Hi,
In my study, there are 3-min bars for data1 and daily bars for data2. One daily bar corresponds to 120 3-min bars. If I want to get the 5-day moving average, what MaxBarsBack should I set? 5 or 600? If I set it to 600, then seems both data series share the same MaxBarsBack and the study starts after 600 days from the beginning. Any ideas please?
Thanks.
MaxBarsBack for multi data series
Re: MaxBarsBack for multi data series
This is a known (and very annoying) "feature" of MC.
Assuming you want to calculate a 600-bar average of 3-min bars, then the walk-arounds could be:
1) set the start date of data2 600 days back and indeed use 600 for MaxBarsBack....Simplest, assuming you have the data (you can create/add some dummy back data if you don't)
2) use Exponential moving average (xaverage() ) - which internally needs only the latest data point for calculations.
If you need a 5-day MA of daily closes, then:
var: sma(0,data2);
sma=average(close,5) data(2);
..and the MaxBarsBack setting is to be set as per the max you need in your other calculations.
P.S.: there is a way to address prior values of a variable farther away than set by MaxBarsBack - by using Symbol_Close[ago].
so, you can either try passing this in average() ( most probably will not work) or creating your own MA function that will use symbol_close[x] for calculations.
Assuming you want to calculate a 600-bar average of 3-min bars, then the walk-arounds could be:
1) set the start date of data2 600 days back and indeed use 600 for MaxBarsBack....Simplest, assuming you have the data (you can create/add some dummy back data if you don't)
2) use Exponential moving average (xaverage() ) - which internally needs only the latest data point for calculations.
If you need a 5-day MA of daily closes, then:
var: sma(0,data2);
sma=average(close,5) data(2);
..and the MaxBarsBack setting is to be set as per the max you need in your other calculations.
P.S.: there is a way to address prior values of a variable farther away than set by MaxBarsBack - by using Symbol_Close[ago].
so, you can either try passing this in average() ( most probably will not work) or creating your own MA function that will use symbol_close[x] for calculations.
Re: MaxBarsBack for multi data series
If you need a 5-day MA of daily closes, then:
var: sma(0,data2);
sma=average(close,5) data(2);
If I do this, seems it still needs MaxBarsBack to be set to 600.
var: sma(0,data2);
sma=average(close,5) data(2);
If I do this, seems it still needs MaxBarsBack to be set to 600.
This is a known (and very annoying) "feature" of MC.
Assuming you want to calculate a 600-bar average of 3-min bars, then the walk-arounds could be:
1) set the start date of data2 600 days back and indeed use 600 for MaxBarsBack....Simplest, assuming you have the data (you can create/add some dummy back data if you don't)
2) use Exponential moving average (xaverage() ) - which internally needs only the latest data point for calculations.
If you need a 5-day MA of daily closes, then:
var: sma(0,data2);
sma=average(close,5) data(2);
..and the MaxBarsBack setting is to be set as per the max you need in your other calculations.
P.S.: there is a way to address prior values of a variable farther away than set by MaxBarsBack - by using Symbol_Close[ago].
so, you can either try passing this in average() ( most probably will not work) or creating your own MA function that will use symbol_close[x] for calculations.