I'm trying to have a strategy enter after 3 consectutive closes in a specific direction, and reverse after only after 3 bars have gone the opposite direction. Here was my first attempt at the strategy but it's not working quite right. Hoping someone can take a look to see what my flaw is here:
protected override void OnBarUpdate() { if (BarsInProgress != 0) return; if (CurrentBars[0] < 4) return; // Set 1 if ((High[0] > High[1]) && (High[1] > High[2]) && (High[2] > High[3]) && (High[3] < High[4])) { EnterLong(Convert.ToInt32(DefaultQuantity), @"long"); } // Set 2 if ((Low[0] < Low[1]) && (Low[1] < Low[2]) && (Low[2] < Low[3]) && (Low[3] > Low[4])) { EnterShort(Convert.ToInt32(DefaultQuantity), @"short"); }
Comment