I want to run a strategy that relies on the previous 2 5000 tick bars. However I don't really want to do it by bar, I want to have a moving window of the last 5000 ticks and the 5000-10000th ticks. So what I was doing is just keeping a list of my own of these ticks.
public class scalper : Strategy { List<double> barFar = new List<double>(); List<double> barNear = new List<double>(); ..... protected override void Initialize() { CalculateOnBarClose = false; EntryHandling = EntryHandling.UniqueEntries; } protected override void OnBarUpdate() { double curPrice = Close[0]; numTicks++; barNear.Add(curPrice); while(barNear.Count > ticksTimeFrame) { barFar.Add(barNear[0]); barNear.RemoveAt(0); } while(barFar.Count > ticksTimeFrame) { barFar.RemoveAt(0); } List<double> barFarCopy = new List<double>(barFar); List<double> barNearCopy = new List<double>(barNear); if(barFar.Count == ticksTimeFrame && barNear.Count == ticksTimeFrame) { barFarCopy.Sort(); barNearCopy.Sort(); double barNearMid = Math.Min(barNearCopy[0], barNearCopy[barNearCopy.Count - 1]) + Math.Abs(barNearCopy[0] - barNearCopy[barNearCopy.Count - 1]); double barFarMid = Math.Min(barFarCopy[0], barFarCopy[barFarCopy.Count - 1]) + Math.Abs(barFarCopy[0] - barFarCopy[barFarCopy.Count - 1]);
Thanks
-Jeff
Comment