save2009 Posted August 16, 2009 Report Share Posted August 16, 2009 Hi All Can anyone help to convert this metastock code to MT4 expert advisor code. This code from Detecting Breakouts From Flags & Pennants strategy. More info please go to this link http://www.forexsharing.com/457475 //BUY ZZ:=Zig(C,17,%); X:=BarsSince(ZZ<Ref(ZZ,-1)AND Ref(ZZ,-1)>Ref(ZZ,-2)); X1:=LASTVALUE(X)+1; {flag duration} X2:=X1+1; SD:=Stdev(C,X2); PERIOD:=22; COEF:=.1; INTRA:=Log(H)-Log(L); VINTRA:=Stdev(INTRA,PERIOD); INTER:=Log(Typical())-Log(Ref(Typical(),-1)); VINTER:=Stdev(INTER,PERIOD); CUTOFF:=COEF*(VINTER+VINTRA)*C; MF:=C-(H+L)/2+Typical()-Ref(Typical(),-1); FVE:=Sum(If(MF>CUTOFF, +V, If(MF <-CUTOFF, -V,0)),PERIOD)/ Mov(V,PERIOD,S)/PERIOD*100; X1<21 and X1>2 AND {Condition 1} Ref(LinRegSlope(C,13)/Ref(C,-13)*100,-X1)>2.2{Condition 2} AND Ref(LinRegSlope(C,X2)/Ref(C,-X2),-1)*100<.2 AND LinRegSlope(C,X1)/Ref(C,-X1)>-1.2 {Condition 3} AND Ref(LinRegSlope(V,X2)/Ref(V,-X2),-1)*100<-2 {Condition 4} AND Ref(LinRegSlope(SD,X1),-1)<0 {Condition 5} AND Stoch(20,3)>55 AND ADX(10)>30{Condition 6} AND FVE>10 AND Fml("VFI")>-3 {Condition 7} AND C>Ref(C,-1) AND C>O {Condition 8} //SELL D1:=Simulation.CurrentPositionAge; D2:=LASTVALUE(D1); zz:=Zig(Ref(C,-D2),17,%); X:=BarsSince(ZZ<Ref(ZZ,-1)AND Ref(ZZ,-1)>Ref(ZZ,-2)); X1:=LastValue(X)+1; {flag duration} c1:=LLV(C,(D2+40)); {pole base} c2:=ref(hhv(c,22),-D2); {pole top} BREAK1:= Simulation.CurrentPositionPerformance*100; POLE:=(C2-C1)/C1*100; {pole height %} {EXIT CONDITIONS} BREAK1 >1.94* Power(pole ,.724) { Exit condition 1- profit target } OR C<REF(LLV(C,X1),-D2) { Exit condition 2 stop loss on breaking of lower flag trendline} OR (D2>14 AND BREAK1<.25*POLE) { Exit condition 3-inactivity } OR (D2>3 AND C<.9*HHV(C,4)) { Exit condition 4-trailing stop loss} OR D2>24 { Exit condition 5-time exit} //VFI indicator PERIOD:= Input("PERIOD FOR VFI ",5,1300,130); COEF:=.2; VCOEF:=Input("MAX VOLUME CUTOFF",0,50,2.5); INTER:=Log(Typical())-Log(Ref(Typical(),-1)); VINTER:=Stdev(INTER,30); CUTOFF:=COEF*VINTER*C; VAVE:=Ref(Mov(V,PERIOD,S),-1); VMAX:=VAVE*VCOEF; VC:=If(V<VMAX,V,VMAX); MF:=Typical()-Ref(Typical(),-1); VFI:=Sum(If(MF>CUTOFF, +VC, If(MF <-CUTOFF, -VC,0)),PERIOD)/VAVE; Mov(VFI,3,E); //FVE indicator PERIOD:= Input("PERIOD FOR FVE",5,80,22); COEF:=Input("COEF FOR CUTOFF",0,2,.1); INTRA:=Log(H)-Log(L);VINTRA:=Stdev(INTRA,PERIOD); INTER:=Log(Typical())-Log(Ref(Typical(),-1)); VINTER:=Stdev(INTER,PERIOD); CUTOFF:=COEF*(VINTER+VINTRA)*C; MF:=C-(H+L)/2+Typical()-Ref(Typical(),-1); FVE:=Sum(If(MF>CUTOFF, +V, If(MF <-CUTOFF, -V,0)),PERIOD)/Mov(V,PERIOD,S)/PERIOD*100; FVE Quote Link to comment Share on other sites More sharing options...
save2009 Posted August 17, 2009 Author Report Share Posted August 17, 2009 Re: [Req] Convert MetaStock code to MT4 More information. ^:)^ ^:)^ ^:)^ Please help http://mkatsanos.com/index_files/Page432.htm Quote Link to comment Share on other sites More sharing options...
⭐ fxknight Posted August 17, 2009 Report Share Posted August 17, 2009 Re: [Req] Convert MetaStock code to MT4 This concept is nothing more than the author's attempt to sell his book. You can check it out for yourself by downloading the ebook here: http://ifile.it/lavptmk/9780470758106.rar Enjoy! Quote Link to comment Share on other sites More sharing options...
save2009 Posted August 17, 2009 Author Report Share Posted August 17, 2009 Re: [Req] Convert MetaStock code to MT4 Thank fxknight for your book. Can you advice me I'm newbie on Metastock language? Quote Link to comment Share on other sites More sharing options...
save2009 Posted August 20, 2009 Author Report Share Posted August 20, 2009 Re: [Req] Convert MetaStock code to MT4 Hi All Still waiting for your help. ^:)^ ^:)^ Quote Link to comment Share on other sites More sharing options...
grandpost1 Posted March 17, 2012 Report Share Posted March 17, 2012 any programmer will do Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.