Hi all - I gave up trying this. Essentially, what I am looking to do is:
- Take input = fwd_bars (let's say 11).
- let's say today is Jan 1st 2025.
- then looking forward for 11 bars (on a daily chart or for intra-day convert it to the appropriate number of bars equivalent for 11 days).
- find the highest price within the future bars and the lowest price. Subtract each from Jan 1st (meaning current bar) close and plot the two values.
I have tried Highest(high()) and used the Offset, but Highest() seems to be going forward to 11th day and getting the highest. Which is not what I want, because highest value could have occured in between.
I tried LookUp highest but this looks at the previous 11 bars!
I do understand that for the most recent 11 days there will not be a plot, which is fine.
- Take input = fwd_bars (let's say 11).
- let's say today is Jan 1st 2025.
- then looking forward for 11 bars (on a daily chart or for intra-day convert it to the appropriate number of bars equivalent for 11 days).
- find the highest price within the future bars and the lowest price. Subtract each from Jan 1st (meaning current bar) close and plot the two values.
I have tried Highest(high()) and used the Offset, but Highest() seems to be going forward to 11th day and getting the highest. Which is not what I want, because highest value could have occured in between.
I tried LookUp highest but this looks at the previous 11 bars!
I do understand that for the most recent 11 days there will not be a plot, which is fine.
Code:
declare lower;
input Look_fwd = 11;
#def hi = highest(high()[-look_fwd]);
def hi = LookUpHighest(length = -look_fwd);
def hi_diff = hi - close();
def low = Lowest(low()[-Look_fwd]);
def lo_diff = low - close();
plot hidiff = hi_diff;
plot lodiff = lo_diff;
Last edited by a moderator: