Conversion of Flag Detection from Metastock 16

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #140145 quote
    scoot3r83
    Participant
    Average

    Hello,

    I obtained the following code from a Stocks and Commodities publication and have successfully used this on Metastock 16 for quite some time. I have attempted to transpose this Metastock Code to Pro Real Time V10.3 however I have failed to succeed in regards to the ZigZag function as V10.3 does not use arrays as I understand. Below is the filtering portion of the code and the PDF of the Stocks and Commodities document is attached.

    Detects Breakouts from Flags and Pennants

    Condition 1 Flag Duration
    Condition 2 Flag Pole
    Condition 3 Slope of Flag
    Condition 4 Volume
    Condition 5 Volitility
    Condition 6 Stochastics & Avg Directional Movement Index
    Condition 7 Money Flow AND FVE>10 AND Fml(“VFI”)>-3 {Condition 7}
    Condition 8 Price

    Filter

    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>0 {Condition 8}
    flags_amp_pennants_.pdf
    #140211 quote
    Nicolas
    Keymaster
    Master

    Added to my conversion list, please remind me if I still haven’t made it by August.

    scoot3r83 thanked this post
    #141304 quote
    Nicolas
    Keymaster
    Master

    Here is the translated code, apart from the VFI condition (VolumeFlowIndex is not an instruction in PRT) , it should run fine.

    percent = 5
    
    ZZ=ZigZag[percent](close)
    zzc = zz<zz[1] and zz[1]>zz[2]
    if zzc then
    startbar=barindex
    endif
    //X:=BarsSince(ZZ<Ref(ZZ,-1)AND Ref(ZZ,-1)>Ref(ZZ,-2));
    x = max(1,min(barindex-startbar,254))
    X1=X+1// {Flag Duration}
    X2=X1+1
    SD=Std[x2](Close)
    
    PERIOD=22
    COEF=1
    INTRA=Log(High)-Log(Low)
    VINTRA=Std[PERIOD](INTRA)
    INTER=Log(Typicalprice)-Log(Typicalprice[1])
    VINTER=Std[PERIOD](INTER)
    CUTOFF=COEF*(VINTER+VINTRA)*Close
    MF=Close-(High+Low)/2+Typicalprice-(Typicalprice[1])
    //FVE=Sum(If(MF>CUTOFF,+V, If(MF<-CUTOFF, -V,0)),PERIOD)/Mov(V,PERIOD,S)/PERIOD*100;
    FVE=0
    for i = 0 to PERIOD-1 do
    if MF[i]>CUTOFF[i] then
    fve=fve+volume
    endif
    if MF[i]<-CUTOFF[i] then
    fve=fve-volume
    endif
    next
    fve=fve/average[PERIOD](volume)/period*100
    
    C1 = X1<21 AND X1>2  //{Condition 1}
    C2 = (LinearRegressionSlope[13](close)[x1]/(Close[13+x1])*100)>2.2 //{Condition 2}
    C3 = (LinearRegressionSlope[x2](Close)[1]/(Close[X2+1]))*100<.2 AND LinearRegressionSlope[X1](close)/Close[X1]>-1.2//{Condition 3}
    C4 = (LinearRegressionSlope[x2](Volume)[1]/(Volume[X2+1]))*100<-2 //{Condition 4}
    C5 = (LinearRegressionSlope[X1](SD)[1])<0 //{Condition 5}
    C6 = Stochastic[20,3]>55 AND ADX[10]>30 //{Condition 6}
    C7 = FVE>10 //AND >-3 {Condition 7}
    C8 = Close>Close[1] AND Close>0 //{Condition 8}
    
    test = c1 and c2 and c3 and c4 and c5 and c6 and c7 and c8
    screener[test]
    scoot3r83 and qigley thanked this post
    #141424 quote
    scoot3r83
    Participant
    Average

    Thanks Nic. Much appreciated on the quick turnaround.

    qigley thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Conversion of Flag Detection from Metastock 16


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
scoot3r83 @scoot3r83 Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by scoot3r83
5 years, 6 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 07/26/2020
Status: Active
Attachments: 1 files
Logo Logo
Loading...