Trend Continuation Factor - Multiple Timeframes (TCF MTF)

baraozemo

Trader
Dec 19, 2017
14
1
24
Brazil
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
 

Attachments

  • tcf - mtf nmc.mq5
    14.9 KB · Views: 49
  • tcf - mtf nmc.mq4
    7.5 KB · Views: 71
  • tcf - mtf nmc.png
    tcf - mtf nmc.png
    221.2 KB · Views: 162

baraozemo

Trader
Dec 19, 2017
14
1
24
Brazil
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:

baraozemo

Trader
Dec 19, 2017
14
1
24
Brazil
for example... I don't know how to "simulate" the shift of MT4 in MT5 conversion..

Code:
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)
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,532
1,355
144
Odesa
www.earnforex.com
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:

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:

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:

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.
 

baraozemo

Trader
Dec 19, 2017
14
1
24
Brazil
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: