When I run backtest, it's always in a trade, so instead of just exiting long, it's exiting long and entering short instantly, and vice versa the other direction. For example, when I look at my chart for an exit long, the bar closed below the indicator but it did not open below the indicator, so I'm not sure why it'd be entering short. Here's a sample of my code:
protected override void OnBarUpdate() { // Condition set 1 - If bar open is above BCD line AND bar is green if (Open[0] > BCDLine[0] && Close[0] > Open[0]) { EnterLongLimit(DefaultQuantity, Close[0], "long"); } // Condition set 2 - If close crosses below BCD line if (Close[0] < BCDLine[0]) { ExitLong("exit long", "long"); } // Condition set 3 - If bar close is below BCD line AND bar is red if (Open[0] < BCDLine[0] && Close[0] < Open[0]) { EnterShortLimit(DefaultQuantity, Close[0], "short"); } // Condition set 4 - If close crosses above BCD line if (Close[0] > BCDLine[0]) { ExitShort("exit short", "short"); } }
Comment