Sunday, 31 August 2014

Strategy for swing trading Afl Fro Amibroker

  Strategy for swing trading




_SECTION_BEGIN("TD Fractl LINE");
strength = Param("Strength",1,1,15,1);
pR=PeakBars(RSI(14),strength)==0;
PlotShapes(shapeSmallCircle*pR,colorWhite,0,H,0);
_SECTION_END();

_SECTION_BEGIN("TD Fractl LINE");
pS =TroughBars(RSI(14),strength)==0;
PlotShapes(shapeSmallCircle*pS,colorYellow,0,L,0);
_SECTION_END();

_SECTION_BEGIN("Price Risistance");
RT=SelectedValue(ValueWhen(pR,H));
ST=SelectedValue(ValueWhen(pS,L));
Plot(RT,"",colorBlue,styleThick);
Plot(ST,"",colorYellow,styleThick);
_SECTION_END();

_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);
Plot(LineA,"",colorWhite,4+8,styleNoLabel);
_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);
Plot(LineB,"",colorWhite,4+8,styleNoLabel);
_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> 0, - angle_MA, angle_MA);
Col=IIf(angle_MA>3,colorWhite,IIf(angle_MA<(-3),colorRed,colorBlack));
Plot(EMA( P,200), _DEFAULT_NAME(), Col, ParamStyle("Style") );
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);

3 comments:

  1. Nice article thanks for sharing such a valuable information with us.you may also check our blog for more information
    FMCG shares
    Nifty FMCG

    ReplyDelete
  2. Nice post ! I am very interesting to read your blog content.Thanks for sharing.you may also check our blog Celestial Biolabs Ltd

    ReplyDelete
  3. range = 25 / (HighHigh - LowLow) * LowLow; gettigerror message division by zero

    ReplyDelete

Thanks