.

All In One Very Accurate Trading System - Amibroker AFL Code

Click Image To Enlarge. Please Rate And Comment.

All In One Very Accurate Trading System

pivot = (H +L+C)/3; 
piv = EMA (pivot,Param("short ema",5,1,20,1));
piv2 = EMA (pivot,Param("fast ema",10,1,50,1));
Buy = Cross (piv, piv2);
Short = Cross (piv2,piv);
pivot_col =  IIf (pivot > Ref(pivot,-1), colorBlue,colorRed);
piv_col = IIf (piv > Ref(piv,-1), colorBlue,colorRed);
piv2_col = IIf (piv2 > Ref(piv2,-1),colorBlue, colorRed);
//Plot (pivot , "pivot", piv_col, styleThick);

bar_col = IIf (MACD( 5, 34 ) > Signal( 5, 34, 14 ), colorBlue, colorRed);
//Plot (pivot , "pivot", pivot_col, styleThick);
Plot (piv , "piv", piv_col, styleThick);
Plot (piv2 , "piv2", piv2_col, styleThick);                
Col = IIf (H > Ref(H,-1) AND L > Ref(L,-1), colorBlue, IIf (Low < Ref(L,-1) AND High < Ref(H,-1),colorRed, colorYellow));
Plot( C, "Close", bar_Col, styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
PlotShapes (shapeUpArrow*Buy, colorGreen);
PlotShapes (shapeDownArrow*Short, colorRed);

//pv_col = IIf ( ADX(9) > Ref(ADX(9),-1) AND PDI( 9 ) > MDI( 9 ),colorBlue,IIf (ADX(9) > Ref(ADX(9),-1) AND PDI( 9 ) < MDI( 9 ),colorRed, colorYellow));
pv_col = IIf (  piv_col == colorBlue AND piv2_col ==colorBlue,colorBlue,IIf ( piv_col == colorRed AND piv2_col ==colorRed,colorRed,colorYellow));

//Plot(3, "ribbon", piv_col, styleOwnScale| styleArea|styleNoLabel,-0.5,100);

_SECTION_BEGIN("ATRtrading");
SetChartBkColor( colorBlack ) ;
period = Param("Period", 13, 1, 240, 1);
mult = Param("Multiplier", 1.7, 1, 240, 0.1);
 
f=ATR(period);

VS[0] = Close[0];
trend[0] = 0;
HighC[0]=0;
Lowc[0]=0;

for( i = period+1; i < BarCount; i++ )
{

vs[i] = vs[i-1];
trend[i] = trend[i-1];
highC[i] = HighC[i-1];
lowc[i] = lowc[i-1];

if ((trend[i]>=0) && ( C[i] <VS[i] ))
{
trend[i] =-1;
HighC[i] = C[i];
lowc[i] = C[i];
}

if ((trend[i]<=0) && (C[i] >VS[i]))
{
trend[i]=1;
HighC[i] = C[i];
lowc[i] = C[i];
}

if (trend[i]==-1)
{
if (C[i]<lowc[i]) lowc[i] = C[i];
VS[i]= lowc[i]+ (mult*f[i]);
}


if (trend[i]==1)
{
if (C[i]>HighC[i]) HighC[i] = C[i];
VS[i]= HighC[i]-(mult*f[i]);
}

}


//Buy=Cross(Trend,0);
//Sell=Cross(0, Trend);

//Plot(Close,"Close",colorBlue,styleCandle);
Plot(VS, "Vol Stop",IIf(trend==1,10,11 ),styleThick);

mkol = IIf( Trend==1, 10, 11);
Plot(5, "ribbon", mkol, styleOwnScale|styleArea|styleNoLabel, 0, -5); // Weekly trend

//shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
//PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low-f, High+f));
_SECTION_END();
Previous Post Next Post