Pending order at MarketSeries.High.LastValue does not produce expected results

Created at 31 Jul 2019, 01:12
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
AI

Aiki1000

Joined 22.07.2019

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!


@Aiki1000
Replies

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