.

Volume Spike Ultimate System - Amibroker AFL Code

Click Image To Enlarge. Please Rate And Comment.

Volume Spike Ultimate System

_SECTION_BEGIN("V-spiker");

SetChartBkGradientFill( ParamColor("BgTop", colorBlue),

ParamColor("BgBottom", colorBlack),ParamColor("Titleblock",colorDarkBlue ));


upcolor=ParamColor("UpCandleColor",colorTeal );
downcolor=ParamColor("DownCandleColor",colorPaleBlue );


//Volume Change
Volwma=WMA(V,15);
Volchange=(((V-Volwma)/Volwma)*100);
Vol=(ROC(V,1)); 


//GraphXSpace = Param("Xspace", 10, 2, 20, 1);
// vol with std
LBP = Param("Look Back", 15, 0, 150,1 );
Mean = MA(ln(V),LBP);
StD = StDev(ln(V),LBP);
xp3 = exp(mean + 2*std); //3 band
xp2 = exp(mean + 1.5*std); //2 nd band
xp1 = exp(mean + 1*std); // 1st band
xm = exp(mean); // avg
xn1 = exp(mean - 1*std); // -1 band
xn2 = exp(mean - 1.5*std); //-2 band
//Plot(xp3,"", colorGrey50,1|4096);
//Plot(xp2,"", colorGrey50,1|4096);
//Plot(xp1,"", colorPaleBlue,1|4096);
//Plot(xm, "AvgVol", ParamColor( "AvgColor", colorOrange ),ParamStyle("AvgStyle",styleLine|styleThick|styleDots,maskAll),1|4096);
Plot(Volwma, "AvgVol", ParamColor( "AvgColor", colorGold ),ParamStyle("AvgStyle",styleLine|styleThick|styleDots,maskAll),1|4096);


//Plot(xn1,"",colorBlue,1|4096);
////Plot(xn2,"", 1,1|4096);

upbar = C > Ref(C,-1);
downbar = C< Ref(C,-1);
barcolor2=IIf(downbar,colorRed, IIf(upbar, 2,19) );

upbar = C > Ref(C,-1);
downbar = C< Ref(C,-1);

O = IIf(downbar, V, 0); 
C = IIf(downbar, 0,V);
L=0; 
H = V;

ColorHighliter = IIf(upbar, upcolor,IIf(downbar, downcolor,colorDarkGreen));
SetBarFillColor( ColorHighliter );

PlotOHLC( O,H,L,C, "", barColor2, ParamStyle("CandleStyle",styleCandle,maskAll));

/*
PcntInc = NumToStr((V-xm)/xm*100,2);
_N(Title =Name() + " " + ": {{VALUES}}"+   WriteIf(V,"  |\\c33 TotVol =\\c35 ","")
 +WriteVal(V, 1.0)+"\n"+EncodeColor(colorTurquoise)+
WriteIf(V > XM*(1 + (LBP * .01)),"Volume's("+PcntInc+")% ABOVE its("+Lbp+") days average","")+
WriteIf(V < XM*(1 + (LBP * .01)),"Volume's("+PcntInc+")% BELOW its("+Lbp+") days average",""));
*/
///////////////////////////
_SECTION_BEGIN("Volume Oscillator");

PlusDM= IIf(High>Ref(High,-1) AND Low>=Ref(Low,-1), High-Ref(High,-1),
                 IIf(High>Ref(High,-1) AND Low<Ref(Low,-1)
                 AND High-Ref(High,-1)>Ref(Low,-1)-Low,
                High-Ref(High,-1),0));

Vm=log(EMA(V,3));
 
Buy= (C-L)*Vm+ (H-O)*Vm + 
         IIf(C>O,(C-O)*Vm,0) + PlusDM*Vm + 
         IIf(Ref(C,-1)<O,(O-Ref(C,-1))*Vm,0);

MinDM = IIf(Low<Ref(Low,-1)   AND  High<=Ref(High,-1), Ref(Low,-1)-Low,
               IIf(High>Ref(High,-1) AND Low<Ref(Low,-1)
               AND High-Ref(High,-1)<Ref(Low,-1)-Low, Ref(Low,-1)-Low, 0));

Sell= (H-C)*Vm + (O-L)*Vm + 
         IIf(C<O,(O-C)*Vm,0) + MinDM*Vm + 
         IIf(Ref(C,-1)>O,(Ref(C,-1)-O)*Vm,0);

Wm=Wilders(Wilders(Buy,3)-Wilders(Sell,3),3);

Buy=Cross(Wm,0);
Sell=Cross(0,Wm);

Title = Name() + " " + WriteVal(V, 1.0) +   WriteIf(Buy,"  |\\c33 Volume :- Buy","");
_SECTION_END();




_N(Title =Name() + " " +EncodeColor(colorWhite)+" Total Vol: " +WriteVal(V,format=1)+
 EncodeColor(49) +" Vol Change : " + WriteIf(Vol>0,EncodeColor(08),EncodeColor(04)) +WriteVal(Vol,format=1.2)+ "%  "  +
"\n"+
 EncodeColor(colorWhite)+"WMA Vol: "+   WriteVal(Volwma,format=1)

+ EncodeColor(05)
+WriteIf(V > Volwma,"  Volume's("+WriteVal(Volchange,format=1.2)+")% ABOVE its(15) days WMA","")
+ EncodeColor(04)
+WriteIf(V < Volwma, "  Volume's("+WriteVal(Volchange,format=1.2)+")% BELOW its(15) days WMA",""));


//WriteIf(V > XM*(1 + (LBP * .01)),"Volume's("+PcntInc+")% ABOVE its("+Lbp+") days average","")+
//WriteIf(V < XM*(1 + (LBP * .01)),"Volume's("+PcntInc+")% BELOW its("+Lbp+") days average",""));
_SECTION_END();


_SECTION_BEGIN("Spiker_Shadow");


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));

/* green volume: up-day and up-close*/
gv = IIf(VType == green, V, 0); 
/* yellow volume: up-day but down-close */
yv = IIf(VType == yellow, V, 0); 
/* red volume: down-day and down-close */
rv = IIf(VType == red, V, 0); 
/* blue volume: down-day but up-close */
bv = IIf(VType == blue, V, 0); 


uv = gv + bv; uv1 = Ref(uv, -1); /* up volume */
dv = rv + yv; dv1 = Ref(dv, -1); /* down volume */


VolPer = Param("Adjust Vol. MA per.", 10, 1, 255, 1);
ConvPer = Param("Adjust Conv. MA per.", 4, 1, 255, 1);


MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);
MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);
MAtv = TEMA(V, VolPer );//total volume




Converge = (TEMA(MAuv - MAdv, ConvPer));
Converge1 = Ref(Converge, -1);
ConvergeUp = Converge > Converge1;
ConvergeOver = Converge > 0;
rising = ConvergeUp AND ConvergeOver;
falling = !ConvergeUp AND ConvergeOver;


/*convergenceOscillator = Param("Show Oscillator", 0, 0, 1, 1);
OscillatorOnly = Param("Show Oscillator Only", 0, 0, 1, 1);
if(convergenceOscillator OR OscillatorOnly){
Plot(Converge, "Bull/Bear Volume Convergence/Divergence", colorViolet,
1|styleLeftAxisScale|styleNoLabel|styleThick);
Plot(0,"", colorYellow, 1|styleLeftAxisScale|styleNoLabel);
}*/


upshadow=ParamColor("UpShadowColor",colorViolet );
downshadow=ParamColor("DownShadowColor",colorViolet );
riseFallColor = IIf(rising, upshadow,downshadow); 

riseFallShadows = Param("Show RiseFallShadows", 1, 0, 1, 1);
if(riseFallShadows){
Plot(IIf(rising OR falling, 1, 0), "", riseFallColor,ParamStyle("ShadeStyle",styleHistogram|styleArea|styleThick|styleOwnScale|styleNoLabel,maskAll));

/*Plot(IIf(rising OR falling, 1, 0), "", riseFallColor,
styleHistogram|styleArea|styleOwnScale|styleNoLabel);*/
}


//GraphXSpace =5;

//_N(Title="");
_SECTION_END();
_SECTION_BEGIN("Flower");
si=Param("Zoom/In Out",5,-50,100,1);
GraphXSpace=si;  

r1 = Param( "ColorFast avg", 5, 2, 200, 1 );
r2 = Param( "ColorSlow avg", 10, 2, 200, 1 );
r3 = Param( "ColorSignal avg", 5, 2, 200, 1 );

m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
mycolor=IIf(m1<0 AND m1>s1, ColorRGB(155,155,155),IIf(m1>0 AND m1>s1,ColorRGB(0,125,0),IIf(m1>0 AND m1<s1,ColorRGB(180,30,160),ColorRGB(100,0,0))));

Prd1=Param("ATR Period",4,1,20,1);
Prd2=Param("Look Back",7,1,20,1);
green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);
flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);
barColor=IIf(Close>Open,ColorRGB(0,245,0),ColorRGB(255,0,0));

Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
total = 0;
total = total  + IIf(tskp_colortmplcnd0 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd1 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd2 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd3 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd4 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd5 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd6 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd7 > 0, 1, -1); 
total = total  + IIf(tskp_colortmplcnd8 > 0, 1, -1); 


for( i = 0; i < BarCount; i++ ) 
{

 if( total[i] >= 5 )
  Color[i] = colorLime;
 else if(  total[i] <= -5 )
  Color[i] = colorRed;
 else
  Color[i] = colorWhite;
} 

Candle=ParamList("Candle","Modified Candlestick,Modified Heikin Ashi,Normal Candlestick",1);
if(Candle=="Modified Candlestick")
{
ColorHighliter = myColor;
SetBarFillColor( ColorHighliter );
Plot (Close,"- Modified Candlestick", Color,ParamStyle( "Style", styleCandle|styleLine | styleThick, maskAll)); 
}
if(Candle=="Modified Heikin Ashi")
{
ColorHighliter = myColor;
SetBarFillColor( ColorHighliter );
PlotOHLC( IIf(flowerOpen<flowerClose, flowerOpen, flowerClose),flowerHigh,flowerLow,IIf(flowerOpen<flowerClose, flowerClose, flowerOpen), "Modified Heikin Ashi", Color, styleCandle|styleLine);
}
if(Candle=="Normal Candlestick")
{
//ColorHighliter = myColor;
//SetBarFillColor( ColorHighliter );
PlotOHLC(O,H,L,C,"Normal Candlestick",barcolor,styleCandle|styleLine);
}


_SECTION_END();

_SECTION_BEGIN("TSKPPUSHDOTS");
if(Candle=="Modified Heikin Ashi")
{
Combo = E_TSKPCOMBO(Open,High,Low,Close,Volume);
NewUpDown = E_TSKPNEWUPDOWN(Open,High,Low,Close,Volume);
UpDown7 = 0.5*(High+Low) - E_TSKPSTOPLINE(High,Low,Close);
//r=Param("Red",0,0,255,1);
//g=Param("Green",0,0,255,1);
//b=Param("Blue",0,0,255,1);

if(Candle=="Normal Candlestick" OR Candle=="Modified Candlestick")
{
PlotShapes( IIf( ((Combo>0) AND (NewUpDown > 0) AND (UpDown7 > 0)),shapeSmallCircle,shapeNone), ColorRGB(0,125,255),0, High, 8);
PlotShapes( IIf( ((Combo<0) AND (NewUpDown < 0) AND (UpDown7 < 0)),shapeSmallCircle,shapeNone), ColorRGB(225,0,0),0, High, 8);
}

else
{
PlotShapes( IIf( ((Combo>0) AND (NewUpDown > 0) AND (UpDown7 > 0)),shapeSmallCircle,shapeNone), ColorRGB(0,255,0),0, flowerhigh, 12);
PlotShapes( IIf( ((Combo<0) AND (NewUpDown < 0) AND (UpDown7 < 0)),shapeSmallCircle,shapeNone), ColorRGB(255,0,0),0, flowerhigh, 12);
}
}
_SECTION_END();

