OnBar - instead of just single order it creates multiple orders

Created at 14 Feb 2017, 11:44
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!
LS

LSR2412

Joined 07.11.2014

OnBar - instead of just single order it creates multiple orders
14 Feb 2017, 11:44


Hi fellow traders,

I have made robot, and in OnBar() I have placed 2 simple pending stop orders (one for buy and one for sell).

but when bar is completed and on next tick, it sends 4 orders..2 for buy and 2 for sell with same levels and same volume.

How I can limit it to only send one order for buy and one for sell.

This is how orders looks like..also before sending order condition must be checked...if position already exists

 

please help, thanks

              
      if ( pos_long == null )
 {

                    PlaceStopOrder(TradeType.Buy, Symbol, volume, MarketSeries.High.Last(1), "MYBC", (MarketSeries.High.Last(1) - MarketSeries.Low.Last(1)) / Symbol.PipSize, takeProfit, MarketSeries.OpenTime.LastValue.AddMinutes(duration.Minutes).AddSeconds(duration.Seconds - 1), "long");
          
                }


                if ( pos_short == null )
                {

                    PlaceStopOrder(TradeType.Sell, Symbol, volume, MarketSeries.Low.Last(1), "MYBC", (MarketSeries.High.Last(1) - MarketSeries.Low.Last(1)) / Symbol.PipSize, takeProfit, MarketSeries.OpenTime.LastValue.AddMinutes(duration.Minutes).AddSeconds(duration.Seconds - 1), "short");

                }

 


@LSR2412
Replies

LSR2412
14 Feb 2017, 12:16

I think I solved it..I just deleted { }..and now it only sends 2 orders

thanks

 


@LSR2412