Prevent cBot to send double order in a specific Symbol

Created at 09 Jul 2019, 17:45
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!
AL

alexsanramon

Joined 21.02.2019

Prevent cBot to send double order in a specific Symbol
09 Jul 2019, 17:45


Please help me to prevent cBot to send double order in a specific Symbol.

My code is like below which do not work.

if ((RSI.Result.LastValue > 50)  & (Positions.Where(x => x.SymbolName == Symbol.Name) == 0))
            {


                if (!IsPositionOpenByType(TradeType.Buy))
                {
                    OpenPosition(TradeType.Buy);
                }

                ClosePosition(TradeType.Sell);
            }

            if ((RSI.Result.LastValue < 50)   & (Positions.Where(x => x.SymbolName == Symbol.Name) == 0))
            {


                if (!IsPositionOpenByType(TradeType.Sell))
                {
                    OpenPosition(TradeType.Sell);
                }

                ClosePosition(TradeType.Buy);
            }

 


@alexsanramon
Replies

alexsanramon
10 Jul 2019, 01:51

I think I got it.

 

((Positions.Count(x => x.SymbolCode == Symbol.Code)) == 0))


@alexsanramon