In the first two attached screenshots, I have demonstrated the automatic expansion of chart scale with specific settings using the two indicators described above. I have varied the user-input called "offset_price" from 100, to 200, and finally to 400 across three copies of the same chart.
I modified original code which I thought was called "Last Price Line Arnie" but now I cannot locate the original thread. I want to express my thanks to the original authors.
Here is the code for "scaling_line_hi_a":
Code: Select all
inputs:
Color(rgb(255,255,255)),
RightShift(50),
offset_price(100)
;
variables:
firstBar(0),
lastPrice(0)
;
//+++++++++++++++++++++
//+++++++++++++++++++++
//+++++++++++++++++++++
/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// start: Scaling_Line_high
//
/////////////////////////////////////////////////////////////////////////////////////////////////////
if currentbar = 1 then
firstBar = currentbar;
lastPrice = high + offset_price;
for value1 = 0 to (currentbar - firstBar) begin
plot1[value1](lastPrice,"vizHi", Color);
end;
for value1 = 0 to RightShift begin
Plot1[-value1](lastPrice, "vizHi", Color);
end;
noplot(1);
/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// end: Scaling_Line_high
//
/////////////////////////////////////////////////////////////////////////////////////////////////////
Here is the code for "scaling_line_lo_a":
Code: Select all
inputs:
Color(rgb(255,255,255)),
RightShift(50),
offset_price(100)
;
variables:
firstBar(0),
lastPrice(0)
;
//+++++++++++++++++++++
//+++++++++++++++++++++
//+++++++++++++++++++++
/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// start: Scaling_Line_low
//
/////////////////////////////////////////////////////////////////////////////////////////////////////
if currentbar = 1 then
firstBar = currentbar;
lastPrice = low - offset_price;
for value1 = 0 to (currentbar - firstBar) begin
plot1[value1](lastPrice,"vizLo", Color);
end;
for value1 = 0 to RightShift begin
Plot1[-value1](lastPrice, "vizLo", Color);
end;
noplot(1);
/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// end: Scaling_Line_low
//
/////////////////////////////////////////////////////////////////////////////////////////////////////