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

Re: needing help and advice on maxbarsback



PureBytes Links

Trading Reference Links

> (My belief is that a maxbarsback of auto just means Tradestation
> first tries with a low number, when it hits a problem with that
> number it increases maxbarsback and then tries again). This is
> correct? 

That's exactly what happens.  You can see this happening if you print 
the bar date/time/number on each bar, then go through the print log. 
You'll see it start at the first bar, go through some number of bars 
until it hits the MBB limit, then it goes back to the start with a 
larger MBB.  It may do this many times, depending on the study.

Obviously that will totally mess up any data you write to files.

> Anyone know the algorithm for how it increases maxbarsback?

I don't know the precise algorithm, but you can infer it.

I applied this indicator to a daily chart, with MBB set to "Auto":

  fileappend("e:\temp\foo.txt",
    numtostr(d,0) & ": BarNumber = " & numtostr(BarNumber,0) & newline);
  value1 = highest(high, BarNumber);
  if false then plot1(0,"");

The file shows that barnumber went from 1 to 3, then 1-5, then 1-7, 1-
9, 1-11, 1-13, 1-15 ...  I think I see a pattern forming here.  :-)

If I change the lookback to highest(high,10*BarNumber), the first few 
lines look like this:

980730: BarNumber = 1
980812: BarNumber = 1
980813: BarNumber = 2
980826: BarNumber = 1
980827: BarNumber = 2
980828: BarNumber = 3
980910: BarNumber = 1
980911: BarNumber = 2
980914: BarNumber = 3
980915: BarNumber = 4
980924: BarNumber = 1
980925: BarNumber = 2
980928: BarNumber = 3
980929: BarNumber = 4
980930: BarNumber = 5
981008: BarNumber = 1
981009: BarNumber = 2
981012: BarNumber = 3
981013: BarNumber = 4
981014: BarNumber = 5
981015: BarNumber = 6
981022: BarNumber = 1

So it appears to be jumping MBB by about 10 each time.  It looks like 
the algorithm is somewhat adaptive.

Notice, BTW, that the date on BarNumber 1 **changes** each time.  
That's because BarNumber = 1 is NOT the first bar of the chart, but 
the MaxBarsBack+1 bar.  980730 is actually the 2nd bar on the chart, 
so MBB was 1 on the first attempt.  980812 is the 11th bar, so MBB 
was 10 on the 2nd attempt.  980826 was the 21st bar, 980910 was the 
31st bar, etc.

If I was to guess, I would say TS is increasing MBB just enough to 
cover the case that just exceeded the old MBB.  E.g. the first pass 
had MBB = 1, but I looked back 10*BarNumber or 10.  So it set it to 
10 on the second attempt.

> Now, when I am planning to change this setting, I am afraid of
> causing errors that I do not have today. 

If you understand your indicators, you know how far back they can go. 
 Set MBB to that value.

If your indicators have an unbounded lookback -- e.g. if they store 
the last high swing, and then do a highest(High,LastSwing) or 
something like that -- you can usually rewrite them to avoid the 
lookback.  You'll limit your unbounded lookback and the indicator 
will be more efficient in the bargain.  (Of course, efficiency is 
probably not a key concern if you're dumping stuff to files.)

> The manual recommends to always set it to at least 50. Why? I can
> not see any good reason? 

It's just a reasonable starting point that covers common usage 
patterns for most users.  There's no need to set it that high if you 
don't need it.  E.g. let's say you have an indicator that does an 
xaverage, and nothing else that looks into history.  You could 
actually set MBB to 1 because xaverage only looks back 1 bar.

> If using the workchart assistant for scanning a lot of stocks and
> having a maxbarsback setting that is too low, will I ever get an
> error message telling me if maxbarsback is too low? Or will I just
> have a number of indicators that did not deliver data for some
> stocks? Or was even turned off? Anyone could give me some hints on
> this? 

You'll get an error.  Like I said, you need to look at your indicator 
to see how far back it actually can look.  If it's unbounded, rewrite 
the indicator to limit the lookback.

Gary