//Trend Following _SECTION_BEGIN("Price1"); SetChartOptions(0, chartShowArrows | chartShowDates); _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue(ROC(C, 1)))); Plot(C, "Close", ParamColor("Color", colorBlack), styleNoTitle | ParamStyle("Style") | GetPriceStyle()); _SECTION_END(); _SECTION_BEGIN("tboly varázs afl"); SetChartOptions(0, chartShowArrows | chartShowDates); // **************** INITIAL CONDITIONS: bi = BarIndex() - 1; // ************************************** ADAPTIVE PERIODS *********************** // **************** BASE PERIODS tf = Param("tf", 1, 1, 500, 1); bp = tf * Param("bp", 24, 2, 500, 1); // ************************************************************ HiHi = HHV(H, bp); HiRH = Ref(HiHi, - 1); LoLw = LLV(L, bp); LoRL = Ref(LoLw, - 1); // long exit //Plot( HiHi, "H", colorCustom12 , 1); //Plot( LoLw, "L", colorCustom9 , 1); //Plot( Lorl, "L", colorBlue , 32); //Plot( Hirh, "H", colorRed , 32); bs = BarsSince(H == HiHi); // Promt bl = BarsSince(L == LoLw); // Promt LtHL = ValueWhen(bs > bl, HiHi); StLH = ValueWhen(bs < bl, LoLw); BarLthl = BarsSince(bs < bl AND Hirh == Lthl); BarStLH = BarsSince(bs > bl AND Lorl == Stlh); PlotShapes(IIf(bs > bl AND Ref(bs, - 1) < Ref(bl, - 1), shapeSmallDownTriangle, 0), colorRed, layer = 0, yposition = H, offset = - 10); PlotShapes(IIf(bs < bl AND Ref(bs, - 1) > Ref(bl, - 1), shapeSmallUpTriangle, 0), colorGreen, layer = 0, yposition = L, offset = - 10); BarloSl = IIf(BarStLH > BarLthl, BarLthl + 1, 0); BarshSl = IIf(BarStLH < BarLthl, Barstlh + 1, 0); LoLL = LLV(L, bl + 1); //Plot( IIf( bl > 0 , LoLL, Null) , "", colorBlue, 1 ); LoH = HHV(H, bl + 1); Plot(IIf(bl > 0, LoH, Null), "", colorCustom9, 1); // Range sign ShHH = HHV(H, bs + 1); //Plot( IIf( bs > 0 , ShHH, Null) , "", colorRed, 1); ShL = LLV(L, bs + 1); Plot(IIf(bs > 0, ShL, Null), "", colorCustom12, 1); // Range sign // ************************ NOISE ******************************** //Noise= MA( HHV(H,bp/6)-LLV(L,bp/6) ,bp); // ********************** NOISE HL1 ******************************* np = Param("np", 2, 2, 500, 1); NoHL = H - L; NoHLMa = MA(Nohl, np); mpHL1 = NoHL / NoHLMa; // ********************** NOISE HL2 ******************************* Noise = HHV(H, 2 *tf) - LLV(L, 2 *tf); NoiseMa = MA(Noise, np); momHL = NoHL / NoiseMa; momLo = momHL >= 1 AND C > O; momSh = momHL >= 1 AND C < O; momlb = 1100; //Param("momlb",100,2,2500,1); momst = Sum(IIf(momHL >= 1, 1, 0), momlb) / momlb * 100; //PlotShapes(IIf(momlo,shapeSmallCircle,0),colorBlue, layer = 0, yposition= H, offset = 15 ); //PlotShapes(IIf(momsh,shapeSmallCircle,0),colorRed, layer = 0, yposition =L, offset = - 15 ); mpnma = Noise / NoiseMa; mpn = Param("mpnoise", 0.85, 0, 3, 0.025); HLVlsl2 = LLV(L + noisema * mpn *(1+log10(bs + 1)), bs + 1); Plot(IIf(bs > 0, Ref(Min(Hlvlsl2, shhh), - 1), Null), "Sh", colorBlue, 1); // Range sign + noise //Plot( Ref(Min(Hlvlsl2,shhh),-1) , "Sh", colorBlue, 1); // Range sign + noise Plot(IIf(bs > 0, (Ref(Min(Hlvlsl2, shhh), - 1) + shl) / 2, Null), "Shf", colorBlue, 32); HLVlsl = HHV(H - noisema * mpn *(1+log10(bl + 1)), bl + 1); Plot(IIf(bl > 0, Ref(Max(HLvlsl, Loll), - 1), Null), "Lo", colorRed, 1); // Range sign-noise //Plot( Ref(Max(HLvlsl,Loll),-1) , "Lo", colorRed, 1); // Range sign-noise Plot(IIf(bl > 0, (Ref(Max(HLvlsl, Loll), - 1) + Loh) / 2, Null), "Lo", colorRed, 32); // ******************** HL2 NOISE BASE LG **************************************** RHAb = (ShHH - LoLL); //Plot( (H+L)/2+Ref(MA(H-L,bp),-1)/2,"",colorBlack,1); //Plot( (H+L)/2-Ref(MA(H-L,bp),-1)/2,"",colorBlack,1); dHLNoise = IIf((bs > 0 AND Ref(Hlvlsl2, - 1) < Ref(shhh, - 1))AND(bl > 0 AND Ref(HLvlsl, - 1) > Ref(Loll, - 1)), (Ref(Min(Hlvlsl2, shhh), - 1) - Ref(Max(HLvlsl, Loll), - 1)) / (noisema *mpn), 0); // ********************************************************************************************************** // **************************** BUY/SELL CONDITIONS ****************************************************** Buy = (bs < bl AND Ref(bs, - 1) > Ref(bl, - 1)); Sell = (bs > bl AND Ref(bs, - 1) < Ref(bl, - 1)); PlotShapes(IIf(Buy,shapeHollowUpArrow,0),colorDarkGreen, layer = 0, yposition= Low, offset = - 25 ); PlotShapes(IIf(Sell,shapeHollowDownArrow,0),colorRed, layer = 0, yposition =High, offset = - 25 ); /*Buy = bl>0 AND L< Ref(Max(HLvlsl,Loll),-1) AND H >Ref(Max(HLvlsl,Loll),-1) ; //BuyPrice= LFLong ; Sell= bs>0 AND H> Ref(Min(Hlvlsl2,shhh),-1) AND L< Ref(Min(Hlvlsl2,shhh),-1) ; //SellPrice= LFShort ; // **************** FLIP CONDITIONS //Buy = ExRem(Buy,Sell); //Sell = ExRem(Sell,Buy); PlotShapes(IIf(Buy,shapeUpArrow,0),colorBlue, layer = 0, yposition= Low, offset = - 10 ); //PlotShapes(IIf(Sell,shapeHollowDownArrow,0),colorRed, layer = 0, yposition =High, offset = - 25 ); // **************************** SHORT/SELL CONDITIONS ****************************************************** Short=Sell; Cover=Buy; PlotShapes(IIf(Short,shapeDownArrow,0),colorRed, layer = 0, yposition =High, offset = - 10 ); //PlotShapes(IIf(Cover ,shapeHollowUpArrow,0),colorBlue, layer = 0, yposition= Low, offset = - 25 ); */ // ************************** PLOT CANDLE *********************** /* Plot( Close, "", IIf( (L > LFLong AND LFLongL < LFLongS) , colorBlue, IIf( (H < LFShort AND !LFShortL < LFShortS) , colorRed, //IIf( LFLongL < LFLongS AND !LFShortL < LFShortS , colorBlack, //AND LFShortL < LFShortS AND !LFLongL < LFLongS colorBlack)) , styleCandle ); //OR (LFShort> LFLong AND L>LFShort) //OR (LFShort> LFLong AND H bs, colorGreen,54)),styleOwnScale | styleArea | styleNoLabel, - 0.5, 100); /*Plot( 2, "",IIf( bl > 0 , colorBlue,//IIf( bl > bs AND L< Ref(Max(HLvlsl,Loll),-1) AND H 0, (H / Ref(L, - bl) *100-100) / (bl + 1), H / L * 100-100), 1.2) //+ " \\c29 RelLoL = \\c-1" + WriteVal(IIf( bl>0, (L/Ref(L,-bl)*100-100)/(bl+1),0 ) ,1.2) + " \\c29 Lbase = \\c-1"+WriteVal( slg,1.2) + " \\c29 RelLoRew = \\c-1" + WriteVal(IIf(bl > 0, ((L / Ref(L, - bl) *100-100) / (bl + 1)) / ((H / Ref(L, - bl) *100-100) / (bl + 1)) *100-100, 0), 1.2) + " \\c32 \nRelShH = \\c-1" + WriteVal(IIf(bs > 0, (L / Ref(H, - bs) *100-100) / (bs + 1), L / H * 100-100), 1.2) + " \\c32 RelShH = \\c-1" + WriteVal(IIf(bs > 0, (H / Ref(H, - bs) *100-100) / (bs + 1), 0), 1.2) + " \\c32 RelShRew = \\c-1" + WriteVal(IIf(bs > 0, ((H / Ref(H, - bs) *100-100) / (bs + 1)) / ((L / Ref(H, - bs) *100-100) / (bs + 1)) *100-100, 0), 1.2) ; _SECTION_END(); VP = Param("Period for Avg Vol" , 10, 50, 240, 1); // sets the period for the average volume calculation Filter = C <60 AND C >2 AND Volume > 100000 AND C> Ref(C,-1);//AND PDI (14)> MDI(14); // Filter = Buy OR Sell; Action = WriteIf(Buy, "BUY", WriteIf(Sell, "SELL", " ")); Result = WriteIf(Buy,"Buy","Sell"); AddTextColumn( WriteIf(Buy, "Buy" , "Sell" ) , "TRADE" , 5 , IIf(Buy,colorYellow, colorWhite), IIf(Buy, colorDarkGreen, colorRed) ); AddTextColumn(IndustryID(1) ,"Industry Sector ", 25.0, colorWhite, colorBlue, 125); // adds a column for the industry sector AddColumn(C, "Close", 3.2, colorBlue, colorYellow, 55); // adds a column for today's close AddColumn(Ref(Close,-1),"Y-Close",1.2, IIf( ROC(Ref(C,-1),1)>=0,colorDarkGreen, colorRed ),50 ); AddColumn( ROC( Close, 1 ), "ROC(1)", 1.2, IIf( ROC(C, 1 ) >= 0,colorDarkGreen, colorRed)); AddColumn(BuyPrice, "BuyPrice" ,3.1, colorWhite,colorDarkGreen); AddColumn(SellPrice, "SellPrice",3.1, colorYellow, colorDarkBlue, 75); // adds a column for the close as a % from the prior close AddColumn(V, "VOLUME",8.0, colorYellow, colorDarkGreen, 75); // adds a column for today's volume AddColumn( Ref(MA(V,VP),-1), WriteVal(VP, 2.0)+ " dMA", 8.0, colorWhite, colorBlue, 75); // adds a column for the average volume