Calculate Stoploss for 3 digit pairs (MQL5) [SOLVED]

 

Hi all,

Lets say you want to add 50 points stop loss to your position (EURUSD) and you calculate it like this

double MyStopLoss= Tick.bid+0.00050

how can I calculate same stoploss for USDJPY ? Somehow Multipliying it by 100 doesn't seem working.

thank you.


Answer

Just for others seeking the answer, The best answer is this simple

50* _Point

this approach normalize your point StopLoss for 3 and 5 digit pairs.

Basic Principles - Trading Operations - MetaTrader 5 Help
Basic Principles - Trading Operations - MetaTrader 5 Help
  • www.metatrader5.com
is an instruction given to a broker to buy or sell a financial instrument. There are two main types of orders: Market and Pending. In addition, there are special Take Profit and Stop Loss levels. is the commercial exchange (buying or selling) of a financial security. Buying is executed at the demand price (Ask), and Sell is performed at the...
 
        double Pip;
        int digits = (int)MarketInfo(_Symbol, MODE_DIGITS);
            
        if (digits % 2 == 1){ Pip = MarketInfo(_Symbol,MODE_POINT); Pip *= 10;} 
        else Pip = MarketInfo(_Symbol,MODE_POINT);  

        Bid - 50*Pip
 
Multiply the amount of points that you want for _Point

 
Fabio Cavalloni: Multiply the amount of points that you want for _Point
Using Point means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points,) and metals. Compute what a PIP is and use it, not points.
          How to manage JPY pairs with parameters? - MQL4 programming forum
          Slippage defined in index points - Currency Pairs - Expert Advisors and Automated Trading - MQL5 programming forum

PIP, Point, or Tick are all different in general.
          What is a TICK? - MQL4 programming forum
 
William Roeder:
Using Point means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points,) and metals. Compute what a PIP is and use it, not points.
          How to manage JPY pairs with parameters? - MQL4 programming forum
          Slippage defined in index points - Currency Pairs - Expert Advisors and Automated Trading - MQL5 programming forum

PIP, Point, or Tick are all different in general.
          What is a TICK? - MQL4 programming forum

If used a 4 digits broker Point=PIP (for all forex pairs)

Am I wrong?

I often use multiplying my SL/TP point for _Point predefined variable, of course I have to be aware of what _Point means for current symbol and broker.

 
  1. Fabio Cavalloni: If used a 4 digits broker Point=PIP (for all forex pairs)
    Of course. Did you read What is a TICK? - MQL4 programming forum

  2. Fabio Cavalloni: of course I have to be aware of what _Point means for current symbol and broker.
    Only if you use point and not PIP. What part of "code breaks" didn't you understand.
 

William Roeder:

Only if you use point and not PIP. What part of "code breaks" didn't you understand. 

    What do you mean with "code breaks"? The code that is not working as expected? Only if used without consciusness and without error handling.

     
    Fabio Cavalloni: What do you mean with "code breaks"?

    If you set it up for a 5 digit broker, your stops are 10 times bigger on a 4. You are risking 10X.

    If you set it up for a 4 digit broker, your stops are 1/10 the proper size on a 5. Instant stop out.

     
    Ferhat Mutlu:

    I was looking for the answer for mql5 not mql4

     
    Fabio Cavalloni:
    Multiply the amount of points that you want for _Point

    thanks a lot.

    Reason: