I'm having an issue here regarding extending a line to the left.
What am I missing? I'd like the line to extend to the first bar of the chart or at least 3 or 4 days ago, not only half of yesterday's.
It's due to MaxBarsBack of the indicator. When I change the following of your code:
Code: Select all
if (LastBarOnChart_s) then begin
if (ExtendLeft = true) then begin
Print("length: ", Symbol_Length, ", maxbarsback: ", MaxBarsBack);
for value1 = 0 to Symbol_Length - MaxBarsBack begin
plot1[value1](lastPrice, "lastPrice", Color);
end;
end;
end;
I get the following output:
length: 173.00 maxbarsback: 0.00
length: 173.00 maxbarsback: 6.00
length: 173.00 maxbarsback: 12.00
length: 173.00 maxbarsback: 21.00
length: 173.00 maxbarsback: 35.00
length: 173.00 maxbarsback: 58.00
length: 173.00 maxbarsback: 95.00
So MaxBarsBack automatically increments when set to Auto-detect (as it should). What I find odd, however, is that setting the MaxBarsBack setting explicitly to a low value (like 10), I get this output:
length: 174.00, maxbarsback: 10.00
length: 174.00, maxbarsback: 17.00
length: 174.00, maxbarsback: 29.00
length: 174.00, maxbarsback: 48.00
length: 174.00, maxbarsback: 79.00
length: 174.00, maxbarsback: 129.00
length: 174.00, maxbarsback: 129.00
length: 174.00, maxbarsback: 129.00
length: 174.00, maxbarsback: 129.00
That's odd because the script starts calculating with a MaxBarsBack of 10 (like I specified), but then automatically increments it exactly as specified in
the documentation.
In this situation, I'd expect the script to throw the "Tried to reference back more bars. Please increase the Max Bars Back setting" error message, and
not to override the manual setting.
(Although I might misunderstand how MaxBarsBack set to 'User Specified' should work).