Problem with stop loss and target profit

 

Hi all


I have a very simple problem with my EA.


Could you help me solve it ?


Here is my problem.

int TakeProfit = 30;

double myprofit = Ask + TakeProfit * Point;


double ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, 0, myprofit, "Magic = " + Magic, Magic, 0, 0);


My EA works well with some brokers.


But problem with some brokers as forex.com, fxpro ...

Problem that sometimes my target profit = 30 pips, sometimes my target profit = 3 pips. I do not know why.


Please help me


Many thanks,

 
I guess because these brokers have 5 digits prices.
 
int TakeProfit = 30;
double myprofit = Ask + TakeProfit * Point;
double ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, 0, myprofit, "Magic = " + Magic, Magic, 0, 0);

The units of TakeProfit is PIPs. The unit of myprofit is real. On a five digit broker a point=1/10 pip. Likewise your slippage of 3, you want pips, but the unit is points. Either you must multiply your constants by ten when you're running on a five digit broker or the EA must.

//---- These are adjusted for 5 digit brokers.
double	pips2points	= 1,	//	slippage  3 pips	3=points	30=points
	pips2dbl; //	= Point //	Stoploss 15 pips	0.0015		0.00150
int	Digits.pips	= 0;	// DoubleToStr(dbl/pips2dbl, Digits.pips)
int init()
{
	pips2dbl	 = Point;
	if (Digits == 3 || Digits == 5) {
		pips2points *= 10;
		pips2dbl    *= 10;
		Digits.pips++;
}	}
//...
double myprofit = Ask + TakeProfit * pips2dbl;
double ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3*pips2points, 0, myprofit, "Magic = " + Magic, Magic, 0, 0);