Inquiry on Conversion of StopLoss and TakeProfit

 

Would just like to ask why in the following code:

void OnTick()
{
   double MyPoint;
   if(Digits==3 || Digits==5) MyPoint=Point*10;

, why the Point*10?

It was generated by a certain code generator. Mainly used to multiply the MyPoint to the inputted Take Profit to convert it into pips.

Thank you in advance!

 
Ibex Thales:

Would just like to ask why in the following code:

, why the Point*10?

It was generated by a certain code generator. Mainly used to multiply the MyPoint to the inputted Take Profit to convert it into pips.

Thank you in advance!

In a 5 digits broker 10 Points = 1 PIP
 
Ibex Thales:


, why the Point*10?


 Point and pip : 

 1 Point = 0.1 pip

and 10 Point = 1 pip

example in a 5 digits broker : 0.01009 = 100,9 pips = 1009 Point

 
Ibex Thales: It was generated by a certain code generator. Mainly used to multiply the MyPoint to the inputted Take Profit to convert it into pips.
  1. You have it backwards. Your TP input is in PIPs and you are converting it to a change in price for the OrderSend/OrderModify.
    Using Points 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 and MetaTrader 4 - MQL4 programming forum
              Slippage defined in index points - Currency Pairs - Expert Advisors and Automated Trading - MQL5 programming forum

  2. EA builder, EATree, fxDreema, FxPro, Online Forex Expert Advisor Generator, Quant, Visual Trader Studio, MQL5 Wizard, etc. are all the same. You will get something quick, but then you will spend a much longer time trying to get it right, than if you learned the language up front, and then just wrote it.

    • Since you haven't learned MQL4/5, therefor there is no common language for us to communicate.
      If we tell you what you need, you can't code it.
      If we give you the code, you don't know how to integrate it into yours.
      We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem, but we are not going to debug your hundreds of lines of code. You are essentially going to be on your own.

    • EA builder makes bad code counting up while closing multiple orders.
      EA builder makes bad code Bars is unreliable (max bars on chart) volume is unreliable (miss ticks) Always use time. New candle - MQL4 forum
      EA builder makes bad code, not adjusting for 4/5 digit brokers, TP/SL and slippage.
      EA builder makes bad code, not adjusting for ECN brokers. (pre-Build 500)
      EA builder makes bad code, not checking return codes.
      EATree uses objects on chart to save values - not persistent storage (files or GV+Flush.) No recovery (crash/power failure.)
    Learn to code it or or pay (Freelance) someone to code it.
 

Hi!

Been reading those book.mql4 sites. I think I am getting the gist of them, but I miss some of the finer details. Thank you for bearing with me though!

Would like some clarifications on the following:

1. The 1 Point = 0.1 PiP and 1 PiP = 10 Points only applies to 5-digit pairs and NOT to 3-digit pairs, right? But the way I understood

if(Digits==3 || Digits==5) MyPoint=Point*10;

is that if the decimal places displayed in the pair/instrument is either up to the 3rd or 5th decimal place, the code will multiply my inputted StopLoss and TakeProfits (in pips) by 10 (to make it a price). Did I miss something? Can't I just add Digits ==4, Digits ==6, et cetera, and it will work out just as well?

2. If it is 1 Point = 0.1 PiP for 5-digit brokers, isn't it 1 Point = 1 PiP for 3-digit brokers? Thus, the abovementioned code can be written as:

if(Digits==5) 
{
   MyPoint=Point*10;
}
else
{
   if (Digits==3)
   {
      MyPoint=Point*1;
   }
}

Why is it not the case?

Thank you once again for your patience. I may be slow in my absorbing some details since codes are some of the farthest things from my native field of work. :))

 
Oh I see your confusion, even though we say 5 digits broker it is a common term use classify brokers who offer price feeds with extra digit accuracy. 
So for yen pairs 3 digits are given by 5 digits broker(common term), all the other currency symbols have 5 digits in 5 digits broker.

In a 4 digits broker , yen pairs have 2 decimal places and other pairs have 4 digits(after ".")

Example :- USDJPY ==> 112.132 (5 digits broker) & 112.13(4 digits broker)

EURUSD ==> 1.12435 (5 digits broker) and 1.1243 ( 4 digits broker)
 
Lakshan Perera:
Oh I see your confusion, even though we say 5 digits broker it is a common term use classify brokers who offer price feeds with extra digit accuracy. 
So for yen pairs 3 digits are given by 5 digits broker(common term), all the other currency symbols have 5 digits in 5 digits broker.

In a 4 digits broker , yen pairs have 2 decimal places and other pairs have 4 digits(after ".")

Example :- USDJPY ==> 112.132 (5 digits broker) & 112.13(4 digits broker)

EURUSD ==> 1.12435 (5 digits broker) and 1.1243 ( 4 digits broker)

1. I see. So in my formula

if(Digits==5 || Digits==3)

the 3 refers to JPY pairs while the 5 refers to all other pairs, right?

2. Is my understanding of the below statement correct? 

A pip = 0.01 for JPY and = 0.0001 for other pairs. But since 5-digit brokers offer another level of accuracy by adding another decimal place, the 50 pips inputted for StopLoss will just mean 5 pips, so it is multiplied by 10.

3. But why will Point() break down on exotics? The way I understand it, as whroeder has stated, stop losses are take profits are entered in pips. Then, they are converted to prices (x10, as the above statement states), added to the Bid/Ask, as the case may be, to generate the stop loss and take profit level.