What is wrong, if cross line then onpe buy or sell repeatedly but I want only open position if close bar

Created at 02 Jun 2017, 11:17
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!
ST

stahur

Joined 24.04.2016

What is wrong, if cross line then onpe buy or sell repeatedly but I want only open position if close bar
02 Jun 2017, 11:17


    if (!isBuyPositions && isSOCBuySignal && _TMA1.Result.LastValue > _TMA2.Result.LastValue)
            {
                closePositions(TradeType.Sell);
                Open(TradeType.Buy);
            }
            if (!isSellPositions && _SMA.Result.LastValue > MarketSeries.Close.LastValue && _TMA1.Result.LastValue > _TMA2.Result.LastValue)
            {
                closePositions(TradeType.Buy);

            }

            if (!isBuyPositions && _SMA.Result.LastValue < MarketSeries.Close.LastValue && _TMA1.Result.LastValue < _TMA2.Result.LastValue)
            {
                closePositions(TradeType.Sell);

            }
            if (!isSellPositions && isSOCSellSignal && _TMA1.Result.LastValue < _TMA2.Result.LastValue)
            {
                Open(TradeType.Sell);
                closePositions(TradeType.Buy);

            }


@stahur
Replies

croucrou
03 Jun 2017, 01:31

Use "OnBar()" instead of "OnTick()".


@croucrou