protected override void Initialize()
{
CalculateOnBarClose = false;
}
protected override void OnBarUpdate()
{
...
bool goingdown = false;
....
if (NBarsDown(3, true, true, true)[0] == 1)
goingdown = true;
...
// If you have 3 consecutive bars go against the trade, get out
if (goingdown)
ExitLong();
}
However, when I run the code on real data, I still have conditions where there are 3 bars going down (in my LONG trade) but the strategy doesn't exit the long condition. Any ideas? I do set a stop loss prior to these lines of code using:
SetStopLoss(CalculationMode.Price, smaT);
Does the SetStopLoss inclusion override the logical "if going down, get out" logic? Any feedback or pointers would be appreciated.
Regards,
Dwayne
Comment