//@version=4 study("[A618] Trend Tracker", overlay=true) //input variables Length=input(title="Look Back Period", defval=10) ATRPeriod=input(title="ATR Period", defval=10) Mult=input(title="ATR Multiplier", defval=2) //calculate stop value short_stop = lowest(Length)+Mult*atr(ATRPeriod) long_stop = highest(Length)-Mult*atr(ATRPeriod) shortvs = 0.0 longvs = 0.0 shortvs:=na(shortvs[1]) ? short_stop : iff(close>shortvs[1], short_stop , min(short_stop,shortvs[1])) longvs:=na(longvs[1]) ? long_stop : iff(close=shortvs[1] and close[1]longvs[1] , 1 , 0) direction =0 direction := iff(na(direction[1]), 0, iff (direction[1]<=0 and longswitch, 1, iff (direction[1]>=0 and shortswitch, -1, direction[1]))) pc=direction>0?longvs:shortvs // pipCharlie's Code End // Thanks pipCharlie for your amazing Contribution pc_plot = plot(pc, color=color.gray) //My part //REMODELLING THE Higher Time Frame Part // //HTF part resolution = input(25) __0__ = input(true, "===== Resolution should be 5 times the current timeframe ====") short_stop_htf = security( syminfo.tickerid, tostring(resolution), lowest(Length)+Mult*atr(ATRPeriod) ) long_stop_htf = security( syminfo.tickerid, tostring(resolution), highest(Length)-Mult*atr(ATRPeriod) ) shortvs_htf = 0.0 longvs_htf = 0.0 shortvs_htf :=na(shortvs_htf[1]) ? short_stop_htf : iff(close>shortvs_htf[1], short_stop_htf , min(short_stop_htf,shortvs_htf[1])) longvs_htf :=na(longvs_htf[1]) ? long_stop_htf : iff(close=shortvs_htf[1] and close[1]longvs_htf[1] , 1 , 0) direction_htf =0 direction_htf := iff(na(direction_htf[1]), 0, iff (direction_htf[1]<=0 and longswitch_htf, 1, iff (direction_htf[1]>=0 and shortswitch_htf, -1, direction_htf[1]))) pc_htf=direction_htf>0?longvs_htf:shortvs_htf pc_htf_plot = plot(pc_htf, color=color.gray) //condition for color color_cond = pc>pc_htf and close>pc ? color.green : pcpc_htf and close>pc) and not(pc[1]>pc_htf[1] and close[1]>pc[1]) bear_entry_condition = (pc