Access data from the first candle entry in the operation


First, I want to thank the developers of this excellent software! I am use for backtests on Brazilian market.

I'm doing some backtests and I need help to access the open, lower, hight, close datas of the first candle that entry the operation, example:

// buy if the current price is greater than 1

Buy = H > 1;

// sell if the current price is 2 x higher than the closing of the entry candle

Sell = H> (close price of the entry candle * 2)

I try don't sucess:

  • Close[0]

  • Ref(Close, -BarsSince(Buy))


Valuewhen() function is a good place to start.

Be aware though that the use of Exrem() to remove buy/sell signals to function as desired. Regular backtest will handle that but say you want to plot the AFL on chart it could be needed depending on your logic.

1 Like