I'm not sure why this is happening. As you can see from this one picture... SOMETIMES the trailing stop I programmed works...and sometimes it looks like it gets me out at the very price I got in at. (actually in the pic, I set the bars back to 10 during a back test...so if you noticed that it wasn't a 5 bar low, you're really good)
Help.
What it's SUPPOSED to do is create a natural volatility trailing stop that takes the lowest low of the last 5 bars (subtracts one more tick) and keeps updating this on each close. This allows some pullbacks, but generally grabs the majority of any break outs that might happen during the trade.
//variables
private int barsAgo = 5; // Default setting for BarsAgo
private int plusX = 1; // Default setting for PlusX
// Initialize
// (...nada)
// OnBarUpdate()
// local variables
int LoBar = LowestBar(Low,barsAgo);
int HiBar = HighestBar(High,barsAgo);
// Exit Long
if (Position.MarketPosition == MarketPosition.Long)
{
{SetStopLoss(CalculationMode.Price, Low[LoBar]-(plusX*TickSize));}
}
// Exit Short
if (Position.MarketPosition == MarketPosition.Short)
{
{SetStopLoss(CalculationMode.Price, High[HiBar]+(plusX*TickSize));}
}
Comment