Need 2 Indicators

Discussion in 'Forex' started by sukhen, Jan 1, 2009.

  1. sukhen


    Can anybody please post the codes or ex4 in MQL of MT4 for
    1) Directional Movement (ADX, DI+ and DI-) and
    2) Triple Exponential Average or TRIX
    in the same line of VT of CMS.

    Thank you in advance

    Wish everybody a Happy New Year

    - Sukhen

    The code of VT (which is similar to MetaStock also) of Directional Movement is
    TH:= if(Ref(C,-1)>H,Ref(C,-1),H);
    TL:= if(Ref(C,-1)<L,Ref(C,-1),L);
    TR:= TH-TL;

    PlusDM:= if(H>Ref(H,-1) AND L>=Ref(L,-1), H-Ref(H,-1),
    if(H>Ref(H,-1) AND L<Ref(L,-1) AND H-Ref(H,-1)>Ref(L,-1)-L, H-Ref(H,-1),

    PlusDI:= 100 * Wilders(PlusDM,Pr)/Wilders(Tr,Pr);

    MinusDM:= if(L<Ref(L,-1) AND H<=Ref(H,-1), Ref(L,-1)-L,
    if(H>Ref(H,-1) AND L<Ref(L,-1) AND H-Ref(H,-1)<Ref(L,-1)-L, Ref(L,-1)-L,

    MinusDI:= 100 * Wilders(MinusDM,Pr)/Wilders(Tr,Pr);

    DIDif:= Abs(PlusDI-MinusDI);
    DISum:= PlusDI + MinusDI;

    _ADX:= 100 * Wilders(DIDif/DISum,SmPr);
    _ADXR:= (_ADX + Ref(_ADX,1-SmPr)) / 2;

    Final_ADX:= if(cT=0,_ADX,_ADXR);


    and the code for for TRIX is like
    MA1:= mov(mapr,maper,E);
    MA2:= mov(ma1,maper,E);
    MA3:= mov(ma2,maper,E);

    _TRIX:= (MA3-ref(MA3,-1))/ref(MA3,-1);
    TRIX_Signal:= mov(_TRIX,TRIXper,E);