I tried to set a trailing stop to the lowest low for the previous 10 bars. I did not see that option in the strategy wizard so I set the trailing stop to the available option of Variable0 and unlocked the code to see the following:
protectedoverridevoid Initialize()
{
SetTrailStop("", CalculationMode.Ticks, Variable0, false);
CalculateOnBarClose = true;
}
I then edited the code (and saved the changes) to the following:
protectedoverridevoid Initialize()
{
SetTrailStop(Low[10]);
CalculateOnBarClose = true;
}
When I backtest the strategy on daily bars the trailing stop gets set to the open price of the bar where a long position is taken, essentially entering and exiting at the same price. Where did I go wrong, with my code?
This is my first attempt at inserting code into the strategies I create so please forgive me if the answer is obvious.
Thanks in advance for your help.
Joe

Comment