// Downloaded From https://www.WiseStockTrader.com // BB & KB AREA COLOR SQUEEZE _SECTION_BEGIN("Bollinger Bands"); //P = ParamField("Price field",-1); PeriodsBB = Param("PeriodsBB", 15, 2, 300, 1 ); WidthBB = Param("WidthBB", 2, 0, 10, 0.05 ); //Color = ParamColor("Color", colorCycle ); //Style = ParamStyle("Style"); //Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style ); //Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style ); Plot( BBandTop( C, PeriodsBB, WidthBB ), "\nBBTop" + _PARAM_VALUES(), colorBlue , styleLine+styleThick ); Plot( BBandBot( C, PeriodsBB, WidthBB ), "\nBBBot" + _PARAM_VALUES(), colorBlue , styleLine+styleThick ); _SECTION_END(); _SECTION_BEGIN("Keltner Bands"); //P = ParamField("Price field",-1); PeriodsKB = Param("PeriodsKB", 15, 2, 300, 1 ); WidthKB = Param("WidthKB", 2, 0, 10, 0.05 ); //Color = ParamColor("Color", colorCycle ); //Style = ParamStyle("Style", styleLine | styleNoLabel); CenterLine = MA( C, PeriodsBB ); // OBSERVATIE: CenterLine= BBMid= KMid ; KTop = CenterLine + WidthKB * ATR( PeriodsKB ); KBot = CenterLine - WidthKB * ATR( PeriodsKB ); //Plot( KTop, "KBTop" + _PARAM_VALUES(), Color, Style ); //Plot( KBot, "KBBot" + _PARAM_VALUES(), Color, Style ); Plot( KTop, "\nKBTop" + _PARAM_VALUES(), colorRed , styleLine+styleThick ); Plot( KBot, "\nKBBot" + _PARAM_VALUES(), colorRed , styleLine+styleThick ); _SECTION_END(); bbupper= BBandTop( C, PeriodsBB, WidthBB ) ; bblower= BBandBot( C, PeriodsBB, WidthBB ) ; bbmid= (bbupper+bblower)/2 ; bbmidcol= IIf(bbmid>=Ref(bbmid,-1),colorBlue,colorAqua ) ; //Plot(bbmid,"\nBBMid",colorBlue,styleLine) ; Plot(bbmid,"\nBBMid",bbmidcol,styleDots+styleThick ) ; kupper= KTop ; klower= KBot ; kmid= (ktop+kbot)/2 ; //Plot(kmid,"\nKMid",colorRed,styleLine) ; //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx //XXXXXXXXXX HEIKIN ASHI DERZI EXACT FORMULA BEGIN DDDDDDDDDDDDDDDDD _SECTION_BEGIN("HA Looping ( no AMA() )"); //SetChartOptions(0,chartShowArrows|chartShowDates); /////////////////////////////////////////////////////////// // // Heikin Ashi - Calculated Properly with no use of AMA // // JF Derzi, December 2012 // // HaClose[0] = (Open[0]+High[0]+Low[0]+Close[0]) / 4; HaOpen[0] = (HaClose[0] + Open[0]) / 2; HaHigh[0] = Max( High[0], Max( HaClose[0], HaOpen[0] ) ); HaLow[0] = Min( Low[0], Min( HaClose[0], HaOpen[0] ) ); for (i=1; i=HaOpen,colorGreen,colorRed); SetBarFillColor(IIf(HaClose>=HaOpen,colorBrightGreen,colorOrange)); PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "\nHeikinAshiDerzi", barcolorha, styleCandle ); //-------------------------------------------------------------------------------------------------------- // Heikin Ashi & C>O and C>Ref(C,-1) /* barcolorha = IIf(HaClose>=HaOpen AND C>O and C>Ref(C,-1),colorGreen, IIf(HaClose=HaOpen AND C>O and C>Ref(C,-1),colorBrightGreen , IIf(HaClose=HaOpen ; haDelta= HaClose-HaOpen ; MAhaDelta= MA(haDelta,3) ; haDeltaUpMA= haDelta>MA(haDelta,3) ; //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXHEIKIN ASHI EXACT FORMULA END DDDDDDDDDDDDDDDDDDDDDDDD //PRICE _SECTION_BEGIN("Price"); //SetChartOptions(0,chartShowArrows|chartShowDates); _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%)Vol " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) )); //Plot( C, "", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); //barcolorc= IIf(C>O AND C>Ref(C,-1), colorBlue, // IIf(CO AND C>Ref(C,-1), colorBrightGreen, // IIf(C= kLower; // OBSERVATIE: KMid= BBMid ; IsSqueeze= ( bbupper<=kupper AND bblower>=klower ) ; IsSqueezeCol= IIf(issqueeze, colorAqua,colorPink) ; PlotOHLC(bbupper,bbupper,bblower,bblower,"",issqueezecol,styleCloud) ; //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx //RIBBON TMV BEGIN RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR _SECTION_BEGIN("MultipleRibbon"); // You plot a Ribbon by calling the function as follows: MultiRibbon("Color", "Ribbon Number", "Name To Display"); // The "Ribbon Number" is simply the order of the ribbon, starting with 1 as the bottom Ribbon. You can add as many // ribbons as you want, until you run out of chart space. Just keep track of the 'Serial Number' (Ribbon Number). :-) RibbonThickness = Param("RibbonThickness", 8, 1, 15, 0.1); Font = ParamList("Font:","Arial|Calibri|Futura|Tahoma|Times New Roman"); ""; 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 = colorLightGrey; Position = RibbonThickness * Position; x2 = Status("pxchartright"); y2 = Status("pxchartbottom"); RibbonColor = IIf(GfxConvertBarToPixelX(BarIndex()-Status("firstvisiblebarindex")) > y2/1.5 * (RibbonThickness/100) * 18 , RibbonColor, colorYellow); Plot(0, "", LineColor, styleOwnScale | styleNoLabel, 0, 100); Plot(Position, "", LineColor, styleOwnScale | styleNoLabel, 0, 100); Plot(Position, "", RibbonColor, styleArea | styleOwnScale | styleNoLabel, 0, 100); GfxSetTextColor(colorBlack); GfxSelectFont(Font, y2/1.5 * (RibbonThickness/100), 400); GfxDrawText(Label, 8, y2 * 1.001 -(y2 * Position/100) , y2/1.5 * (RibbonThickness/100) * 17, y2, 2 + 32 + 256); } //================================================================================================================= //================================================================================================================= //TREND ADVISOR pointer[0] = 0; /* Phase filter */ /* Cond1 = Close > MA(Close, 50)AND NOT(Close > MA(Close, 200))AND NOT(MA(Close, 50) > MA(Close, 200)); Cond2 = Close > MA(Close, 50)AND Close > MA(Close, 200)AND NOT(MA(Close, 50) > MA(Close, 200)) ; Cond3 = Close > MA(Close, 50)AND Close > MA(Close, 200)AND MA(Close, 50) > MA(Close, 200) ; Cond4 = NOT(Close > MA(Close, 50))AND Close > MA(Close, 200)AND MA(Close, 50) > MA(Close, 200); Cond5 = NOT(Close > MA(Close, 50))AND NOT(Close > MA(Close, 200))AND MA(Close, 50) > MA(Close, 200); Cond6 = NOT(Close > MA(Close, 50))AND NOT(Close > MA(Close, 200))AND NOT(MA(Close, 50) > MA(Close, 200)); */ Cond1 = C>=MA(C,50) AND C=MA(C,50) AND C>=MA(C,200) AND MA(C,50)=MA(C,50) AND C>=MA(C,200) AND MA(C,50)>=MA(C,200) ; Cond4 = C=MA(C,200) AND MA(C,50)>=MA(C,200); Cond5 = C=MA(C,200); Cond6 = C C1; dc = C <= C1; ud = C > O; dd = C <= O; green = 1; blue = 2; yellow = 3; red = 4; white = 5; VType = IIf(ud, IIf(uc, green, yellow), IIf(dd, IIf(dc, red, blue), white)); gv = IIf(VType == green, V, 0); yv = IIf(VType == yellow, V, 0); rv = IIf(VType == red, V, 0); bv = IIf(VType == blue, V, 0); uv = gv + bv; uv1 = Ref(uv, -1); /* up volume */ dv = rv + yv; dv1 = Ref(dv, -1); /* down volume */ /* create moving average period parameters */ VolPer = Param("Adjust Vol. MA per.", 21, 1, 255, 1); ConvPer = Param("Adjust Conv. MA per.", 7, 1, 255, 1); /* create triple exponential moving avearges of separate up and down volume moving averages */ MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1); MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1); MAtv = TEMA(V, VolPer );//total volume /* Switch for Horizontal lines indicating current level of positive and negative volume for ease in comparing to past highs/lows - toggle via parmameter window */ OscillatorOnly = Param("ShowOscillatorOnly", 0, 0, 1, 1); CompareBullVolume = Param("ShowBullLevel", 1, 0, 1, 1); if(CompareBullvolume AND !OscillatorOnly){ //Plot(SelectedValue(MAuv), "", colorGreen, styleLine); } CompareBearVolume = Param("ShowBearLevel", 1, 0, 1, 1); if(CompareBearVolume AND !OscillatorOnly){ //Plot(SelectedValue(MAdv), "", colorRed, styleLine); } /* Volume Segment Switches - toggle via parameter window */ bullvolume = Param("ShowBullVolume", 1, 0, 1, 1); bearvolume = Param("ShowBearVolume", 1, 0, 1, 1); totalvolume = Param("ShowTEMA(TotalVolume)", 1, 0, 1, 1); /* plot volume lines and histograms if toggled on: */ bearToFront = Param("ShowBearVolinFront", 0, 0, 1, 1); if(bearToFront AND !OscillatorOnly){ //Plot(MAdv, "", colorRed, styleNoLabel); } if(bullvolume AND !OscillatorOnly){ //Plot(MAuv, "AverageBullVolume", colorGreen, styleThick+styleNoLabel); } if(bearvolume AND !OscillatorOnly){ //Plot(MAdv, "AverageBearVolume", colorRed, styleThick+styleNoLabel); } if(bearvolume AND !OscillatorOnly){ //Plot(MAdv, "", colorOrange, styleNoLabel); //PlotOHLC( 0 , MAdv , 0 , MAdv , "", colorOrange, styleCloud | styleNoRescale|styleNoLabel); } if(bullvolume AND !OscillatorOnly){ //Plot(MAuv, "", colorLime, styleNoLabel); //PlotOHLC( 0 , MAuv , O ,MAuv , "", colorLime, styleCloud | styleNoRescale|styleNoLabel); } if(totalVolume AND !OscillatorOnly){ //Plot(MAtv, "TEMA(TotalVolume)", colorLightBlue ); //PlotOHLC( 0 , MAtv , 0 , MAtv , "", colorLightBlue, styleCloud | styleNoRescale|styleNoLabel); } /* Buy=Cross(MAuv,MAdv); Sell=Cross(MAdv,MAuv); PlotShapes(IIf(Buy,shapeUpArrow,shapeNone) ,colorBlue); PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed); Filter=Buy OR Sell; Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy); */ //AddColumn(Close,"Close");AddColumn(Volume,"Total Volume");AddColumn(Buy,"Buy"); AddColumn(Sell,"sell"); /* better visibility of zero line: */ //Plot(0, "", colorViolet, 1); /* Rise/Fall Convergence variables: */ Converge = (TEMA(MAuv - MAdv, ConvPer)); Converge1 = Ref(Converge, -1); ConvergeUp = Converge > Converge1; ConvergeOver = Converge > 0; rising = ConvergeUp AND ConvergeOver; falling = !ConvergeUp AND ConvergeOver; /* Rise/Fall Convergence Oscillator Switch - toggle via parameter window - (provides a better view of resulting combination of battling bull/bear volume forces) */ convergenceOscillator = Param("Show Oscillator", 0, 0, 1, 1); if(convergenceOscillator OR OscillatorOnly){ //Plot(Converge, "AmimalsWar", colorBrown, 1|styleLeftAxisScale|styleNoLabel|styleThick); //Plot(0,"", colorViolet, 1|styleLeftAxisScale|styleNoLabel); } /******************************************************** Convergence Rise/Fall Shadows: (provides a more easily visible display of rising and falling bull/bear volume convergence) - toggle via parameter window -posiitive Volume exceeding negative Volume: Light shadow -negative volume exceeding positive volume: dark shadow -if you use standard gray background - best shadows are: -my greys: 14 = (216, 216, 216); 15 = (168, 168, 168)); -best substitute? using AB color constants? -light: colorpalegreen; dark: colorRose;? -(depends on your color scheme - customize to your tastes) **********************************************************/ /* uncomment if you use my custom color greys: */ riseFallColor = IIf(rising, colorLime,colorOrange); //my custom shadow greys /* comment out if you use my custom color gray shadows: */ /* riseFallColor = IIf(rising, colorPaleGreen,colorRose); */ /* Rise/Fall Convergence Plot Switch - toggle via parameter window */ riseFallShadows = Param("ShowRiseFallShadows", 0, 0, 1, 1); if(riseFallShadows){ //Plot(IIf(rising OR falling, 1, 0), "", riseFallColor, styleArea|styleOwnScale|styleNoLabel); } GraphXSpace = 0.5; _SECTION_END(); /* _SECTION_BEGIN("Background"); SetChartBkColor(ParamColor("Outer panel",colorBlack)); // color of outer border SetChartBkGradientFill( ParamColor("Inner panel upper",colorBlack),ParamColor("Inner panel lower",colorBlack)); tchoice=Param("Title Selection ",2,1,2,1); _SECTION_END(); */ BullV= MAuv>MAdv ; UpV= ( MAuv>MAdv AND MFI()>MA(MFI(),7) ) ; UporV= ( MAuv>MAdv OR MFI()>MA(MFI(),7) ) ; DnV= ( MAuv Lh ) { upsw = 1; Hh = Ch; Hl = Cl; } } Hla[ i ] = Hl; Lha[ i ] = Lh; upswa[ i ] = upsw; } //Plot( IIf( upswa == 1, Hla, Null ), "SwLine", ColorRGB( 64, 128, 128), styleThick ); //Plot( IIf( upswa == 0, Lha, Null ), "SwLine", ColorRGB( 128, 64, 128), styleThick ); //Plot( IIf( upswa == 1, Hla, Null ), "\nSwLine", colorBlue , styleDots ); //Plot( IIf( upswa == 0, Lha, Null ), "\nSwLine", colorRed , styleDots ); //Plot( C, "Price", IIf( upswa == 1, // ColorBlend( colorGreen, colorWhite ), // ColorBlend( colorRed, colorWhite )), styleBar+styleThick ); //Plot( C, "Price", IIf( upswa == 1, // ColorBlend( colorLime , colorWhite ), // ColorBlend( colorRed, colorWhite )), styleBar+styleThick ); CpClear= upswa == 1 ; VdClear= upswa == 0 ; //Buy= Cross(upswa ,0) ; //Sell= Cross(1,upswa) ; //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx //FORMULE RIBBON TREND MOMENTUM VOLUME Stochup= StochK()>StochD() ; macdup= MACD()>Signal() ; macdup0= MACD()>0 ; Hist= MACD()-Signal() ; Histup= Hist>Ref(Hist,-1) ; pdiupmdi= PDI()>MDI() ; uptrend= ( MACD()>Signal() AND PDI()>MDI() ) ; dntrend= ( MACD()MA(RSI(),7) ; CCIUP0= CCI()>0 ; MFIUPMA7= MFI()>MA(MFI(),7) ; myup= (pdiupmdi AND macdup0 AND cciup0 AND histup AND stochup AND upswa == 1 ) ; //YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY //RIBBONS TREND MOMENTUM VOLUME //R8=========================== TREND =============================================================== r1 = IIf( uptrend ,colorGreen , IIf( dntrend , colorRed,colorTan ) ) ; //--------------------------------------------------------------------------------------------------- //R1============================= MOMENTUM ==================================================== r2 = IIf( rsiupma7 AND cciup0,colorGreen , IIf( !rsiupma7 AND !cciup0, colorRed,colorTan ) ) ; //----------------------------------------------------------------------------------------------- //R1============================== VOLUME ==================================================== r3 = IIf( mfiupma7 AND bullv,colorGreen , IIf( !mfiupma7 AND !bullv, colorRed,colorTan ) ) ; //------------------------------------------------------------------------------------------- //YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx MultiRibbon( r3, 1, "VOLUME"); MultiRibbon( r2, 2, "MOMENTUM"); MultiRibbon( r1, 3, "TREND"); // RIBBON TMV END RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR //VSTOP 2 _SECTION_BEGIN("Volatility 2"); // Just Re-share // E.M.Pottasch, Jul 2010 // from Metastock formula, link: http://stocata.org/metastock/stop_trail_atr.html // added separate parameters for upward and downward market environment function vstop_func(trBull,trBear) { trailArray[ 0 ] = C[ 0 ]; // initialize for( i = 1; i < BarCount; i++ ) { prev = trailArray[ i - 1 ]; if (C[ i ] > prev AND C[ i - 1 ] > prev) { trailArray[ i ] = Max(prev,C[ i ] - trBull[ i ]); } else if (C[ i ] < prev AND C[ i - 1 ] < prev) { trailArray[ i ] = Min(prev,C[ i ] + trBear[ i ]); } else if (C[ i ] > prev) { trailArray[ i ] = C[ i ] - trBull[ i ]; } else { trailArray[ i ] = C[ i ] + trBear[ i ]; } } return trailArray; } //trailLong= Support= SellStop ; //trailShort= Resistance= BuyStop ; //per = Param("per",20, 1, 150, 1); //multBull = Param("multBull",2, 1, 4, 0.05); //multBear = Param("multBear",2, 1, 4, 0.05); per = Param("ATRper",14, 1, 150, 1); multBear = Param("kRes",1.7, 0, 4, 0.05); multBull = Param("kSup",1.7, 0, 4, 0.05); trBull = multBull * ATR(per); trBear = multBear * ATR(per); trailArray = vstop_func(trBull,trBear); //SetChartBkColor( ParamColor("ColorBG", ColorRGB( 0, 0, 0 ) ) ); GraphXSpace = 5; //SetChartOptions(0, chartShowDates); //Plot(IIf(trailArray > C,trailArray,Null),"\ntrailShort",ParamColor("ColorTrailShort",ColorRGB(255,0,0)),styleStaircase); //Plot(IIf(trailArray < C,trailArray,Null),"\ntrailLong",ParamColor("ColorTrailLong",ColorRGB(0,255,0)),styleStaircase); //Plot(IIf(trailArray > C,trailArray,Null),"\nBuyStop",colorRed,styleStaircase+styleThick); //Plot(IIf(trailArray < C,trailArray,Null),"\nSellStop",colorBlue,styleStaircase+styleThick); trailARRAYcolor= IIf(C>trailARRAY,colorBlue,colorRed) ; //Plot(trailArray,"\nVSTOP",trailARRAYcolor,styleLine+styleThick) ; //Plot(trailArray,"\nVSTOP",trailARRAYcolor,8+16) ; //Plot(trailArray,"\nVSTOP",trailARRAYcolor,styledots) ; //Plot( C, "\nCandle",colorWhite, styleCandle ); BuystopNew= C>trailARRAY ; _SECTION_END(); //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx //TRAILING STOP LOSS WITH HIGH AND LOW /* // STAMP CODE NAME GfxSelectFont("Tahoma", 15, 700 ); GfxSetBkColor( colorGreen ); GfxSetTextColor(colorBlack); GfxTextOut("High Low Trailing Stop",Status("pxwidth")/1.25,Status("pxheight")/50); GraphXSpace=5; */ //====== Original TT by X ======== //------ Setting ----------------- SetOption("InitialEquity",1000000); SetTradeDelays( 0, 0, 0, 0 ); RoundLotSize = 100; BuyPrice=Close; SellPrice=Close; SetOption("maxopenpositions",1); PositionSize=-100; PcntOffset = 0; function Hstop_func() { trailHL[ 0 ] = L[ 0 ]; // initialize for( i = 1; i < BarCount; i++ ) { prev = trailHL[ i - 1 ]; if (C[ i ] >= prev AND C[ i - 1 ] >= prev)// Long Side This Day and Previous Day > Trailing { if(H[i]>H[i-1])// Make New High trailHL[ i ] = (Max(prev,L[i-1]))*(1-PcntOffset/100); else // No New high trailHL[ i ] = prev; } else if (C[ i ] < prev AND C[ i - 1 ] < prev)// Short Side This Day and Previous Day < Trailing { if(L[i]= prev)// Short Point { trailHL[ i ] = (Max(H[i],H[i-1]))*(1+PcntOffset/100);//C[ i ] - trBull[ i ]; stoploss[i-1]=1; } else //Long Point { trailHL[ i ] = (L[i])*(1-PcntOffset/100);//C[ i ] + trBear[ i ]; } } return trailHL; } trailHL = Hstop_func(); //Plot( trailHL,"\nStopLossHL",IIf(CtrailHL ; //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx //GRAPHIC MODIFIED BULL&BEAR VOLUME CHYNTHIA _SECTION_BEGIN("BullBearVolume"); C1 = Ref(C, -1); uc = C > C1; dc = C <= C1; ud = C > O; dd = C <= O; green = 1; blue = 2; yellow = 3; red = 4; white = 5; VType = IIf(ud, IIf(uc, green, yellow), IIf(dd, IIf(dc, red, blue), white)); gv = IIf(VType == green, V, 0); yv = IIf(VType == yellow, V, 0); rv = IIf(VType == red, V, 0); bv = IIf(VType == blue, V, 0); uv = gv + bv; uv1 = Ref(uv, -1); /* up volume */ dv = rv + yv; dv1 = Ref(dv, -1); /* down volume */ /* create moving average period parameters */ VolPer = Param("Adjust Vol. MA per.", 21, 1, 255, 1); ConvPer = Param("Adjust Conv. MA per.", 7, 1, 255, 1); /* create triple exponential moving avearges of separate up and down volume moving averages */ MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1); MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1); MAtv = TEMA(V, VolPer );//total volume /* Switch for Horizontal lines indicating current level of positive and negative volume for ease in comparing to past highs/lows - toggle via parmameter window */ OscillatorOnly = Param("ShowOscillatorOnly", 0, 0, 1, 1); CompareBullVolume = Param("ShowBullLevel", 1, 0, 1, 1); if(CompareBullvolume AND !OscillatorOnly){ //Plot(SelectedValue(MAuv), "", colorGreen, styleLine); } CompareBearVolume = Param("ShowBearLevel", 1, 0, 1, 1); if(CompareBearVolume AND !OscillatorOnly){ //Plot(SelectedValue(MAdv), "", colorRed, styleLine); } /* Volume Segment Switches - toggle via parameter window */ bullvolume = Param("ShowBullVolume", 1, 0, 1, 1); bearvolume = Param("ShowBearVolume", 1, 0, 1, 1); totalvolume = Param("ShowTEMA(TotalVolume)", 1, 0, 1, 1); /* plot volume lines and histograms if toggled on: */ bearToFront = Param("ShowBearVolinFront", 0, 0, 1, 1); if(bearToFront AND !OscillatorOnly){ //Plot(MAdv, "", colorRed, styleNoLabel); } if(bullvolume AND !OscillatorOnly){ //Plot(MAuv, "AverageBullVolume", colorGreen, styleThick+styleNoLabel); } if(bearvolume AND !OscillatorOnly){ //Plot(MAdv, "AverageBearVolume", colorRed, styleThick+styleNoLabel); } if(bearvolume AND !OscillatorOnly){ //Plot(MAdv, "", colorOrange, styleNoLabel); //PlotOHLC( 0 , MAdv , 0 , MAdv , "", colorOrange, styleCloud | styleNoRescale|styleNoLabel); } if(bullvolume AND !OscillatorOnly){ //Plot(MAuv, "", colorLime, styleNoLabel); //PlotOHLC( 0 , MAuv , O ,MAuv , "", colorLime, styleCloud | styleNoRescale|styleNoLabel); } if(totalVolume AND !OscillatorOnly){ //Plot(MAtv, "TEMA(TotalVolume)", colorLightBlue ); //PlotOHLC( 0 , MAtv , 0 , MAtv , "", colorLightBlue, styleCloud | styleNoRescale|styleNoLabel); } /* Buy=Cross(MAuv,MAdv); Sell=Cross(MAdv,MAuv); PlotShapes(IIf(Buy,shapeUpArrow,shapeNone) ,colorBlue); PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed); Filter=Buy OR Sell; Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy); */ //AddColumn(Close,"Close");AddColumn(Volume,"Total Volume");AddColumn(Buy,"Buy"); AddColumn(Sell,"sell"); /* better visibility of zero line: */ //Plot(0, "", colorViolet, 1); /* Rise/Fall Convergence variables: */ Converge = (TEMA(MAuv - MAdv, ConvPer)); Converge1 = Ref(Converge, -1); ConvergeUp = Converge > Converge1; ConvergeOver = Converge > 0; rising = ConvergeUp AND ConvergeOver; falling = !ConvergeUp AND ConvergeOver; /* Rise/Fall Convergence Oscillator Switch - toggle via parameter window - (provides a better view of resulting combination of battling bull/bear volume forces) */ convergenceOscillator = Param("Show Oscillator", 0, 0, 1, 1); if(convergenceOscillator OR OscillatorOnly){ //Plot(Converge, "AmimalsWar", colorBrown, 1|styleLeftAxisScale|styleNoLabel|styleThick); //Plot(0,"", colorViolet, 1|styleLeftAxisScale|styleNoLabel); } /******************************************************** Convergence Rise/Fall Shadows: (provides a more easily visible display of rising and falling bull/bear volume convergence) - toggle via parameter window -posiitive Volume exceeding negative Volume: Light shadow -negative volume exceeding positive volume: dark shadow -if you use standard gray background - best shadows are: -my greys: 14 = (216, 216, 216); 15 = (168, 168, 168)); -best substitute? using AB color constants? -light: colorpalegreen; dark: colorRose;? -(depends on your color scheme - customize to your tastes) **********************************************************/ /* uncomment if you use my custom color greys: */ riseFallColor = IIf(rising, colorLime,colorOrange); //my custom shadow greys /* comment out if you use my custom color gray shadows: */ /* riseFallColor = IIf(rising, colorPaleGreen,colorRose); */ /* Rise/Fall Convergence Plot Switch - toggle via parameter window */ riseFallShadows = Param("ShowRiseFallShadows", 0, 0, 1, 1); if(riseFallShadows){ //Plot(IIf(rising OR falling, 1, 0), "", riseFallColor, styleArea|styleOwnScale|styleNoLabel); } GraphXSpace = 0.5; _SECTION_END(); /* _SECTION_BEGIN("Background"); SetChartBkColor(ParamColor("Outer panel",colorBlack)); // color of outer border SetChartBkGradientFill( ParamColor("Inner panel upper",colorBlack),ParamColor("Inner panel lower",colorBlack)); tchoice=Param("Title Selection ",2,1,2,1); _SECTION_END(); */ BullV= MAuv>MAdv ; //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx //AROON OSCILLATOR /* Description: Aroon is Sanskrit word meaning "dawn's early light" or the change from night to day. The Aroon indicator allows you to anticipate changes in security prices from trending to trading range. The indicator uses two lines: Aroon Up and Aroon Down. Aroon Down is a measure of how close the current bar is to the most recent lowest Low bar found in the last N bars. Aroon Up is a measure of how close the current bar is to the most recent highest High bar found in the last N bars. Additionally Aroon oscillator can be defined as the difference between the Aroon Up and Aroon Down indicators. For more information on the Aroon indicator see the article written by Tushar Chande in the September 1995 issue of Technical Analysis of Stocks & Commodities magazine. Aroon indicator ranges from 0 to 100 and it is drawn with additional 30/70 levels. The default period is 14 days. The indicator works as follows: if a security makes a new 14-day high, the Aroon Up = 100; when the security makes a new 14-day low, the Aroon Down = 100; when there was no new high in 14 days, the Aroon Up = 0; and consequently when there was no new low for 14 days, the Aroon Down = 0. Aroon indicator is an another way (in addition to VHF and ADX indicators) of detemining if market is trending or not. "The Aroon Oscillator indicates an upward trend when it is above zero and a downward trend when it is below zero."; "The farther away the oscillator is from the zero line, the stronger the trend."; The Aroon indicator allows you to anticipate changes in security prices from trending to trading range. The indicator uses two lines: Aroon Up AND Aroon Down. Aroon Down is a measure of how Close the current bar is to the most recent Lowest Low bar found in the last N bars. Aroon Up is a measure of how Close the current bar is to the most recent Highest High bar found in the last N bars. Additionally Aroon oscillator can be defined as the difference between the Aroon Up AND Aroon Down indicators. Aroon indicator ranges from 0 to 100 AND it is drawn with additional 30/70 levels. The default period is 14 days. The indicator works as follows: if a security makes a new 14-Day High, the Aroon Up = 100; when the security makes a new 14-Day Low, the Aroon Down = 100; when there was no new High in 14 days, the Aroon Up = 0; AND consequently when there was no new Low for 14 days, the Aroon Down = 0. Aroon indicator is an another way (in addition to VHF AND ADX indicators) of detemining if market is trending OR NOT. */ AroonPer = Param("AroonPer",14,4,45,1); AroonUp = 100 * (AroonPer - (HHVBars(H, AroonPer + 1))) / AroonPer; AroonDn = 100 * (AroonPer - (LLVBars(L, AroonPer + 1))) / AroonPer; AroonOsc = AroonUp - AroonDn; //pdimdicol= IIf(pdimdi>0 AND pdimdi>Ref(pdimdi,-1),colorGreen, // IIf(pdimdi<0 AND pdimdi0 AND aroonosc>Ref(aroonosc,-1) OR aroonosc>=50,colorGreen, IIf(aroonosc<0 AND aroonosc 0,colorLime,colorRed), styleHistogram| styleThick); //Plot(AroonOsc, "Aroon Oscillator("+AroonPer+")", arooncol, styleDots ); //Plot(AroonOsc, "", arooncol, styleHistogram| styleThick); //PlotGrid(-50, colorBrown); //PlotGrid(50, colorBrown); //Plot(-50,"", colorBlue ,styleLine ); //Plot(50, "",colorRed ,styleLine ); //Plot(0, "",colorBrown,styleLine ); AroonOscUp0= AroonOsc>0 ; AroonOscUp50= AroonOsc>=50 ; AroonOscUp= AroonOsc>Ref(AroonOsc,-1) ; AroonOscUpUp= ( AroonOsc>0 AND AroonOsc>=Ref(AroonOsc,-1) ) ; //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx //CLEAR METHOD //LISTING 1 upsw = 0; Hh = Lh = H[ 0 ]; Hl = Ll = L[ 0 ]; for( i = 0; i < BarCount; i++ ) { Ch = H[ i ]; Cl = L[ i ]; if( upsw == 1 ) { Hh = Max( Ch, Hh ); hL = Max( Cl, Hl ); if( Ch < Hl ) { upsw = 0; Ll = Cl; Lh = Ch; } } if( upsw == 0 ) { Ll = Min( Cl, Ll ); Lh = Min( Ch, Lh ); if( Cl > Lh ) { upsw = 1; Hh = Ch; Hl = Cl; } } Hla[ i ] = Hl; Lha[ i ] = Lh; upswa[ i ] = upsw; } //Plot( IIf( upswa == 1, Hla, Null ), "SwLine", ColorRGB( 64, 128, 128), styleThick ); //Plot( IIf( upswa == 0, Lha, Null ), "SwLine", ColorRGB( 128, 64, 128), styleThick ); //Plot( IIf( upswa == 1, Hla, Null ), "\nSwLine", colorBlue , styleDots ); //Plot( IIf( upswa == 0, Lha, Null ), "\nSwLine", colorRed , styleDots ); //Plot( C, "Price", IIf( upswa == 1, // ColorBlend( colorGreen, colorWhite ), // ColorBlend( colorRed, colorWhite )), styleBar+styleThick ); //Plot( C, "Price", IIf( upswa == 1, // ColorBlend( colorLime , colorWhite ), // ColorBlend( colorRed, colorWhite )), styleBar+styleThick ); CpClear= upswa == 1 ; VdClear= upswa == 0 ; //Buy= Cross(upswa ,0) ; //Sell= Cross(1,upswa) ; //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx //COUNTBACK LINE //* Stephane Carrasset's Countback Line (CBL) popularized by Daryl Guppy //Refer to amibroker posting 30th December 2004 */ //nR=2; nR= Param("nR",2,1,20,1,0) ; Cbl[nR]=Null; bCBL=False; for( i=nR; i < BarCount; i++) { if( (Low[i-2]1) { minval[i] = Low[i-j]; n--; } else { Cbl[i] = Low[i-j]; breakloop=True; } } } if (Cbl[i] < Cbl[i-1]) Cbl[i] = Cbl[i-1]; } } else { Cbl[i] = Cbl[i-1]; } if (Cbl[i]==0) Cbl[i] = Cbl[i-1]; } CBLcol= IIf(C>CBL,colorBlue,colorRed) ; //Plot(Cbl,"\nCBL",colorRed,styleLine+styleThick); //Plot(Cbl,"\nCBL",CBLcol,styleLine+styleThick); //Plot(C,"",-1,64); _SECTION_END(); CpCBL= C>CBL ; //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx //TREND ADVISOR pointer[0] = 0; /* Phase filter */ /* Cond1 = Close > MA(Close, 50)AND NOT(Close > MA(Close, 200))AND NOT(MA(Close, 50) > MA(Close, 200)); Cond2 = Close > MA(Close, 50)AND Close > MA(Close, 200)AND NOT(MA(Close, 50) > MA(Close, 200)) ; Cond3 = Close > MA(Close, 50)AND Close > MA(Close, 200)AND MA(Close, 50) > MA(Close, 200) ; Cond4 = NOT(Close > MA(Close, 50))AND Close > MA(Close, 200)AND MA(Close, 50) > MA(Close, 200); Cond5 = NOT(Close > MA(Close, 50))AND NOT(Close > MA(Close, 200))AND MA(Close, 50) > MA(Close, 200); Cond6 = NOT(Close > MA(Close, 50))AND NOT(Close > MA(Close, 200))AND NOT(MA(Close, 50) > MA(Close, 200)); */ Cond1 = C>=MA(C,50) AND C=MA(C,50) AND C>=MA(C,200) AND MA(C,50)=MA(C,50) AND C>=MA(C,200) AND MA(C,50)>=MA(C,200) ; Cond4 = C=MA(C,200) AND MA(C,50)>=MA(C,200); Cond5 = C=MA(C,200); Cond6 = CStochD() ; stochupmy= ( StochK()>StochD() OR StochK()>80) ; stochdn80= StochK()<80 ; stochup19= StochK()>19 ; MACDup= MACD()>Signal() ; MACDup0= MACD()>0 ; Hist= MACD()-Signal() ; Histup= Hist>Ref(Hist,-1) ; MFIupma7= MFI()>MA(MFI(),7) ; MFIdn80= MFI()<80 ; MFIup50= MFI()>50 ; MFIup30= MFI()>30 ; Cupo= C>O ; CCIup0= CCI()>0 ; CCIupMA7= CCI()>MA(CCI(),7) ; MA20up= MA(C,20)>=Ref(MA(C,20),-1) ; MA10upMA15= MA(C,10)>MA(C,15) ; MA5upma10= MA(C,5)>MA(C,10) ; EMA50up= (EMA(C,50)>=Ref(EMA(C,50),-1) OR C>=EMA(C,50)) ; Cupma20= C>MA(C,20) ; Cupma50= C>MA(C,50) ; PDIupmdi= PDI()>MDI() ; PDIup20= PDI()>20 ; PDIup18= PDI()>18 ; Uptrend= (MACD()>Signal() AND PDI()>MDI()) ; Dntrend= (MACD()18 ; ADXupup= (ADX()>18 AND ADX()>Ref(ADX(),-1) OR ADX()>20 ) ; HAup= haClose>=haOpen ; CupSAR= C>SAR(0.02,0.2) ; RSIup50= RSI()>50 ; RSIupMA7= RSI()>MA(RSI(),7) ; UpV= (MAuv>MAdv AND MFI()>MA(MFI(),7)) ; DnV= (MAuvMAdv OR MFI()>MA(MFI(),7)) ; CupSAR= C>SAR() ; LimADX= ADX()<49 AND ADX()>18 ; Cuptop1= C>BBandTop( C,20,1 ) ; MyUp= ( macdup0 AND pdiupmdi AND histup AND stochup AND cciup0 AND upv ) ; //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx //PARAMTOGGLE // This combines indicators into one timing Signal //function ParamOptimize( description, default, minv, maxv, step ) // { return Optimize(description, Param(description,default, minv, maxv, step ), minv, maxv, step ); } tgl = ParamToggle("Result", "AND logic|Compare"); // switch test calculation and compare the results if(tgl) { myBuy = issqueeze AND haup AND ( ( macdup AND rsiupma7 ) OR myup ) ; myShort = !buystopnew AND !cuptop1 AND !haup OR !macdup AND !cuptop1 AND !haup OR DNTREND AND DNV ; } else { myBuy = IIf( ( bbupper<=kupper AND bblower>=klower ) AND haClose>=haOpen AND ( ( MACD()>Signal() AND RSI()>MA(RSI(),7) ) OR ( macdup0 AND pdiupmdi AND histup AND stochup AND cciup0 AND upv ) ) ,1,0); myShort = IIf( C