My SMA cbot is overtrading

Created at 03 Aug 2020, 19:29
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!
PU

puppiebullet1

Joined 11.07.2020

My SMA cbot is overtrading
03 Aug 2020, 19:29


I created an SMA cbot to execute trades when the SMA crosses the bid price and it works well except for certain times where it over trades within a small range of price any help?

protected override void OnTick()
        {           
            var SMA = sma.Result.LastValue;
            if (SMA > Symbol.Bid)
            {
                Close(TradeType.Buy);
                Open(TradeType.Sell);
            }
            else if (SMA < Symbol.Bid)
            {
                Close(TradeType.Sell);
                Open(TradeType.Buy);
            }
        }

 


@puppiebullet1
Replies

PanagiotisCharalampous
04 Aug 2020, 08:10

Hi puppiebullet1,

Your code does not check for crossovers but if the price is above or below the SMA. Hence it will open trades on every tick. Try adding a condition that will check if positions are already open in that direction before placing a new one.

 Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous