Stock Portfolio Organizer
The ultimate porfolio management solution.
Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
NEW AFL for Amibroker (AFL)
Copy & Paste Friendly
Back
_SECTION_BEGIN("Name"); GfxSetOverlayMode(1); pxh= Status("pxHeight"); pxw=Status("pxWidth"); GfxSelectFont("Tahoma",pxh/30); GfxSetTextColor(colorWhite); GfxSetTextAlign(6); GfxSetBkMode(0); GfxTextOut(FullName(),pxw/2,pxh/12); GfxSelectFont("Tahoma",pxh/15); GfxTextOut("",pxw/2,pxh/3); _SECTION_END(); _SECTION_BEGIN("Trend Detection"); function Rise( Pd, perd, Pl, perl ) { MAD = DEMA(Pd,perd); MAL = LinearReg(Pl,perl); CondR = ROC(MAD,1)>0 AND ROC(MAL,1)>0; CondF = ROC(MAD,1)<0 AND ROC(MAL,1)<0; R[0] = C[0]>(H[0]+L[0])/2; for(i=1;i<BarCount;i++) { if( CondR[i] ) { R[i] = 1; } else { if( CondF[i] ) { R[i] = 0; } else { R[i] = R[i-1]; } } } return R; } PrD = C; PrL = H/2+L/2; PrdD = PrdL = PrdM = Param("Prd",12,2,40,1); permax = Max(prdd,prdl); Rs = IIf( BarIndex()<permax, 0, Rise(PrD, PrdD, PrL, PrdL) ); Fs = IIf( BarIndex()<permax, 0, 1-Rs ); Confirm = MA(C,prdm); function DirBar( dr, df ) { B[0] = 0; for(i=1;i<BarCount;i++) { if( dr[i-1] && df[i] ) { B[i] = 1; } else { if( df[i-1] && dr[i] ) { B[i] = 1; } else { B[i] = B[i-1] + 1; } } } return B; } Bs = DirBar( Rs, Fs ); Direction = ROC(Confirm,1) > 0 AND ROC(Confirm,5) > 0; Downward = ROC(Confirm,1) < 0 AND ROC(Confirm,5) < 0; Select = Rs AND Ref(Fs,-1); Caution = Fs AND Ref(Rs,-1); Change = IIf( Rs, H/ValueWhen(Fs,L)*100, L/ValueWhen(Rs,H)*100 ); PlotShapes( shapeSmallCircle* select, colorDarkGreen, 0, H,-14 ); PlotShapes( shapeSmallCircle* Caution, colorDarkRed, 0, L, 14 ); _SECTION_BEGIN("Sloping Channel"); //Pattern Recognition graph with shading /*TRENDLINES BREAKOUT*/ x = Cum(1); per = Param("Percent",3,1,20,1); s1=L; s11=H; pS = TroughBars( s1, per, 1 ) == 0; endt= LastValue(ValueWhen( pS, x, 1 )); startt=LastValue(ValueWhen( pS, x, 2 )); endS = LastValue(ValueWhen( pS, s1, 1 ) ); startS = LastValue( ValueWhen( pS, s1, 2 )); dtS =endt-startt; aS = (endS-startS)/dtS; bS = endS; trendlineS = aS * ( x -endt ) + bS; pR = PeakBars( s11, per, 1 ) == 0; endt1= LastValue(ValueWhen( pR, x, 1 )); startt1=LastValue(ValueWhen( pR, x, 2 )); endR = LastValue(ValueWhen( pR, s11, 1 ) ); startR = LastValue( ValueWhen( pR, s11, 2 )); DTR=ENDT1-STARTT1; aR = (endR-startR)/dtR; bR = endR; trendlineR = aR * ( x -endt1 ) + bR; BEGIN=Min(STARTT,STARTT1); TRS = IIf(x>BEGIN-10,trendlineS,-1e10); TRR = IIf(x>BEGIN-10,trendlineR,-1e10); Condcolor=(Cross(C,trendlineR) AND X>ENDT1) OR (Cross(trendlineS,C) AND X>ENDT); BarColor=IIf(Condcolor,7,1); Plot(TRS,"Support",colorCustom11,styleDots); Plot(TRR,"Resist",colorCustom11,styleDots); ///////////////////////////////////// // Pattern Recognition in title bar // /////////////////////////////////////////// Lowline=Ends-starts; Highline=endr-startr; Wedge=IIf(Highline <0 AND Lowline > 0,1,0); DecendingTriangle=IIf(Highline < 0 AND Lowline==0,1,0); AscendingTriangle=IIf(Highline==0 AND Lowline > 0,1,0); DownChannel=IIf(Highline<0 AND Lowline<0,1,0); UpChannel=IIf(Highline>0 AND Lowline>0,1,0); BroadeningWedge=IIf(Highline > 0 AND Lowline < 0,1,0); /////////////////////////////////// // Bullish or Bearish breakout // ////////////////////////////////// BullishBreakout=Cross(C,trendlineR); BearishBreakout=Cross(trendlineS,C); Breakout =WriteIf(C > trendlineR, "Bullish","Bearish"); PlotShapes(IIf(BullishBreakout,shapeDigit6,Null),C olorRGB(176,176,255),0,L,130); PlotShapes(IIf(BullishBreakout,shapeUpArrow,Null), ColorRGB(176,176,255),0,L,120); PlotShapes(IIf(BearishBreakout,shapeDigit7,Null),c olorViolet,0,H,120); PlotShapes(IIf(BearishBreakout,shapeDownArrow,Null ),colorViolet,0,H,-130); Plot(BullishBreakout,"",ColorRGB(176,176,255),styl eHistogram|styleDashed|styleOwnScale|styleNoLabel, 0,1,0,0); Plot(BearishBreakout,"",colorViolet,styleHistogram |styleDashed|styleOwnScale|styleNoLabel,0,1,0,0); _SECTION_BEGIN("companysympole"); _SECTION_BEGIN("companyclos"); { GfxSelectFont("french script mt",13, 800 ); GfxSetBkMode(1); GfxSetTextColor(colorWhite); GfxTextOut("C="+C+" ",580,1); } _SECTION_END(); _SECTION_BEGIN("companyhigh"); { GfxSelectFont("french script mt",13, 800 ); GfxSetBkMode(1); GfxSetTextColor(colorCustom13); GfxTextOut("H="+H+" ",480,1); } _SECTION_END(); _SECTION_BEGIN("companyopen"); { GfxSelectFont("french script mt",13, 800 ); GfxSetBkMode(1); GfxSetTextColor(colorWhite); GfxTextOut("O="+O+" ",380,1); } _SECTION_END(); _SECTION_BEGIN("companylow"); { GfxSelectFont("french script mt",13, 800 ); GfxSetBkMode(1); GfxSetTextColor(colorYellow); GfxTextOut("L="+L+" ",280,1); } _SECTION_END(); _SECTION_BEGIN("CNcP"); Cd1=-(O-C)/(H-L)*100; Cd=Prec((Cd1),2); ColorE=IIf(Cd>=68,colorYellow,IIf(Cd<=-68,colorRed,colorCustom12)); _SECTION_END(); _SECTION_BEGIN("Price"); BarColor = IIf((Cd>=68)OR (Cd<=-68),colorYellow,colorCustom12); Plot(C, "", BarColor, styleNoTitle| styleThick | styleCandle|styleNoLabel); Plot(C, "",styleCandle, colorBlack, styleThick); _SECTION_END(); _SECTION_BEGIN(""); r= MACD(10, 22); dd= Signal(10,22,5); Hist=r-dd; BuyHist= Cross(Hist,0); SellHist = Cross( 0, Hist ); _SECTION_BEGIN("MA(20)"); BarColor = IIf((C>MA(C,20)),colorWhite,colorRed); Plot(MA(C,20),"",BarColor,styleThick); BuyMA= Cross(C,MA(C,20)); SellMA= Cross( MA(C,20), C ); _SECTION_END(); _SECTION_BEGIN("Magnified Price"); FS=Param("Font Size",15,11,100,1); GfxSelectFont("Arial", FS, 700, True ); GfxSetBkMode(ColorRGB(255,170,188)); GfxSetTextColor( ParamColor("Color",colorYellow) ); Hor=Param("Horizontal Position",390,2,1,2); Ver=Param("Vertical Position",1,1,1,1); GfxTextOut("C="+C,Hor , Ver+55 ); YC=TimeFrameGetPrice("C",inDaily,-1); DD=Prec(C-YC,2); xx=Prec((DD/YC)*100,2); GfxSelectFont("Arial", 12, 700, True ); GfxSetBkMode( colorYellow ); GfxSetTextColor(ParamColor("Color",colorBlue) ); GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+80 ); _SECTION_END(); _SECTION_BEGIN("Nd"); Nd=((C)-(O))/(L)*10000; Filter=Close; AddColumn(Nd , "Nd",1.2,colorBrown); _SECTION_BEGIN(" Nd"); { GfxSelectFont("Arial",12, 700 ); GfxSetBkMode(1); GfxSetTextColor(colorCustom12); GfxTextOut("Nd="+WriteVal(Nd,format=1.2)+"% ",750,1); GfxSetTextColor(colorWhite); } _SECTION_END(); _SECTION_BEGIN("CNcP"); Cd1=-(O-C)/(H-L)*100; Cd=Prec((Cd1),2); Filter=Close; AddColumn(Cd , "Cd",1.2,colorOrange); _SECTION_END(); _SECTION_BEGIN(" Cd"); { GfxSelectFont("Arial",13, 700 ); GfxSetBkMode(1); GfxSetTextColor(colorGold); GfxTextOut("Cd="+WriteVal(Cd,format=1.2)+"% ",870,1); } _SECTION_END(); _SECTION_BEGIN(" ZigZagTrend "); array = Close; amount = Param("Amount", 5, 1, 50, 0.5 ); zz0 = Zig( array, amount ); zz1 = Ref( zz0, -1 ); zz2 = Ref( zz0, -2 ); tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1); pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1); PU = tr + 0.01 * abs(tr)*amount; PD = pk - 0.01 * abs(pk)*amount; ZZT = IIf( array >= PU AND zz0 > zz1, 1, IIf( array <= PD AND zz0 < zz1, -1, 0 ) ); ZZT = ValueWhen( ZZT != 0, ZZT ); Com=IIf(ZZT>0,colorBlue,IIf(ZZT<0,colorRed,colorBl ack)); _SECTION_BEGIN("Font Color"); function GfxConvertBarToPixelX(Bar) { lvb = Status("lastvisiblebar"); fvb = Status("firstvisiblebar"); pxchartleft = Status("pxchartleft"); pxchartwidth = Status("pxchartwidth"); return pxchartleft + Bar * pxchartwidth / (Lvb-fvb + 1); } procedure MultiRibbon(RibbonColor, Position, Label) { LineColor =colorWhite; Position =2* Position; x2 = Status("pxchartright"); y2 = Status("pxchartbottom"); RibbonColor =IIf(GfxConvertBarToPixelX(BarIndex()-Status("firstvisiblebarindex")) > y2/1.5 * (2/100)*10,RibbonColor, colorWhite); Plot(0, "",LineColor, styleOwnScale|styleNoLabel,0,100); Plot(Position, "",LineColor,styleOwnScale| styleNoLabel,0,100); Plot(Position, "",RibbonColor,styleArea|styleOwnScale|styleNoLabe l, 0,100); GfxSelectFont("Arial", y2/1 * (2.7/180),200); GfxDrawText(Label,8, y2 *1.006-(y2 * Position/100) , y2/1.6* (2/100)*10,y2,2+32+256); GfxSetTextColor(colorBlue); } multiribbon(COM,1, "Trend"); Buy=Cross(ZZT,0); Sell=Cross(0,ZZT); PlotShapes(IIf(Buy,shapeSmallUpTriangle,shapeNone) ,colorBlue,0,L,-15); PlotShapes(IIf(Sell,shapeSmallDownTriangle, shapeNone),colorRed,0,H,-15); _SECTION_BEGIN("Zig_Zag_"); PercentChange = 4; mystartbar = SelectedValue(BarIndex()); // FOR GRAPHING mystartbardate = LastValue(ValueWhen(mystartbar == BarIndex(), DateNum(),1)); InitialValue = LastValue(ValueWhen(mystartbardate == DateNum(), C , 1 ) ) ; ZZ = Zig(C,LastValue(PercentChange)) ; PivotLow = Ref(IIf(Ref(ROC(ZZ,1),-1) < 0 AND ROC(ZZ,1) > 0, 1,Null),1); PivotHigh = Ref(IIf(Ref(ROC(ZZ,1),-1) > 0 AND ROC(ZZ,1) < 0, 1,Null),1); PlotShapes(IIf(PivotLow, shapeDigit1, shapeNone),colorYellow, 0,L, Offset=-32); PlotShapes(IIf(PivotHigh, shapeDigit1, shapeNone),colorYellow, 0,H, Offset=32); _SECTION_BEGIN("ZigZag"); { GfxSelectFont("Arial",13, 700 ); GfxSetBkMode(1); GfxSetTextColor(colorGold); GfxTextOut(" ZigZag="+WriteVal(ZZ,format=1.2)+"",75,20); } _SECTION_END(); _SECTION_BEGIN("MACD"); ml = MACD(6, 13); dd= Signal(6,13,5); Hist=ml-dd; col_hist= IIf(Hist > BBandTop( Hist, 5, 0.5 ),colorLightBlue,IIf(Hist < BBandBot( Hist, 5, 0.5 ),colorBlue,colorRed)); pr=PeakBars(C,5)==0; ps =TroughBars(C,5)==0; PlotShapes(IIf(ps,shapeDigit2 ,Null),colorBlue,0,L,-45); PlotShapes(IIf(pr,shapeDigit2 ,Null),colorBlue,0,H,45); _SECTION_BEGIN("Fibonacci And Gann Projections"); Change = 5; GannIncrement = 0.0625; procedure PlotShapeAt( x, y, shape, shift ) { PlotShapes( IIf( BarIndex() == x, shape, 0 ), colorWhite, 0, y, shift ); } procedure PlotBlueDot( x, y ) { for( i = -2; i <= 2; i++ ) { if( i != 0 ) { yGann = ( sqrt( y ) + i * GannIncrement ) ^ 2; } } } bi = BarIndex(); sbi = SelectedValue( bi ); GraphXSpace = 2; upshift =65; if( SelectedValue( PeakBars( C, Change ) < TroughBars( C, Change ) ) ) { pt1 = PeakBars( C, Change, 1 ) == 0 ; pt2 = TroughBars( C, Change, 1 ) == 0 ; } else { pt1 = TroughBars( C, Change, 1 ) == 0 ; pt2 = PeakBars( C, Change, 1 ) == 0 ; upshift = -upshift; } bpt1 = SelectedValue( ValueWhen( pt1, bi ) ); bpt2 = SelectedValue( ValueWhen( pt2, bi ) ); bpt3 = SelectedValue( ValueWhen( pt1, bi, 2 ) ); bpt4 = SelectedValue( ValueWhen( pt2, bi, 2 ) ); bpt5 = SelectedValue( ValueWhen( pt1, bi, 3 ) ); bpt6 = SelectedValue( ValueWhen( pt2, bi, 3 ) ); PlotShapeAt( bpt1, C, shapeDigit1, upshift ); PlotShapeAt( bpt2, C, shapeDigit2, -upshift ); PlotShapeAt( bpt3, C, shapeDigit3, upshift ); PlotShapeAt( bpt4, C, shapeDigit4, -upshift ); PlotShapeAt( bpt5, C, shapeDigit5, upshift ); PlotShapeAt( bpt6, C, shapeDigit6, -upshift ); Level = SelectedValue( ValueWhen( pt1, C ) ); PlotBlueDot( round( bpt1 + 1.618 * ( bpt1 - bpt2 ) ), Level ); PlotBlueDot( round( bpt1 + 0.382 * ( bpt1 - bpt2 ) ), Level ); PlotBlueDot( round( bpt1 + 0.5 * ( bpt2 - bpt3 ) ), Level ); PlotBlueDot( round( bpt1 + 1.732 * ( bpt2 - bpt3 ) ), Level ); PlotBlueDot( round( bpt1 + 0.618 * ( bpt4 - bpt5 ) ), Level ); PlotBlueDot( round( bpt1 + 2 * ( bpt4 - bpt5 ) ), Level ); PlotBlueDot( round( bpt2 + 0.6707 * ( bpt4 - bpt2 ) ), Level ); PlotBlueDot( round( bpt2 + 2.618 * ( bpt4 - bpt2 ) ), Level ); PlotBlueDot( round( bpt2 + 1 * ( bpt6 - bpt2 ) ), Level ); PlotBlueDot( round( bpt2 + 3 * ( bpt6 - bpt2 ) ), Level ); _SECTION_END(); _SECTION_BEGIN("zzt"); para = ParamToggle("plot zz0","off,on"); cbar = Param("cbar",10,2,50,1); per = Param("per",5,1,30,1); zz0 = Zig(C,per); zz1 = Ref( zz0, -1 ); zz2 = Ref( zz0, -2 ); tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1); pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1); pu = tr + 0.01 * abs(tr)*per; pd = pk - 0.01 * abs(pk)*per; zzt = IIf(C>= pu AND zz0 > zz1, 1, IIf(C<= pd AND zz0 < zz1, -1, 0 ) ); zzt= ValueWhen( zzt != 0, zzt ); colorp2= IIf((C>O)OR(C<O),colorWhite,colorYellow); Plot(IIf(para,zz0,Null)," ",colorWhite,styleLine|styleNoTitle); pr=PeakBars(High,5)==0; ps =TroughBars(Low,5)==0; rf=ValueWhen(pr,High); sf=ValueWhen(ps,Low); rf1 = IIf(rf AND BarsSince(pr) <=cbar,rf,Null); sf1 = IIf(sf AND BarsSince(ps ) <=cbar,sf,Null); Plot(rf1,"",colorRed,styleDots | styleNoLine|styleNoLabel); Plot(sf1,"",colorBrightGreen,styleDots | styleNoLine|styleNoLabel); _SECTION_END(); numbars = SelectedValue(Cum(Status("barvisible"))); fraction= IIf(StrRight(Name(),3) == "",3.2,3.2); hts = Param ("text shift", -50,-100,100,10); PlotText("" + WriteVal(rf,fraction), SelectedValue(BarIndex()+6)-(numbars/hts),SelectedValue(rf),colorWhite,colorRed); PlotText("" + WriteVal(sf,fraction), SelectedValue(BarIndex()+6)-(numbars/hts),SelectedValue(sf),colorWhite,colorGreen); _SECTION_END(); Plot( Open, "open", 0, stylehidden| styleNoTitle ); Plot(Close, "close", 0, stylehidden| styleNoTitle ); Plot(High, "high", 0, stylehidden| styleNoTitle ); Plot(Low, "low", 0, stylehidden| styleNoTitle ); numbars = SelectedValue(Cum(Status("barvisible"))); fraction= IIf(StrRight(Name(),3) == "",3.2,3.2); hts = Param ("text shift", -50,-100,100,10); _SECTION_END(); _SECTION_BEGIN("MotheCandle"); Mothc=Ref(H,-1)>H AND Ref(L,-1)<L; y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(L,-1)))); TDL = LineArray(0, y0, (BarCount-1), y0); Plot(TDL, "", colorGold,styleDashed|styleNoLabel); y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(H,-1)))); TDH= LineArray(0, y0, (BarCount-1), y0); PlotShapes(shapeSmallCircle*(Ref(Mothc,1)), colorGold,0,H,5); PlotShapes(shapeSmallCircle*(Ref(Mothc,1)),colorGo ld,0,L,-5); Plot(TDH, "", colorCustom12,styleDashed|styleNoLabel); numbars = SelectedValue(Cum(Status("barvisible"))); fraction= IIf(StrRight(Name(),3) == "",3.2,3.2); hts = Param ("Text Shift", -50,-100,100,10); PlotText("" + WriteVal(TDH,fraction), SelectedValue(BarIndex())-(numbars/hts),SelectedValue(TDH),colorCustom12); PlotText("" + WriteVal(TDL,fraction), SelectedValue(BarIndex())-(numbars/hts),SelectedValue(TDL),colorGold); _SECTION_END(); _SECTION_BEGIN("AuthorName"); k = (GetPerformanceCounter()/100)%100; printf("GetPerformance Counter %g",k); GfxSelectFont("jokerman", 12,800); GfxSetBkMode(1); GfxSetTextColor(colorGold); GfxTextOut("MotherCandle",450,20); RequestTimedRefresh(10); _SECTION_END(); _SECTION_BEGIN("WMA 50"); slope = Param("slope",2,2,100,1); Color20= IIf(LinRegSlope(WMA(C,50),slope)<0,colorCustom13,c olorCustom13); event1= LinRegSlope(WMA(C,50),slope)<1; Plot( WMA( C,50), "",Color20,styleNoLine|styleNoLabel); _SECTION_END(); _SECTION_BEGIN("WMA 50"); { GfxSelectFont("Bernard MT Condensed",12, 800 ); GfxSetBkMode(1); GfxSetTextColor(colorCustom13); GfxTextOut("WMA50="+WMA( C,50),250,20); } _SECTION_END(); _SECTION_BEGIN("Auto trend line Trendline"); /*+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++ THIS SECTION DRAWS TD TREND LINES */ percent = 0.01 * 1; firstpointL = 2; firstpointH = 2; y0=LastValue(Trough(L,percent,firstpointL)); y1=LastValue(Trough(Ref(L,-1),percent,1)); for( i = 1; i < BarCount AND y0 >= y1; i++ ) { firstpointL++; y0=LastValue(Trough(L,percent,firstpointL)); } x0=BarCount - 1 - LastValue(TroughBars(L,percent,firstpointL)); x1=BarCount - 1 - LastValue(TroughBars(Ref(L,-1),percent,1)); LineL = LineArray( x0, y0, x1, y1, 1 ); /* Plot(C, "C", colorBlack, styleCandle); */ Plot( LineL, " Support Trend line", colorBlueGrey,4 +8 ); yt0=LastValue(Peak(H,percent,firstpointH)); yt1=LastValue(Peak(Ref(H,-1),percent,1)); for(i = 1; i < BarCount AND yt0 <= yt1; i++ ) { firstpointH++; yt0=LastValue(Peak(H,percent,firstpointH)); } xt0=BarCount - 1 - LastValue(PeakBars(H,percent,firstpointH)); xt1=BarCount - 1 - LastValue(PeakBars(Ref(H,-1),percent,1)); LineH = LineArray( xt0, yt0, xt1, yt1, 1 ); Plot( lineH, "resistance trend line", colorOrange,4 + 8 ); /*+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++*/ _SECTION_END(); Buy=Cross(C,lineh); Sell=Cross( linel,C); PlotShapes(IIf(Buy,shapeSmallUpTriangle,shapeNone) ,colorOrange,0,C,-25); PlotShapes(IIf(Sell,shapeSmallDownTriangle, shapeNone),colorBlueGrey,0,C,-25); PlotShapes(IIf(Buy,shapeHollowCircle, shapeNone),colorBlack, 0,C,0); PlotShapes(IIf(Sell,shapeHollowCircle, shapeNone),colorWhite, 0,C,0); Filter=Close; AddColumn(IIf(Sell,C,Null),"sell",1.4,colorBlack); AddColumn(IIf(Buy,C,Null),"buy",1.4,colorBlue); _SECTION_END(); _SECTION_BEGIN("Pivot_Finder"); /* ********************************** Code to automatically identify pivots ********************************** */ // -- what will be our lookback range for the hh and ll? farback=Param("How Far back to go",100,0,5000,10); nBars = Param("Number of bars", 8, 5, 40); // -- Create 0-initialized arrays the size of barcount aHPivs = H - H; aLPivs = L - L; // -- More for future use, not necessary for basic plotting aHPivHighs = H - H; aLPivLows = L - L; aHPivIdxs = H - H; aLPivIdxs = L - L; nHPivs = 0; nLPivs = 0; lastHPIdx = 0; lastLPIdx = 0; lastHPH = 0; lastLPL = 0; curPivBarIdx = 0; // -- looking back from the current bar, how many bars // back were the hhv and llv values of the previous // n bars, etc.? aHHVBars = HHVBars(H, nBars); aLLVBars = LLVBars(L, nBars); aHHV = HHV(H, nBars); aLLV = LLV(L, nBars); // -- Would like to set this up so pivots are calculated back from // last visible bar to make it easy to "go back" and see the pivots // this code would find. However, the first instance of // _Trace output will show a value of 0 aVisBars = Status("barvisible"); nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0))); _TRACE("Last visible bar: " + nLastVisBar); // -- Initialize value of curTrend curBar = (BarCount-1); curTrend = ""; if (aLLVBars[curBar] < aHHVBars[curBar]) { curTrend = "D"; } else { curTrend = "U"; } // -- Loop through bars. Search for // entirely array-based approach // in future version for (i=0; i<farback; i++) { curBar = (BarCount - 1) - i; // -- Have we identified a pivot? If trend is down... if (aLLVBars[curBar] < aHHVBars[curBar]) { // ... and had been up, this is a trend change if (curTrend == "U") { curTrend = "D"; // -- Capture pivot information curPivBarIdx = curBar - aLLVBars[curBar]; aLPivs[curPivBarIdx] = 1; aLPivLows[nLPivs] = L[curPivBarIdx]; aLPivIdxs[nLPivs] = curPivBarIdx; nLPivs++; } // -- or current trend is up } else { if (curTrend == "D") { curTrend = "U"; curPivBarIdx = curBar - aHHVBars[curBar]; aHPivs[curPivBarIdx] = 1; aHPivHighs[nHPivs] = H[curPivBarIdx]; aHPivIdxs[nHPivs] = curPivBarIdx; nHPivs++; } // -- If curTrend is up...else... } // -- loop through bars } // -- Basic attempt to add a pivot this logic may have missed // -- OK, now I want to look at last two pivots. If the most // recent low pivot is after the last high, I could // still have a high pivot that I didn't catch // -- Start at last bar curBar = (BarCount-1); candIdx = 0; candPrc = 0; lastLPIdx = aLPivIdxs[0]; lastLPL = aLPivLows[0]; lastHPIdx = aHPivIdxs[0]; lastHPH = aHPivHighs[0]; if (lastLPIdx > lastHPIdx) { // -- Bar and price info for candidate pivot candIdx = curBar - aHHVBars[curBar]; candPrc = aHHV[curBar]; if ( lastHPH < candPrc AND candIdx > lastLPIdx AND candIdx < curBar) { // -- OK, we'll add this as a pivot... aHPivs[candIdx] = 1; // ...and then rearrange elements in the // pivot information arrays for (j=0; j<nHPivs; j++) { aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs- (j+1)]; aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)]; } aHPivHighs[0] = candPrc ; aHPivIdxs[0] = candIdx; nHPivs++; } } else { // -- Bar and price info for candidate pivot candIdx = curBar - aLLVBars[curBar]; candPrc = aLLV[curBar]; if ( lastLPL > candPrc AND candIdx > lastHPIdx AND candIdx < curBar) { // -- OK, we'll add this as a pivot... aLPivs[candIdx] = 1; // ...and then rearrange elements in the // pivot information arrays for (j=0; j<nLPivs; j++) { aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)]; aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)]; } aLPivLows[0] = candPrc; aLPivIdxs[0] = candIdx; nLPivs++; } } // -- Dump inventory of high pivots for debugging for (k=0; k<nHPivs; k++) { _TRACE("High pivot no. " + k + " at barindex: " + aHPivIdxs[k] + ", " + WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k], DateTime(), 1), formatDateTime) + ", " + aHPivHighs[k]); } ////////////////////////////////////////////////////////////////////////////// // -- OK, let's plot the pivots using arrows PlotShapes(IIf(aHPivs==1, shapeSmallDownTriangle, shapeNone), colorRed, 0, High, Offset=-14); PlotShapes(IIf(aLPivs==1, shapeSmallUpTriangle , shapeNone), colorBrightGreen, 0, Low, Offset=-13); ////////////////////////////////////////////////////////////////////////////// /* ********************************** Code to automatically identify pivots ********************************** */ // -- what will be our lookback range for the hh and ll? farback=Param("How Far back to go",500,12,30,1); nBars = Param("Number of bars", 8, 1, 30, 1); // -- Create 0-initialized arrays the size of barcount aHPivs = H - H; aLPivs = L - L; // -- More for future use, not necessary for basic plotting aHPivHighs = H - H; aLPivLows = L - L; aHPivIdxs = H - H; aLPivIdxs = L - L; nHPivs = 0; nLPivs = 0; lastHPIdx = 0; lastLPIdx = 0; lastHPH = 0; lastLPL = 0; curPivBarIdx = 0; // -- looking back from the current bar, how many bars // back were the hhv and llv values of the previous // n bars, etc.? aHHVBars = HHVBars(H, nBars); aLLVBars = LLVBars(L, nBars); aHHV = HHV(H, nBars); aLLV = LLV(L, nBars); // -- Would like to set this up so pivots are calculated back from // last visible bar to make it easy to "go back" and see the pivots // this code would find. However, the first instance of // _Trace output will show a value of 0 aVisBars = Status("barvisible"); nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0))); _TRACE("Last visible bar: " + nLastVisBar); // -- Initialize value of curTrend curBar = (BarCount-1); curTrend = ""; if (aLLVBars[curBar] < aHHVBars[curBar]) { curTrend = "D"; } else { curTrend = "U"; } // -- Loop through bars. Search for // entirely array-based approach // in future version for (i=0; i<farback; i++) { curBar = (BarCount - 1) - i; // -- Have we identified a pivot? If trend is down... if (aLLVBars[curBar] < aHHVBars[curBar]) { // ... and had been up, this is a trend change if (curTrend == "U") { curTrend = "D"; // -- Capture pivot information curPivBarIdx = curBar - aLLVBars[curBar]; aLPivs[curPivBarIdx] = 1; aLPivLows[nLPivs] = L[curPivBarIdx]; aLPivIdxs[nLPivs] = curPivBarIdx; nLPivs++; } // -- or current trend is up } else { if (curTrend == "D") { curTrend = "U"; curPivBarIdx = curBar - aHHVBars[curBar]; aHPivs[curPivBarIdx] = 1; aHPivHighs[nHPivs] = H[curPivBarIdx]; aHPivIdxs[nHPivs] = curPivBarIdx; nHPivs++; } // -- If curTrend is up...else... } // -- loop through bars } // -- Basic attempt to add a pivot this logic may have missed // -- OK, now I want to look at last two pivots. If the most // recent low pivot is after the last high, I could // still have a high pivot that I didn't catch // -- Start at last bar curBar = (BarCount-1); candIdx = 0; candPrc = 0; lastLPIdx = aLPivIdxs[0]; lastLPL = aLPivLows[0]; lastHPIdx = aHPivIdxs[0]; lastHPH = aHPivHighs[0]; if (lastLPIdx > lastHPIdx) { // -- Bar and price info for candidate pivot candIdx = curBar - aHHVBars[curBar]; candPrc = aHHV[curBar]; if ( lastHPH < candPrc AND candIdx > lastLPIdx AND candIdx < curBar) { // -- OK, we'll add this as a pivot... aHPivs[candIdx] = 1; // ...and then rearrange elements in the // pivot information arrays for (j=0; j<nHPivs; j++) { aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs- (j+1)]; aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)]; } aHPivHighs[0] = candPrc ; aHPivIdxs[0] = candIdx; nHPivs++; } } else { // -- Bar and price info for candidate pivot candIdx = curBar - aLLVBars[curBar]; candPrc = aLLV[curBar]; if ( lastLPL > candPrc AND candIdx > lastHPIdx AND candIdx < curBar) { // -- OK, we'll add this as a pivot... aLPivs[candIdx] = 1; // ...and then rearrange elements in the // pivot information arrays for (j=0; j<nLPivs; j++) { aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)]; aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)]; } aLPivLows[0] = candPrc; aLPivIdxs[0] = candIdx; nLPivs++; } } // -- Dump inventory of high pivots for debugging /* for (k=0; k<nHPivs; k++) { _TRACE("High pivot no. " + k + " at barindex: " + aHPivIdxs[k] + ", " + WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k], DateTime(), 1), formatDateTime) + ", " + aHPivHighs[k]); } */ // -- OK, let's plot the pivots using arrows PlotShapes(IIf(aHPivs==1, shapeHollowSmallDownTriangle, shapeNone), colorOrange, 0, High, Offset=-25); PlotShapes(IIf(aLPivs==1, shapeHollowSmallUpTriangle , shapeNone), colorWhite, 0, Low, Offset=-23); Sell = aHPivs == 1 ; Buy = aLPivs == 1 ; Filter=Buy OR Sell; Sell=ExRem(Sell,Buy); Buy=ExRem(Buy,Sell); _SECTION_END(); _SECTION_BEGIN("td fractl line"); strength = Param("strength",1,1,15,1); pr=PeakBars(RSI(14),strength)==0; _SECTION_END(); _SECTION_BEGIN("td fractl line"); ps =TroughBars(RSI(14),strength)==0; _SECTION_END(); _SECTION_BEGIN("price risistance"); rt=SelectedValue(ValueWhen(pr,H)); st=SelectedValue(ValueWhen(ps,L)); _SECTION_BEGIN("td fractl line"); pr=PeakBars(RSI(14),strength)==0; pivothigh = Ref(pr,-1)<pr AND pr>Ref(pr,1); y0=SelectedValue(ValueWhen(pivothigh,H,2)); y1=SelectedValue(ValueWhen(pivothigh,H,1)); x0=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,2)); x1=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,1)); linea=LineArray(x0,y0,x1,y1,1); _SECTION_END(); _SECTION_BEGIN("td fractl line"); ps =TroughBars(RSI(14),strength)==0; pivotlow = Ref(ps,-1)<ps AND ps>Ref(ps,1); yt0=SelectedValue(ValueWhen(pivotlow,L,2)); yt1=SelectedValue(ValueWhen(pivotlow,L,1)); xt0=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,2)); xt1=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,1)); lineb=LineArray(xt0,yt0,xt1,yt1,1); _SECTION_END(); _SECTION_BEGIN("ema1"); p = ParamField("price field",-1); _SECTION_END(); pi = atan(1.00)* 4 ; periods = 30; highhigh = HHV(H, periods); lowlow = LLV(L, periods); range = 25 / (highhigh - lowlow) * lowlow; ma1= EMA(C,200); x1_ma = 0; x2_ma= 1; y1_ma= 0; y2_ma= (Ref(ma1, -1) - ma1) / Avg * range; c_ma= sqrt((x2_ma- x1_ma)*(x2_ma- x1_ma) + (y2_ma- y1_ma)*(y2_ma- y1_ma)); angle_ma= round(180 * acos((x2_ma - x1_ma)/c_ma) / pi); angle_ma= IIf(y2_ma> 3, -angle_ma, angle_ma); col=IIf(angle_ma>3,colorGreen,IIf(angle_ma<(-3),colorRed,colorCustom12)); Plot(EMA( p,200), _DEFAULT_NAME(), col, styleDots ); buy1=Cross(C,linea) AND RSI(14)>60 AND angle_ma>=1; buy2=Cross(C,rt)AND RSI(14)>60 AND angle_ma>=1; Buy=buy1 OR buy2; sell1=Cross(lineb,C)AND RSI(14)<40 AND angle_ma<=(-1); sell2=Cross(rt,C)AND RSI(14)<40 AND angle_ma<=(-1); Sell=sell1 OR sell2; PlotShapes(IIf(Buy,shapeSmallUpTriangle,shapeNone) ,colorBlue,0,L,-20); PlotShapes(IIf(Sell,shapeSmallDownTriangle, shapeNone),colorYellow,0,H,-20); if (SelectedValue(Buy)==1) Say("super move"); if (SelectedValue(Sell)==1) Say("weake move"); _SECTION_BEGIN("exploration"); Filter=Close; var = WriteIf(Buy,"buy",WriteIf(Sell,"sell","")); AddTextColumn( var , "buy/sell", 1.2 , colorWhite, IIf( Buy, colorBlue,IIf(Sell,colorRed,colorWhite) )); AddColumn(angle_ma,"angle",1.4,colorBlue); _SECTION_END(); _SECTION_BEGIN("t trend"); { GfxSelectFont("Arial",12, 800 ); GfxSetBkMode(1); GfxSetTextColor(colorWhite); GfxTextOut("RSI="+WriteVal(RSI(14),format=1.2)+" ",970,1); } _SECTION_END(); _SECTION_BEGIN("t trend"); { GfxSelectFont("Arial",13, 800 ); GfxSetBkMode(1); GfxSetTextColor(colorCustom11); GfxTextOut("angle="+angle_ma+"% ",600,20); } _SECTION_END(); _SECTION_BEGIN("MACD"); r1 = Param("Fast avg", 14, 2, 200, 1); r2 = Param("Slow avg", 26, 2, 200, 1); r3 = Param("Signal avg", 9, 2, 200, 1); m1 = MACD(r1,r2); s1 = Signal(r1,r2,r3); _SECTION_END(); //Hook Bullish Z= Cross(C, EMA(C,5))AND RSI(9)>30; //Bearish Bullish t= Cross(EMA(C,5), C)AND RSI(9)<70; // Histogram pt = m1-s1; Tp = Ref(pT,-1) == HHV(pT,3); Vl = Ref(pT,-1) == LLV(pT,3); //ADX related calculations plus = EMA(PDI(14),3)>Ref(EMA(PDI(14),3),-5); ap = EMA(ADX(14),3)>Ref(EMA(ADX(14),3),-5); Minus = EMA(MDI(14),3)>Ref(EMA(MDI(14),3),-5); //Power Dips - Bullish PDIp = ADX(14)>MDI(14) AND PDI(14)>MDI(14) AND ap AND Vl AND m1>s1 AND plus; //Power Dips - Bearish PDIm = ADX(14)>PDI(14) AND MDI(14)>PDI(14) AND ap AND Tp AND m1<s1 AND Minus; //Bullish Crossed up above zero j1 = Cross(m1,s1)AND m1>0; // Bullish crossover up below zero j2 = Cross(m1,s1)AND m1<0 ; //Bearish Crossed down below Zero j3 = Cross(s1,m1) AND m1>0; // Bearish crossover down above zero j4 = Cross(s1,m1)AND m1<0; _SECTION_BEGIN("V"); TimeFrameSet(inDaily); D=V; TimeFrameRestore(); _SECTION_END(); //Volume Change Volma=MA(V,15); Volchange=(((V-Volma)/Volma)*100); GraphXSpace=Param("GraphXSpace",10,0,100,1); dec = (Param("Decimals",2,0,7,1)/10)+1; Title = EncodeColor(55)+ Title = Name() + " " + EncodeColor(32) + Date() + " "+ EncodeColor(5) + "{{INTERVAL}} " + EncodeColor(55)+ " Open = "+ EncodeColor(52)+ WriteVal(O,dec) + EncodeColor(55)+ " High = "+ EncodeColor(5) + WriteVal(H,dec) + EncodeColor(55)+ " Low = "+ EncodeColor(32)+ WriteVal(L,dec) + EncodeColor(55)+ " Close = "+ EncodeColor(7)+ WriteVal(C,dec)+ "\n\n\n"+EncodeColor(colorBrightGreen)+ WriteIf (PDIP, " @Bullish Power Dip","")+EncodeColor(colorRed)+ WriteIf (PDIm, " @Bearish Power Dip","")+EncodeColor(colorBrightGreen)+ WriteIf (z, " @Bullish hook","")+EncodeColor(colorRed)+ WriteIf (t, " @Bearish hook","")+EncodeColor(colorBrightGreen)+ WriteIf (Vl AND m1>s1, "@Histogram peak","")+EncodeColor(colorRed)+ WriteIf (Tp AND m1<s1, " @Histogram troughs","")+EncodeColor(colorBrightGreen)+ WriteIf (j1, " @Bullish Crossed up above zero","")+EncodeColor(colorBrightGreen)+ WriteIf (j2, " @Bullish crossover up below zero","")+EncodeColor(colorRed)+ WriteIf (j4, "@Bearish Crossed down below Zero","")+EncodeColor(colorRed)+ WriteIf (j3, " @Bearish crossover down above zero","")+"\n"+EncodeColor(colorBlue)+ WriteIf (Cross(ZZT,0), "@ BUY ZZT","")+EncodeColor(colorCustom12)+ WriteIf (Cross(0,ZZT), "@ SELL ZZT","")+EncodeColor(colorYellow)+ WriteIf (PivotLow, "@ BUY ZIG ZAG","")+EncodeColor(colorYellow)+ WriteIf (PivotHigh, "@ SELL ZIG ZAG","")+EncodeColor(colorYellow)+ WriteIf (ps, "@ BUY MACD","")+EncodeColor(colorYellow)+ WriteIf (pr, "@ SELL MACD","")+EncodeColor(colorGold)+ WriteIf (aLPivs==1, "@ BUY Pivot_Finder","")+"\n"+EncodeColor(colorGold)+ WriteIf (aHPivs==1, "@ SELL Pivot_Finder","")+EncodeColor(colorOrange)+ WriteIf (Cross(C,lineh), "@ TREND BROKEN UP","")+EncodeColor(colorBlueGrey)+ WriteIf (Cross( linel,C), "@ TREND BROKEN DOWN ","")+EncodeColor(colorCustom12)+ WriteIf (Cross(C,TDH), " @ BUY MOTHER CANDLE","")+"\n"+EncodeColor(colorGold)+ WriteIf (Cross(TDL,C), " @ SELL MOTHER CANDLE","")+EncodeColor(colorGrey50)+ WriteIf (BuyHist, " @ BUY Hist","")+"\n"+EncodeColor(colorRed)+ WriteIf (sellHist, " @ SELL Hist","")+EncodeColor(colorBrightGreen)+ WriteIf (BuyMA, " @ BREAK UP MA(20)","")+EncodeColor(colorBrightGreen)+ WriteIf (sellMA, " @BREAK DOWN MA(20)","") + EncodeColor( colorRed)+ WriteIf(DownChannel==1,"& Downward Sloping Channel","")+EncodeColor( colorBrightGreen)+ WriteIf(UpChannel==1," &Upward Sloping Channel","")+EncodeColor( colorWhite)+ WriteIf(wedge==1," &Wedge","")+ WriteIf(DecendingTriangle==1," &Decending Triangle","")+ WriteIf(AscendingTriangle==1,"&Ascending Triangle","")+ WriteIf(broadeningWedge==1," &Broadening Wedge","")+EncodeColor( colorBrightGreen ) + WriteIf(bullishbreakout==1,"@Bullish Breakout","")+EncodeColor( colorWhite ) + WriteIf(bearishbreakout==1,"@Bearish Breakout","")+EncodeColor( colorCustom12 ) +"\n"+EncodeColor(colorWhite)+WriteIf(V > Volma," Volume's above MA(15) with ("+WriteVal(Volchange,format=1.2)+")%","" ) +"\n"+EncodeColor(colorWhite)+WriteIf(V < Volma, " Volume's below MA(15)with("+WriteVal(Volchange,format=1.2)+")% ","" ); _SECTION_BEGIN("Target&Trail SL"); SetChartOptions(0, chartShowDates | chartWrapTitle); Type = ParamList("Average Type", "Wilders"); P = Param("Averaging Period", 20, 3, 100,1); Q = Param("%Change", 1, 0.1, 10, 0.1); BP = Param("BB Period", 20, 3, 100); BW = Param("BB Width", 2, 0.5, 10, 0.5); BBOption = ParamToggle("Plot BB", "No I Yes"); A=Param( "Swing", 20, 1, 100); SL = Max(LLV(L, 5), Trough(L, Q, 1)); Tgt = 2 * H - SL; MeanPrice = Prec((O + C) / 2, 2); Part = 100 * (H - A) / (H - L); BBTop = BBandTop(C, BP, BW); BBBot = BBandBot(C, BP, BW); res=HHV(H,A); sup=LLV(L,A); avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0)); avn=ValueWhen(avd!=0,avd,1); tsl=IIf(avn==1,sup,res); // line code Plot(tsl, _DEFAULT_NAME(), ParamColor( "ColorD", colorRed ), styleStaircase|styleNoLabel|styleNoLine); // arrows code Buy=Cross(C,Ref(res,-1)); Sell=Cross(Ref(sup,-1),C); Buy = ExRem(Buy, Sell); Sell = ExRem(Sell, Buy); Bought = Flip(Buy, Sell); Sold = Flip(Sell, Buy); NextTgt = ValueWhen(Buy, Tgt, 1); for(i = 1; i < BarCount; i++) { if(Bought[i] AND NOT Buy[i]) { SL[i] = Max(SL[i], SL[i - 1]); if(C[i - 1] >= 0.9999 * NextTgt[i - 1]) NextTgt[i] = Tgt[i - 1]; NextTgt[i] = Max(NextTgt[i], NextTgt[i - 1]); } } BuyDate = ValueWhen(Buy, Ref(DateTime(), 1), 1); BuyPrice = ValueWhen(Buy, Ref(MeanPrice, 1), 1); SellPrice = ValueWhen(Sell, Ref(MeanPrice, 1), 1); TgtReached = IIf(Bought AND NOT Buy AND C >= 0.9999 * NextTgt, True, False); SLHit = IIf(Bought AND NOT Buy AND C < SL, True, False); SLHit = ExRem(SLHit, Buy); Plot(IIf(Bought, NextTgt, Null), "Target", colorRed,styleNoLine|styleNoTitle|styleNoLabel); Plot(SL, "Trail SL", colorGrey40, styleNoLine|styleNoTitle|styleNoLabel); _SECTION_BEGIN(" "); { GfxSelectFont("Arial",13, 700 ); GfxSetBkMode(1); GfxSetTextColor(colorDarkYellow); GfxTextOut("TR="+WriteVal(NextTgt,format=1.2)+"",7 40,20); GfxSetTextColor(colorBlue); GfxTextOut("Trail="+WriteVal(SL,format=1.2)+"",850 ,20); GfxSetTextColor(colorRed); GfxTextOut(" SL="+WriteVal(tsl,format=1.2)+"",970,20); } _SECTION_END(); _SECTION_BEGIN(" Bullish sign & Bearish sign "); SetChartOptions(0,chartShowArrows|chartShowDates); rg=(H-L); arg=Wilders(rg,30); Vl=V<Ref(V,-1) AND V<Ref(V,-2); mp=(H+L)/2; _SECTION_BEGIN("VSA"); eftup=H>Ref(H,-1) AND L>Ref(L,-1) AND C>Ref(C,-1) AND C>=((H-L)*0.7+L) AND rg>arg AND V>Ref(V,-1); eftdn=H<Ref(H,-1) AND L<Ref(L,-1) AND C<Ref(C,-1) AND C<=((H-L)*0.25+L) AND rg>arg AND V>Ref(V,-1); _SECTION_END(); PlotShapes(shapeSmallCircle*eftup, colorDarkTeal, 0, mp, 0 ); PlotShapes(shapeSmallCircle*eftdn, colorBlack, 0, mp, 0 ); _SECTION_BEGIN("BB"); bb2top = BBandTop(Close,20,2.25); bb1top = BBandTop(Close,20,1); bb2bot = BBandBot(Close,20,2.25); bb1bot = BBandBot(Close,20,1); Plot (bb1top,"",IIf(bb1top > Ref(bb1top,-1) AND bb1bot < Ref(bb1bot,-1),colorYellow,colorYellow),32); Plot (bb1bot,"",IIf(bb1top > Ref(bb1top,-1) AND bb1bot < Ref(bb1bot,-1),colorYellow,colorYellow),32); Plot (bb2top,"",IIf(bb2top > Ref(bb2top,-1) AND bb2bot < Ref(bb2bot,-1),colorLightGrey,colorLightGrey),32); Plot (bb2bot,"",IIf(bb2top > Ref(bb2top,-1) AND bb2bot < Ref(bb2bot,-1),colorLightGrey,colorLightGrey),32); PlotOHLC(bb2top,bb2top,bb1top,bb1top,"",ColorRGB(5 6,63,118),styleCloud|styleNoLabel); PlotOHLC(bb1bot,bb1bot,bb2bot,bb1bot,"",ColorRGB(5 6,63,118),styleCloud|styleNoLabel); _SECTION_END(); _SECTION_BEGIN("EMA Time Frame"); r= RSI(14); pR=PeakBars(RSI(14),1)==0; pivothigh = Ref(pR,-1)<pR AND pR>Ref(pR,1); y0=SelectedValue(ValueWhen(pivothigh,RSI(14),2)); y1=SelectedValue(ValueWhen(pivothigh,RSI(14),1)); x0=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,2)); x1=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,1)); LineA=LineArray(x0,y0,x1,y1,1); pS =TroughBars(RSI(14),1)==0; pivotlow = Ref(pS,-1)<pS AND pS>Ref(pS,1); yt0=SelectedValue(ValueWhen(pivotlow,RSI(14),2)); yt1=SelectedValue(ValueWhen(pivotlow,RSI(14),1)); xt0=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,2)); xt1=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,1)); LineB=LineArray(xt0,yt0,xt1,yt1,1); _SECTION_BEGIN("DIV"); u00=LastValue(Peak(H,1,2)); u11=LastValue(Peak(H,1,1)); a00=BarCount - 1 - LastValue(PeakBars(H,1,2)); price_start1=Close[a00]; a11=BarCount - 1 - LastValue(PeakBars(H,1,1)); price_end1=Close[a11]; Line = LineArray(a00,u00,a11,u11, 0 ); LastPointSell = LineArray(a11-1,u11-1,a11,u11,0); GG=u11<u00 AND price_end1>price_start1; PlotShapes(shapeSmallCircle*GG ,colorDarkRed,0,Line,-2); _SECTION_END(); _SECTION_BEGIN("DIV"); u0=LastValue(Trough(L,1,2)); u1=LastValue(Trough(L,1,1)); a0=BarCount - 1 - LastValue(TroughBars(L,1,2)); price_start=Close[a0]; a1=BarCount - 1 - LastValue(TroughBars(L,1,1)); price_end=Close[a1]; Line = LineArray(a0,u0,a1,u1, 0 ); TT=u1>u0 AND price_end<price_start; LastPointBuy = LineArray(a1-1,u1-1,a1,u1,0); PlotShapes(shapeSmallCircle*TT,colorCustom11,0,Lin e,-2); _SECTION_END(); SetChartBkColor( ParamColor("background",colorDarkTeal));