Calculation Pips Difference between Indicator and Close

 

I would like to calculate the „Pips“ difference between a indicator and the Close.

The Parameters which I need for my calculation (in my opinion)

1. Breakout indicator (Support/ Resistance)

2. Close Course

My Try in code it works:

      //Initizilation (BarClose)
      double BarClose=iClose(Symbol(),PERIOD_CURRENT, i);     
      
      //Initizilation (iCustom)
      double Resistance=iCustom(Symbol(), PERIOD_CURRENT, "Support and Resistance (Barry)", 0, i);
      double Support=iCustom(Symbol(), PERIOD_CURRENT, "Support and Resistance (Barry)", 1, i);      
      
      //Calculation PipsDifference
      double diffToResistance = Resistance - BarClose;
      double diffToSupport = BarClose - Support;
      
      if(Close[i] < Resistance && Close[i] > Support && (diffToSupport*10000)<2){ // 2 = Pips
         upArrow[i]=Low[i]-2.9*myPoint;
      }
      
      if(Close[i] > Support && Close[i] < Resistance && (diffToResistance*10000)<2){ // 2 Pips
         downArrow[i]=High[i]+2.9*myPoint;
      }  

My Problem with my Code:

(diffToSupport*10000)<2

(diffToResistance*10000)<2

At the moment it only works with the EURUSD and Pairs which has following decimals 1.1111

I need to multiplicate the result with „10000“ to get the Pips a 1,2,3


My Question is there a (I*m sure“) to calculate that better?


And my second Question do I need to setup the calculation formula for every pair or is it possible

To calculate the difference within one function for every pair?  

 
noSkill06s:


Support && (diffToSupport)< 20*Digits() ){ // 2 = Pips
 
Vitaly Muzichenko #:

thx bro it worked, but not with "Digits()" i coded following 


   //Decimal Point Calculation
   double myPoint = Point()
   if(Digits()==5 || Digits()==3){
      myPoint *= 10;
   }

my solution for others in future who will face the same problem maybe

 
noSkill06s: My Problem with my Code:

(diffToSupport*10000)<2

(diffToResistance*10000)<2

Don't hard code numbers.  Fails on all JPY pairs.

Difference in points
(assuming a 5 digit broker).
diffToSupport/_Point < 20

diffToResistance/_Point < 20
Difference in PIPs.
diffToSupport/PIP < 2

diffToResistance/PIP < 2
Difference less than 2 PIPs
diffToSupport < 2 * PIP

diffToResistance < 2 * PIP

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

Unless you manually adjust your SL/TP for each separate symbol, 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 (2017)
          Slippage defined in index points - Expert Advisors and Automated Trading - MQL5 programming forum (2018)

 
Vitaly Muzichenko #:
Support && (diffToSupport)< 20*Digits() ){ // 2 = Pips

20*5=100 is not the definition of a PIP.