Delaying entry by a set number of pips?
14 Oct 2014, 13:59
Hi all,
Could any of you lovely people explain how to delay entry until 5 pips after a Moving Average cross over?
I'm new to coding and am modifying the sample trend robot to fit my system. So far I have changed the code to maintain a position inline with the fast EMA and trending direction. However this creates a huge amount of micro trades when the Moving Averages are converging...
Please ponder over my changes, any advice is greatly appreciated...
protected override void OnTick()
{
var longPosition = Positions.Find(label, Symbol, TradeType.Buy);
var shortPosition = Positions.Find(label, Symbol, TradeType.Sell);
var SlowMa = slowMa.Result.Last(0);
var FastMa = fastMa.Result.Last(0);
if (SlowMa < FastMa && longPosition == null)
{
if (shortPosition != null)
ClosePosition(shortPosition);
ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, label);
}
else if (SlowMa > FastMa && shortPosition == null)
{
if (longPosition != null)
ClosePosition(longPosition);
ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, label);
}
}
}
}
Many Thanks, Ian...

Spotware
14 Oct 2014, 14:05
Try something like this:
and
@Spotware