moving average20- moving average50

 

hallo somebody can help me recently I've gone from metastock to Meta4
it is very simple formula fometastock, but i can not do that in meta4


a:= moving average 20 - moving average 50;
b: a- a(-1) a less previous bar a of 1 bar;
c: moving averge 20 of b;

thank for help

 
biandi wrote >>

hallo somebody can help me recently I've gone from metastock to Meta4
it is very simple formula fometastock, but i can not do that in meta4


a:= moving average 20 - moving average 50;
b: a- a(-1) a less previous bar a of 1 bar;
c: moving averge 20 of b;

thank for help


iMA is your friend ... https://docs.mql4.com/indicators/iMA ... :-)
double a=iMA(...20...,1)-iMA(...50...,1);
double c=iMA(...20...,2);
 
EADeveloper wrote >>


iMA is your friend ... https://docs.mql4.com/indicators/iMA ... :-)
double a=iMA(...20...,1)-iMA(...50...,1);
double c=iMA(...20...,2);


i know to write movingh averge less moving average but this result less bar behind it s the problem
a= ima(null,0,20,0,mode_sma,mode_close,0) -ima (null,0,50,0,mode_sma,mode_close,0);

b= a - bar behind a ???? a- a(-1) ???
this is a problem
 
biandi wrote >>


i know to write movingh averge less moving average but this result less bar behind it s the problem
a= ima(null,0,20,0,mode_sma,mode_close,0) -ima (null,0,50,0,mode_sma,mode_close,0);

b= a - bar behind a ???? a- a(-1) ???
this is a problem


ima(null,0,20,0,mode_sma,mode_close,1);
last number is bar shift .. 0 is the currend bar, 1 is the last closed bar before, 2 is 2 before ...
so .. a=ima(null,0,20,0,mode_sma,mode_close,0) and b=ima(null,0,20,0,mode_sma,mode_close,1) in your example

Reason: