in my expert i want the distance between (open price-EMA)*2 for take profit?how can i do this in mql4?
i use this formula for buy position but it does not work
Ask+((Bid-EMA)*2)
in my expert i want the distance between (open price-EMA)*2 for take profit?how can i do this in mql4?
i use this formula for buy position but it does not work
Ask+((Bid-EMA)*2)
Your question references Open Price, but you are using Bid, this is incorrect. You should be using something like the following
int ema_period=20;
double EMA=iMA(NULL,0,ema_period,0,MODE_EMA,PRICE_CLOSE,0);
double take_profit=Ask+MathAbs(iOpen(NULL,0,0)-EMA)*2;
You should also check that your take profit is far enough away from the current price to be accepted by the trade server (using MarketInfo(NULL, MODE_STOPLEVEL)).