[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Understanding Max Bars Back



PureBytes Links

Trading Reference Links

I'm trying to understand Max Bars Back. I've written a fair share of (relatively complicated) Easy Language code already, but there are still some things about this that allude me.
1) How does TS compute what MaxBarsBack should be if I don't specify? >From what I gathered from past experience, it looks like it:
1a) Runs indicator on code to see how far back it references. Uses this as MaxBarsBack.
1b) Then it takes MaxBarsBack and SKIPS this many bars on your chart.
1c) After skipping this many bars, it labels the first one your code runs on as BarNumber 1.
1d) BUT, if some code executing on BarNumber 1 references back with []'s the result is 0. i.e. an Average(X,Y) on bar 1 will be 0. If this is the case, why didn't it label the first bar on my chart as bar number 1???
What am I missing here?
As an example, I wrote the following code. It doesn't do anything useful beyond show my area of confusion.
VAR: x(0), y(0); INPUT: LOOPLEN(5); INPUT: AVGLEN(3);

PRINT(File("C:\Log\DEBUG.txt"),BarNumber:4:0," ",Date:6:0," ",TIME:4:0, " ", MAXBARSBACK:3:0, " ");

y = 0; FOR x = 1 TO LOOPLEN BEGIN IF Average(C,AVGLEN)[x+1] > Average(C,AVGLEN)[x] THEN y = y + 1;

PRINT(File("C:\Log\DEBUG.txt"),BarNumber:4:0," ",Date:6:0, " ", Average(C,AVGLEN)[x+1], " ", Average(C,AVGLEN)[x]);

END;

PLOT1(y,"y");
With the default inputs, I get MaxBarsBack set at 7. Why 7? At the bottom of this email is the first part of the output -- note all of the 0's coming from Average(). Why?
If my primary data series is intraday bars (10 min) and I insert a second data series that is daily, how does it compute MaxBarsBack then? e.g. if my code references back 5 10min bars (DATA1) and 2 daily bars (DATA2) is MaxBarsBack 5, and computation starts on the 5th 10min bar? OR does it realize that it needs 2 DAILY bars and starts executing on the 46th 10min bar (where the 2nd daily bar is available)? OR something else?
Am I overlooking something in the documentation that describes all of this?
Any assistance will be greatly appreciated! I expect having these questions anwered will keep me quiet for a while! ;^)
Thanks, Dave
1 980803 1150 7 1 980803 0.00 0.00 1 980803 0.00 0.00 1 980803 0.00 0.00 1 980803 0.00 0.00 1 980803 0.00 0.00 2 980803 1200 7 2 980803 0.00 220.83 2 980803 0.00 0.00 2 980803 0.00 0.00 2 980803 0.00 0.00 2 980803 0.00 0.00 3 980803 1210 7 3 980803 220.83 220.67 3 980803 0.00 220.83 3 980803 0.00 0.00 3 980803 0.00 0.00 3 980803 0.00 0.00 4 980803 1220 7 4 980803 220.67 220.50 4 980803 220.83 220.67 4 980803 0.00 220.83 4 980803 0.00 0.00 4 980803 0.00 0.00 5 980803 1230 7 5 980803 220.50 220.58 5 980803 220.67 220.50 5 980803 220.83 220.67 5 980803 0.00 220.83 5 980803 0.00 0.00 6 980803 1240 7 6 980803 220.58 220.67 6 980803 220.50 220.58 6 980803 220.67 220.50 6 980803 220.83 220.67 6 980803 0.00 220.83 7 980803 1250 7 7 980803 220.67 220.75 7 980803 220.58 220.67 7 980803 220.50 220.58 7 980803 220.67 220.50 7 980803 220.83 220.67 8 980803 1300 7 8 980803 220.75 220.67 8 980803 220.67 220.75 8 980803 220.58 220.67 8 980803 220.50 220.58 8 980803 220.67 220.50 9 980803 1310 7 9 980803 220.67 220.58 9 980803 220.75 220.67 9 980803 220.67 220.75 9 980803 220.58 220.67 9 980803 220.50 220.58 10 980803 1320 7 10 980803 220.58 220.42 10 980803 220.67 220.58 10 980803 220.75 220.67 10 980803 220.67 220.75 10 980803 220.58 220.67