I'm having an issue with MAX().
What I'm trying to do is get the MAX high price over the last 30 days in a back testing scenario.
I want to see if the price during any given point in a backtesting strategy is less than 10% of the prior 30 days high to determine good entry points to go Long. (Not looking for Month bars... I want the literal last 30 Days high, so it's always a running 30 day High)
protected override void OnBarUpdate() { highPeriod = MAX(30)[0]; Print(Instrument.FullName + ": " + "HighPeriod Var is: $" + highPeriod); }
If I backtest it on one day's data, I get nothing. If I backtest on 2 day's data, I get the high from the first day.
I trying to start a strategy on any day I choose, assuming it can look back at data 30 days prior.
Any ideas how to make this happen?
Do I have to start the backtest 30 days prior and then ignore the values for 30 days in order to start my strategy? If that's the case, I don't know how to make that work in a real-time scenario.
Thank you,
Jeff
Comment