// Downloaded From https://www.WiseStockTrader.com _SECTION_BEGIN("Unnamed 32"); /*TREND DETECTOR WITH VARIABLE PERIOD, by D. Tsokakis, Apr2003*/ t=Param("f",20,1,60,1); // fast period x=DEMA(StochD(40),t); Plot(x,"",1,8);// fast trend detector tA=Param("movcc",50,1,60,1); // slow period xA=DEMA(StochD(40),tA); Plot(xA,"",7,8);// slow trend detector Cond1=Ref(x,-1)==LLV(x,3); Plot(50*Cond1,"",5,2);// the start of the fast uptrend Cond2=Ref(x,-1)==HHV(x,3); Plot(50*Cond2,"",4,2);// the end of the fast uptrend k1=BarsSince(Cond1);// uptrend bar counter k2=BarsSince(Cond2);// downtrend bar counter Plot((k2>k1)*10,"",5,2); Plot((k2k1,t+k1,t+k2);// the variable period x1=DEMA(StochD(40),t1);// the variable trend detector Plot(x1,"",(x1>Ref(x1,-1))*5+(x1