Buy and Sell in the same day

Hi,

How can I buy and sell a stock with Open price at the beginning of the day and to Sell at the end of the day.
For example AAPL :

  • start a day at 53.5 - I want to Buy
  • end the same day at 54.0 - I want to Sell .

Thanks
-

Implemented.

There is an option “AllowSameBarExit” in Seetu now:

SetOption("AllowSameBarExit",FALSE);

or

SetOption("AllowSameBarExit",TRUE);

A default value (when this option is not used at all) is FALSE


Here is an example code:

SetOption("AllowSameBarExit",TRUE);

BuyPrice = Open; // Buy at Open prices
SellPrice = Close; // Sell at Close prices

Buy = Cross(CalcMACD(), CalcMACDSignal());

// Sell at the same bar
Sell = Buy;

Effects:

  1. SetOption(“AllowSameBarExit”,FALSE);

  1. SetOption(“AllowSameBarExit”,TRUE);

Happy trading!

Thanks Bob. It’s very helpful