input nbar = 20; def na = double.nan; # Set up Select Box for which strategy to plot input dir = {default Both,Long,Short}; plot l; switch(dir) { case Short: l=0; case Long: l=1; default: l=1; } l.hide(); plot s; switch(dir) { case Short: s=1; case Long: s=0; default: s=1; } s.hide(); #Start the Code for LOHP and Short Entry def htest = if Highest(high, nbar) == high then 1 else 0; rec lohp = if htest or lohp[1] == 0 then low else lohp[1]; rec ssetup = if htest and close >= lohp[1] then 1 else if ssetup[1] and close >= lohp[1] then 1 else 0; plot plohp = if ssetup*s then lohp else na; #Format the plot plohp.SetDefaultColor(color.orange); plohp.SetStyle(curve.points); plohp.SetLineWeight(5); #Start the Code for HOLP and Long Entry def ltest = if Lowest(low, nbar) == low then 1 else 0; rec holp = if ltest or holp[1]==0 then high else holp[1]; rec lsetup = if ltest and close <= holp[1] then 1 else if lsetup[1] and close <= holp[1] then 1 else 0; plot pholp = if lsetup*l then holp else na; #Format the plot pholp.SetDefaultColor(color.cyan); pholp.SetStyle(curve.points); pholp.SetLineWeight(5);