Title = StrFormat("\\c02 {{NAME}} | {{DATE}} | Open : %g | High : %g | Low : %g | Close : %g | Change = %.1f%% | Volume = " +WriteVal( V, 1.0 ) +", {{VALUES}}",
O, H, L, C, SelectedValue( ROC( C, 1 )) );




_SECTION_BEGIN("TSKPMoMo");

if(Candle=="Modified Heikin Ashi")
{
blsLong = 0;
KPStopLine = E_TSKPSTOPLINE(High,Low,Close);
// tskp_upsell, tskp_triggerline, tskp_triggerlinevma
sw = E_TSKPUPSELL(Open,High,Low,Close,Volume);
KPTriggerLine = tskp_triggerline;
KPFast3Val = IIf((E_TSKPFAST3(Open,High,Low,Close,Volume)> 0),1, -1);
//tskp_fast2val1, tskp_fast2val2
dummy = E_TSKPFAST2(Open,High,Low,Close,Volume);
KPFast2Val = IIf ((tskp_fast2val1 > 0),1,-1); 



Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
sctotal = 0;
sctotal = sctotal  + IIf(tskp_colortmplcnd0 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd1 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd2 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd3 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd4 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd5 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd6 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd7 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd8 > 0, 1, -1); 

// tskp_mediumma,tskp_mediumup,tskp_mediumdown
dummy = E_TSKPMEDIUM(Close);
KPMediumUP = tskp_mediumup;
KPMediumDwn = tskp_mediumdown;
KPMediumMA = tskp_mediumma;

// -- Create 0-initialized arrays the size of barcount
aHPivs = H - H;
aLPivs = L - L;
aHiVal = H - H;
aLoVal = L - L;


for (curBar=5; curBar < BarCount-1; curBar++)
{


 if( (blsLong == -1) OR (blsLong == 0))
   {
       if ((sctotal[CurBar]  >= 5) AND (KPMediumUP[CurBar]  > KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar]  == 1) AND 
        (KPFast2Val[CurBar]  == 1) AND (KPTriggerLine[CurBar]  >= KPStopLine[CurBar] ))
       {
         blsLong = 1;
    aLPivs[CurBar] = 1;
    aLoVal[CurBar] = Low[CurBar];
       }
    }

 if( (blsLong == 1) OR (blsLong == 0))
   {
       if ((sctotal[CurBar]  <= -5) AND (KPMediumDwn[CurBar]  < KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar]  == -1) AND 
       (KPFast2Val[CurBar]  == -1) AND (KPTriggerLine[CurBar]  <= KPStopLine[CurBar] ))
       {
         blsLong = -1;
         aHPivs[Curbar] = 1;
    aHiVal[Curbar] = High[Curbar];
       }
    }

    if ((blsLong == 1) AND ((sctotal[CurBar]  < 5) OR (KPMediumUP[CurBar]  < KPMediumMA[CurBar] )  OR  
       (KPFast2Val[CurBar]  < 1)  OR  (KPFast3Val[CurBar]  < 1) OR (KPTriggerLine[CurBar]  < KPStopLine[CurBar] )) )
       {
           blsLong= 0;
        }
          
      if ((blsLong == -1) AND ((sctotal[CurBar]  > -5)  OR  (KPMediumDwn[CurBar] > KPMediumMA[CurBar] )  OR  
         (KPFast2Val[CurBar]  > -1)  OR (KPFast3Val[CurBar]  > -1)  OR 
         (KPTriggerLine[CurBar]  > KPStopLine[CurBar] )) )
         {
            blsLong = 0;
         }
}

PlotShapes (IIf(aHPivs == 1, shapeHollowSmallSquare, shapeNone) ,colorRed, layer = 0, yposition = flowerHigh, offset = 12 );
PlotShapes (IIf(aLPivs == 1, shapeHollowSmallSquare, shapeNone) ,colorLime, layer = 0, yposition = flowerhigh, offset = 12 );

} 
_SECTION_END();



_SECTION_BEGIN("Graphics");
GrpPrm=Param("Graphic Space",-5,-10,10);
GraphXSpace=GrpPrm;
_SECTION_END();
Previous Post Next Post