My SMA cbot is overtrading
Created at 03 Aug 2020, 19:29
PU
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);
}
}
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