CCI Panel Multiple OB OS Zone |
//www.aflcode.com _SECTION_BEGIN("CCI Panel for Amibroker"); TTMperiod = Param("TTM period",6,2,20,1); Low_ma = EMA(L, TTMperiod); High_ma = EMA(H, TTMperiod); Low_third = (High_ma - Low_ma) / 3 + Low_ma; High_third = 2 * (High_ma - Low_ma) / 3 + Low_ma; tempnum = Now( 4 ) - TimeNum(); TimeRem = Interval() - ((int(tempnum[BarCount - 1] / 100) * 60) + (tempnum[BarCount - 1] - int(tempnum[BarCount - 1] / 100) * 100)); if (TimeRem[BarCount - 1] < 0) TimeRem = 0; MinuteVar = int(TimeRem / 60); SecondsVar = int(frac(TimeRem / 60) * 60); if (TimeRem[BarCount - 1] > 60) { TitleTimeRem = EncodeColor(colorWhite) + MinuteVar + ":" + WriteIf(SecondsVar > 9, "", "0") + SecondsVar; } else if (TimeRem[BarCount - 1] > 20) { TitleTimeRem = EncodeColor(colorYellow) + MinuteVar + ":" + WriteIf(SecondsVar > 9, "", "0") + SecondsVar; } else { TitleTimeRem = EncodeColor(colorRed) + MinuteVar + ":" + WriteIf(SecondsVar > 9, "", "0") + SecondsVar; } // Background color SetChartBkColor(ParamColor("Panel color ",colorPaleBlue)); // CCI colors zcolor= ParamColor("WCCI color",colorBlack); z6color= ParamColor("TCCI color",colorYellow); // CCI periods zperiod=Param("WCCI period",14,0,100); z = CCI(zperiod); z6period=Param("TCCI period",6,0,1000); z6 = CCI(z6period); // Tic/PIP value TicMult= Param("Tic multiplier(ER2=10,YM=1,ES=4,FOREX=1)",1,0,1000000); TicDiv= Param("Tic or PIP value(ER2=0.1,YM=1,FOREX=1)",1,0,1000000); // Rangebar interval rbint= Param("Rangebar interval:(YM=25.0,AB=1.5,NQ=3.75,ES=3.0)",1.0,0.25,1000000); // Rangebar counter rbcounter= round(((rbint-(H-L))) * ticmult); rbcounterpercent= round((rbcounter/(rbint * ticmult))*100); // Timer/counter title timercode= Param("Timer:(minutes=1,rangebar=2)",1,1,2); timetitle= WriteIf(timercode==1,TitleTimeRem, EncodeColor(colorWhite) + "Countdown " + rbcounter + " (" + rbcounterpercent + "%)"); // Spread spread= Param("Spread (included in stop)",0,0,1000000); // Stop value stopval= Param("Stop above/below entry bar",2,0,1000000); // Plot grids PlotTheGrids = ParamToggle("Plot grids","No|Yes",0); if (PlotTheGrids ==1) { PlotGrid(0); PlotGrid(-100); PlotGrid(100); PlotGrid(-200); PlotGrid(200); } // Angle variables PI = atan(1.00) * 4; periods = 30; HighHigh = HHV(H, periods); LowLow = LLV(L, periods); range = 25 / (HighHigh - LowLow) * LowLow; // EMA34 Angle EMA34 = EMA(C,34); x1_EMA34 = 0; x2_EMA34 = 1; y1_EMA34 = 0; y2_EMA34 = (Ref(EMA34, -1) - EMA34) / Avg * range; c_EMA34 = sqrt((x2_EMA34 - x1_EMA34)*(x2_EMA34 - x1_EMA34) + (y2_EMA34 - y1_EMA34)*(y2_EMA34 - y1_EMA34)); angle_EMA34 = round(180 * acos((x2_EMA34 - x1_EMA34)/c_EMA34) / PI); angle_EMA34 = IIf(y2_EMA34 > 0, - angle_EMA34, angle_EMA34); // LSMA25 Angle LSMA25 = LinearReg(C, 25 ); x1_LSMA25 = 0; x2_LSMA25 = 1; y1_LSMA25 = 0; y2_LSMA25 = (Ref(LSMA25, -1) - LSMA25) / Avg * range; c_LSMA25 = sqrt((x2_LSMA25 - x1_LSMA25)*(x2_LSMA25 - x1_LSMA25) + (y2_LSMA25 - y1_LSMA25)*(y2_LSMA25 - y1_LSMA25)); angle_LSMA25 = round(180 * acos((x2_LSMA25 - x1_LSMA25)/c_LSMA25) / PI); angle_LSMA25 = IIf(y2_LSMA25 > 0, - angle_LSMA25, angle_LSMA25); // Color the bars for Woodies Trend Following function Consecutive( array ) { return BarsSince( NOT( array ) ); } function Occurrences( array , period ) { return Sum( array, period ); } array = z; HighBars = Consecutive( array > 0 ); LowBars = Consecutive( array < 0 ); UpCondition = BarsSince( HighBars >= 6 AND Occurrences( array > 100 , 5 ) > 0 ); DnCondition = BarsSince( LowBars >= 6 AND Occurrences( array < -100 , 5 ) > 0 ); UpTrend = ( array > 0 ) AND ( UpCondition < DnCondition ); DnTrend = ( array < 0 ) AND ( UpCondition > DnCondition ); TrTrend = ( HighBars >= 5 AND NOT UpTrend ) OR ( LowBars >= 5 AND NOT DnTrend ); Color = IIf( UpTrend, colorBlue, IIf( DnTrend, colorRed, IIf( TrTrend, colorYellow, colorGrey40 ) ) ); // CCI Line //Plot(round(z),"WCCI", zcolor, styleLine | styleThick); // Turbo CCI d=0.03; z6t=z6+HHV(z6,100)*d; z6b=z6-HHV(z6,100)*d; Plot(round(z6),"TCCI", z6color, styleThick); PlotOHLC(z6t,z6t,z6b,z6b,"",z6color,styleCloud,styleNoLabel); d=0.03; zt=z+HHV(z,100)*d; zb=z-HHV(z,100)*d; PlotOHLC(zt,zt,zb,zb,"",colorBlack,styleCloud,styleNoLabel); Z42=CCI(42); Plot(Z42,"", colorCustom12, styleLine | styleThick); // CCI Histogram Plot( array, "", colorDefault, styleLine | styleThick | styleNoLabel); Plot( array, "", Color, styleHistogram | styleThick| styleNoLabel); // Zero line 25lsma Plot(0,"", IIf(C > LSMA25,colorBrightGreen,IIf(C < LSMA25,colorRed,colorTeal)), styleLine | styleThick | styleNoLabel); // Plot the Mock CZI on the 100s ColorANGLE_EMA = IIf(angle_EMA34 >=5,colorTurquoise, IIf(angle_EMA34 <5 AND angle_EMA34 >=3.57,colorDarkGreen, IIf(angle_EMA34 <3.57 AND angle_EMA34 >=2.14,colorPaleGreen, IIf(angle_EMA34 <2.14 AND angle_EMA34 >=.71,colorLime, IIf(angle_EMA34 <=-1*5,colorDarkRed, IIf(angle_EMA34 >-1*5 AND angle_EMA34 <=-1*3.57,colorRed, IIf(angle_EMA34 >-1*3.57 AND angle_EMA34 <=-1*2.14,colorOrange, IIf(angle_EMA34 >-1*2.14 AND angle_EMA34 <=-1*.71,colorLightOrange,colorYellow)))))))); Plot(100,"", ColorANGLE_EMA , styleLine | styleThick | styleNoLabel); Plot(-100,"", ColorANGLE_EMA , styleLine | styleThick | styleNoLabel); // Plot the Mock Sidewinder on the 200s SW = IIf((abs(angle_EMA34) >= 15) AND (abs(angle_EMA34 + angle_LSMA25) >= 50), IIf(angle_LSMA25 > 0, 2, -2), IIf((abs(angle_EMA34) >= 0) AND (((angle_EMA34 >= 0) AND (angle_LSMA25 >= 0)) OR ((angle_EMA34 <= 0) AND (angle_LSMA25 <= 0))) AND (abs(angle_EMA34 + angle_LSMA25) >= 5), IIf(angle_LSMA25 > 0, 1, -1), 0)); ColorSW = IIf(abs(SW) == 2, colorBrightGreen, IIf(abs(SW) == 1, colorYellow, colorRed)); Plot(200,"", ColorSW, styleLine | styleThick | styleNoLabel); Plot(-200,"", ColorSW, styleLine | styleThick | styleNoLabel); // CCI Points CCipointmove= z-Ref(z,-1); CCIpointmovetitle= WriteIf(abs(CCipointmove)<15,EncodeColor(colorRed) + "\n" + "DIFF " + abs(round(CCipointmove)),WriteIf(abs(CCipointmove)>=15 AND abs(CCipointmove)<20,EncodeColor(colorYellow) + "\n" + "DIFF " + abs(round(CCipointmove)),WriteIf(abs(CCIpointmove)>=20,EncodeColor(colorBrightGreen) + "\n" + "DIFF " + abs(round(CCipointmove)),""))); // Price Panel Lastpricetitlehi= WriteIf(H>Ref(H,-1),EncodeColor(colorBrightGreen) + Ref(H,-1) + " " + H , EncodeColor(colorWhite)+ Ref(H,-1) + " " + H); Lastpricetitlelo= WriteIf(L<Ref(L,-1),EncodeColor(colorRed) + Ref(L,-1) + " " + L , EncodeColor(colorWhite) + Ref(L,-1) + " " + L); Closecolor=WriteIf(C==H AND H>Ref(H,-1),EncodeColor(colorBrightGreen),WriteIf(C==L AND L<Ref(L,-1),EncodeColor(colorRed),EncodeColor(colorWhite))); // Stop in Longbar= L+rbint; Shortbar= H-rbint; sstoptitle=WriteIf(timercode==2, EncodeColor(colorBlue) + "\n" + "Stop In Long " + Longbar + EncodeColor(colorRed) + "\n" + "Stop In Short " + Shortbar + "\n",""); // Stop out stopCode=ParamToggle("Display stop-out ","No|Yes",0); StopLong1= C -(L - (stopval*ticdiv) - (spread*ticdiv)); stoplong1c=C-stoplong1; stoplong= round(StopLong1/ticdiv); StopShort1= (H + (stopval*ticdiv) + (spread*ticdiv)) - C; stopshortc= C+StopShort1; StopShort= round(StopShort1/ticdiv); stoptitle= WriteIf(stopcode==1,EncodeColor(colorBlue) + "\n" + "Stop Out Long " + stoplong1c + " " + stoplong + "\n" + EncodeColor(colorRed) + "Stop Out Short " + stopshortc + " " + stopshort + "\n",""); // Title Title = "\n" + "" + EncodeColor(colorWhite) + Date() + "\n" + "\n" + timetitle + "\n" + "\n" + Lastpricetitlehi + "\n" + Closecolor + C + "\n" + Lastpricetitlelo + "\n" + CCIpointmovetitle + "\n" + sstoptitle + stoptitle; Buy=Z42>0 AND (Cross(round(z),-100) OR Cross(round(z),0) OR Cross(round(z),50)); Sell=Z42<0 AND (Cross(100,round(z)) OR Cross(0,round(z)) OR Cross(-50,round(z))); Filter=Buy OR Sell; AddColumn( IIf(Buy,1,IIf(Sell,-1,0)) ,"BS",1.0,colorBlack,IIf(Buy,colorGreen,IIf(Sell,colorRed,colorBlack))); PlotShapes(Buy*shapeUpArrow,colorBlack); PlotShapes(Sell*shapeDownArrow,colorBlack); _SECTION_END(); _SECTION_BEGIN("Stochastic_45-4-2_833"); ColorX=colorBlack; //ColorX=colorWhite; periods = Param( "Periods", 45, 1, 200, 1 ); K1smooth = Param( "%K1 avg", 4, 1, 200, 1 ); //Plot( StochK( periods , K1smooth), _DEFAULT_NAME(), colorCustom3, styleNoLabel | styleThick | styleDots); periods = Param( "Periods", 45, 1, 200, 1 ); K1smooth = Param( "%K1 avg", 4, 1, 200, 1 ); D1smooth = Param( "%D1 avg", 2, 1, 200, 1 ); //Plot( StochD( periods , K1smooth, D1Smooth ), _DEFAULT_NAME(), colorCustom3, styleNoLabel | styleThick | styleDots); A = StochK( periods , K1smooth); B = StochD( periods , K1smooth, D1Smooth ); PlotOHLC( 300, 300 , 250 , 250 , "", IIf(A>80,colorBlack,colorPaleBlue), styleCloud | styleNoLabel); PlotOHLC( -250, -250 , -300 , -300 , "", IIf(A<20,colorBlack,colorPaleBlue), styleCloud | styleNoLabel); periods = Param( "Periods", 8, 1, 200, 1 ); K1smooth = Param( "%K1 avg", 3, 1, 200, 1 ); periods = Param( "Periods", 8, 1, 200, 1 ); K2smooth = Param( "%K1 avg", 3, 1, 200, 1 ); D2smooth = Param( "%D1 avg", 3, 1, 200, 1 ); M = StochK( periods , K2smooth); N = StochD( periods , K2smooth, D2Smooth ); ColorK=IIf(A>B,colorBrightGreen,colorRed); //Plot( M,"StoK", ColorK, styleNoLabel|styleThick); //Plot( N,"StoD", colorDarkYellow, styleNoLabel|styleDashed); //PlotOHLC( 0, A , B , B , "Cloud", IIf(A > B ,colorAqua,colorRed), styleCloud | styleNoLabel); _SECTION_END();
Sign up here with your email
ConversionConversion EmoticonEmoticon