subtracting amount pips from variables

 

hi!

how subtract a price from variable?

If i want to subtract a variable with fixed amount of pips,

 how i have to write the amount of pips? that way- 0.000X or just subtract X pips from the variable?

this is how i wrote it:

if( ((O - C) < 0.00040) || ((C - O) < 0.00040) ) 

explenation: if open - close smaller than 4 pips.

have i wrote it correctly? 

 
elitrade:

hi!

how subtract a price from variable?

If i want to subtract a variable with fixed amount of pips,

 how i have to write the amount of pips? that way- 0.000X or just subtract X pips from the variable?

this is how i wrote it:

if( ((O - C) < 0.00040) || ((C - O) < 0.00040) ) 

explenation: if open - close smaller than 4 pips.

have i wrote it correctly? 

That depends on the Instrument you are trading,  it would be correct for EURUSD and incorrect for USDJPY.  Why not specify the number of points not pips and use something like this,  then it will work for EURUSD and USDJPY  . . .

 

extern int NumberOfPoints = 40;

if( ((O - C) < NumberOfPoints * Point ) || ((C - O) < NumberOfPoints * Point ) ) 
 
Or adjust pips to points so it works automatically on both a 4 and 5 digit broker and on all pairs (0.00040 assumes non-jpy/metals)
if( MathAbs(O - C) < nPips * pips2dbl) // Closer than nPips
 

thank tou very much for your help!

Reason: