tcf - mtf nmc

Discussion in 'MetaTrader Indicators' started by baraozemo, Dec 23, 2017.

  1. baraozemo

    baraozemo Trader

    6
    1
    13
    Hi,

    I got this "tcf - mtf nmc.mq4" indicator from MT4
    and I started the conversion to mt5, but I can't finish it...

    need help to finish the conversion to mt5.

    tks

    Zemo
     

    Attached Files:

  2. Enivid

    Enivid Administrator Staff Member

    7,174
    226
    94
    Why can't you finish it?
     
  3. baraozemo

    baraozemo Trader

    6
    1
    13
    some mt4 indicators I can't convert, anothers sometime I have doubts about some functions and how make it.
    for example the mentioned indicator I get stuck in the plot.... the original has more lines and my conversion only display one line
     
    Last edited: Dec 24, 2017
  4. baraozemo

    baraozemo Trader

    6
    1
    13
    for example... I don't know how to "simulate" the shift of MT4 in MT5 conversion..

    Code (Text):

    double prev_fast_ma,prev_slow_ma,fast_ma,slow_ma;

    MT4 code
    int start()
    {
    prev_fast_ma=iMA(Symbol(),0,Fast_MA_Period,0,MA_Method,PRICE_CLOSE,2);
    prev_slow_ma=iMA(Symbol(),0,Slow_MA_Period,0,MA_Method,PRICE_CLOSE,2);
    fast_ma=iMA(Symbol(),0,Fast_MA_Period,0,MA_Method,PRICE_CLOSE,1);
    slow_ma=iMA(Symbol(),0,Slow_MA_Period,0,MA_Method,PRICE_CLOSE,1);
    }

    MT5 converted code
    int OnInit()
      {
    prev_fast_ma=iMA(Symbol(),0,Fast_MA_Period,0,MA_Method,PRICE_CLOSE,???);
    prev_slow_ma=iMA(Symbol(),0,Slow_MA_Period,0,MA_Method,PRICE_CLOSE,???);
    fast_ma=iMA(Symbol(),0,Fast_MA_Period,0,MA_Method,PRICE_CLOSE,???);
    slow_ma=iMA(Symbol(),0,Slow_MA_Period,0,MA_Method,PRICE_CLOSE,???);
    }
     
    if I use the "???" =2 or 1 I a got error (wrong parameters)
     
  5. Enivid

    Enivid Administrator Staff Member

    7,174
    226
    94
    Getting indicator values is completely different in MQL5. First, you have to create an indicator handle for each MA you will be using. Like this, for example:

    Code (MQL5):
    int fast_ma_handle = iMA(Symbol(),0,Fast_MA_Period,0,MA_Method,PRICE_CLOSE);
    Then, you need to copy the MA values into a buffer:

    Code (MQL5):
    double Fast_MA_Buffer[];
    CopyBuffer(fast_ma_handle, 0, 0, count, Fast_MA_Buffer);
    And only then, you can access the MA value at some specific shift via the buffer:

    Code (MQL5):
    prev_fast_ma = Fast_MA_Buffer[2];
    I suggest studying the help file on CopyBuffer() and iMA() in MQL5 Editor to get all the necessary information about the process.
     
  6. baraozemo

    baraozemo Trader

    6
    1
    13
    Enivid , tks for the reply..

    yes, I know how to work with buffers, I have mt5 eas working good with this..

    my question is how to simulate the last parameter "shift" that you have in the iMA of the MT4
    using mt5... I dont know what is the correct approach to get the same "result"....

    for example. the MT4 (the last part ) has Shift=2 and Shift=1

    I don't know how get this in MT5 with the same RESULT.

    PRICE_CLOSE,2 (2=Shift 2)
    PRICE_CLOSE,1 (1=Shift 1)

    for example:
    mt4 code
    iMA(Symbol(),0,Fast_MA_Period,0,MA_Method,PRICE_CLOSE,2) // 2=> shift 2

    how get this same result in mt5 ?
    iMA(Symbol(),0,Fast_MA_Period,0,MA_Method,PRICE_CLOSE) // what is the last parameter shift? is the same "ma shift" ? i don't know
     
    Last edited: Jan 8, 2018
  7. baraozemo

    baraozemo Trader

    6
    1
    13
    ok tks i finally read carefully... lol

    I use the "shift" in copybuffer...
     
    Enivid likes this.

Share This Page