Calculation of SL and TP for several Broker (4-digit vs. 5-digit)

 

I try to make my EAs fit for 4-digit AND 5-digit Broker. Currently I use 5 Digit Broker

Lets Assume I have StopLoss 20 and TakeProfit = 60.

This is my current Calculation:

int StopLoss = 20;
int TakeProfit = 60; 

double tp = Ask + TakeProfit*myPoint; double sl = Ask - StopLoss*myPoint; // BUY
double tp = Bid + TakeProfit*myPoint; double sl = Bid - StopLoss*myPoint; // SELL

myPoint will be calculated this way:

double myPoint; 

if (Digits < 4) myPoint = 0.01;
else myPoint = 0.0001;  

Am I correct or how should I do the calculation to make the EA available for 4 and 5 digit Broker?

thanks in advance. 

 
fx_maddin:

I try to make my EAs fit for 4-digit AND 5-digit Broker. Currently I use 5 Digit Broker

Lets Assume I have StopLoss 20 and TakeProfit = 60.

This is my current Calculation:

myPoint will be calculated this way:

Am I correct or how should I do the calculation to make the EA available for 4 and 5 digit Broker?

thanks in advance. 

You are applying the same calculation for 4/5 digit pairs on 4/5 Digit Brokers,  for example, GBPUSD ,  that is incorrect  . . . .   you should ideally also consider non-Forex instruments.
 
Your EA must adjust for 4/5 digit brokers. Pips (tp, sl) and Points (Slippage) See https://www.mql5.com/en/forum/141509
 

Thanks for your answers, but I am still confused.

On 5-Digit-Broker I Set TP=60 & SL=20.

Should I set TP=6 & SL=2 on 4-Digit-Broker?

 

WHRoeder:
Your EA must adjust for 4/5 digit brokers. Pips (tp, sl) and Points (Slippage) See https://www.mql5.com/en/forum/141509

I don't understand the calculation in your Link :-( 

 
fx_maddin:

Thanks for your answers, but I am still confused.

On 5-Digit-Broker I Set TP=60 & SL=20.

Should I set TP=6 & SL=2 on 4-Digit-Broker?

Yes,  you should,  if you want a TP of 6 pips and a SL of 2 pips . . . .  you never actually said what 6 & 2 were meant to be.

This was your code . . .

double myPoint; 

if (Digits < 4) myPoint = 0.01;
else myPoint = 0.0001;  

 taking GBPUSD as an example:  on a 4 digit Broker it will have 4 digits, on a 5 digit Broker it will have 5 digits . . . but as the number of digits is not less than 4 in both cases you treat it the same and you would set myPoint to be 0.0001 in both cases.

What specifically don't you understand about  WHRoeder's  code ?  you would be well served to take some time and go through it line by line until you do understand it.

 

Thanks for your help. Lets clarify:

5-Digit-Broker:

TP = 60; SL = 20; CurrentBuyPrice = 1.27840;

Stop Loss should be 1.27820;

Take Profit should be 1.27900;

 

4-Digit-Broker:

TP = 6; SL = 2; CurrentBuyPrice = 1.2784;

Stop Loss should be 1.2782;

Take Profit should be 1.2790;

 

On both brokers should I earn 60USD with 1Lot or Loss 20USD.

Am I right? 

 
fx_maddin:

Thanks for your help. Lets clarify:

You still haven't clarified what 6 & 2 represent,  but I'll assume you mean Pips . . .

If you had a Broker with zero Spread then you would earn 6 pips or lose 2 pips . . .  as for how many USD you would earn/lose, well that depends on the currency pair you were trading . . . .   it makes a difference for non XXXUSD  pairs when your account currency is USD.

When placing trades you have to be careful not to place your TP & SL not too close to current prices . . .   you need to comply with the requirement spelled out in this article,  otherwise you will get errors and failed  OrderSend() and OrderModify() :  Requirements and Limitations in Making Trades

 
Yes I mean pips. I think it is clear for me now. Thanks again.
 
fx_maddin:
Yes I mean pips. I think it is clear for me now. Thanks again.


Is it ???

Look also to the Slippage  in your OrderSend() function

Reason: