Pending order at MarketSeries.High.LastValue does not produce expected results
Pending order at MarketSeries.High.LastValue does not produce expected results
31 Jul 2019, 01:12
Hi -
I have the following in a backtest:
if (Close1 < Open1 && Close2 > Open2 && Close3 > Open3)
{
PlaceStopOrder(TradeType.Buy, Symbol, 10000, MarketSeries.High.LastValue, "ctwm_StopTest", StopLossPips, TakeProfitPips);
}
I have declared all the open and close variables, etc. and they produce what is expected on the chart - just boilerplate stuff.
But I cannot seems to get Target Price of this buy stop to work. I've tried referencing variables of the sort I've declared above, but finally resorted to MarketSeries.High.LastValue, thinking it would put the pending order (buy stop) at the high of the last closed bar, but no go.
I am trying to use the high of the last bar as a buystop for execution anytime during the currently forming candle.
What am I doing wrong here, please? Any help much appreciated, thanks!
PanagiotisCharalampous
31 Jul 2019, 09:29
Hi Aiki1000,
LastValue will give you the value of the current bar, not the last closed bar. For the last closed bar use Last(1).
Best Regards,
Panagiotis
@PanagiotisCharalampous