Add "shift" function to Donchian Channel?

M

mrmac

New member
VIP
Hi, I have a very simple donchian channel indicator and would like to add a "shift" (I think it is called shift) function to it, is this possible please?

Code:
input length_used_for_calc= 10;
input Use_Other_Time_Frame=yes;
input Time_Frame=aggregationPeriod.DAY;
def h= if use_Other_Time_Frame then high(period=time_Frame) else high;
def l= if use_Other_Time_Frame then low(period=time_Frame) else low;
def highline= highest(high,length_used_for_calc);
def lowline= lowest(low,length_used_for_calc);
Plot High_Line= highline;
high_line.setdefaultColor(color.magENTA);
Plot Low_Line=lowline;
low_Line.setdefaultColor(color.magentA);
 
Last edited by a moderator:
horserider

horserider

Well-known member
VIP
Maybe you mean "Displace".
You would need;
input displace = x;
plot High_Line= (highline[displace]);
Plot Low_Line=(lowline[displace]);
 
M

mrmac

New member
VIP
Maybe you mean "Displace".
You would need;
input displace = x;
plot High_Line= (highline[displace]);
Plot Low_Line=(lowline[displace]);
Thank you very much @horserider - that is exactly what I was looking for. Appreciate your help.
 
madeinnyc

madeinnyc

Member
@horserider , if I want to displace 1 bar back, would it be written as: input displace = -1 or input displace = 1 bar? Thanks!
 
horserider

horserider

Well-known member
VIP
@madeinnyc Bad memory but 1 should be one bar back -1 one bar forward. ?????? Just try and see what way is goes.
input displace = 1;
or
input displace = -1;

Still in Texas? It is time for heat !
 
madeinnyc

madeinnyc

Member
@horserider Thanks for confirming!
yes, still in TX....I don't know how ya'll handle this heat! 🥵
 

Similar threads

Top