Get low of buy bar in backtest to use as stop

During backtesting, I want to set the low of the buy entry bar as the stop loss price. Suppose Buy_bar_low is the price of the entry buy bar. Below code is how I will set the stop;

ApplyStop( type=stopTypeLoss, mode=stopModePoint, amount=(buyprice-Buy_bar_low) )

The question is how do I find Buy_bar_low?

Knowledgebase website is always first station for things like that.

You may play around with bar delay. But if you enter at Open you should delay because otherwise it would be future leak to use Low at Buy entry.

1 Like

x = Valuewhen(Buy, low);
sell = c<x;

1 Like