halcyonguy,
I've studied your formula 3
https://usethinkscript.com/threads/plotting-in-the-expansion-area.9765/#post-91019
for plotting the sloped line and tried unsuccessfully for the past 3 days to modify it so that the slope line begins at the last swinglow within the last 12 bars on a 5minute chart and extends thru current 5minute bar close. I don't know either what's so hard for me to comprehend but any help you would provide is greatly appreciated.
here is image of what i'm trying to achieve:

here is my modified code:
input formula_bars = 6;
def na = Double.NaN;
def bn = BarNumber();
def lastbar = !IsNaN(close[0]) and IsNaN(close[-1]);
def lastbarbn = if lastbar then bn else lastbarbn[1];
def h30mh1 = highest(high,6)[1];
# formula3 plots line based on the slope between the highest high within the last 6 bars to the current bar close
def slope = if bn < lastbarbn then na
# else if lastbar then (close - close[1] )
else if lastbar then (close - h30mh1)
else slope[1];
def formula3 = if (bn < lastbarbn or bn > (lastbarbn + formula_bars)) then na
else if bn == (lastbarbn) then h30mh1
else (formula3[1] + slope);
plot f3 = formula3[-3];
# plot f3 = formula3[-6] works but i want the line plot to always start from the last highest high from the previous 6 bars; formula[-6] offsets the plot by 6 bars it doesn't start the plot from h30mh1 which is the highest high from the previous 6 bars. how can this be done without using [-6]? h30mh1 is a variable where i want the line plot to begin but i need to reference it as a constant. i have no idea how to reference the h30mh1 variable as a constant without getting an error?
Last edited by a moderator: