# get the actual value of an ema - page 2

192

19730719:

can't get an integer from two doubles unless you cast it.

i dont understand what you have written

i list the results i want and the way I think I can do that in the reply to Raptor

17644

19730719:

nah, don't bother. just do like 'the offspring' says: gotta keep 'em seperated.

I find the documentation on type casting a little unclear . . . https://docs.mql4.com/basis/types/casting so I coded an elementary script . . .

```int start()
{
double ma1, ma2;
int i1;

ma1 = 2.70; ma2 = 1.10;
i1 = ma1 - ma2;

int i2 = ma1 - ma2;

Comment("ma1= ", ma1, " ma2= ", ma2, " i1= ", i1, " int i2=",i2 );
Print("ma1= ", ma1, " ma2= ", ma2, " i1= ", i1, " int i2=",i2 );

return(0);
}```

Looks OK to me . . .

17944

therefore the result is always a decimal eg 0.00100 = 100 pips

so to make it a whole number i will multiply it by 10000

Which will NOT work on a JPY pair or on a 4 digit broker. Don't hard code numbers.
```//++++ These are adjusted for 5 digit brokers.
int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int     init(){
if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
} else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
// OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
}
string  PriceToStr(double p){
string pFrc = DoubleToStr(p, Digits);       if(Digits.pips==0) return(pFrc);
string pPip = DoubleToStr(p, Digits-1);
if (pPip+"0" == pFrc)       return(pPip);           return(pFrc);          }
string  DeltaToPips(double d){
if (d > 0)  string sign = "+";  else    sign = "";
double pips = d / pips2dbl;
string dPip = sign + DoubleToStr(pips, 0);  if(Digits.pips==0) return(dPip);
string dFrc = sign + DoubleToStr(pips, Digits.pips);
if (dPip+".0" == dFrc)      return(dPip);           return(dFrc);          }
========
Comment("Difference = ",DeltaToPips(ma-ma2));
```
63

RaptorUK:

I find the documentation on type casting a little unclear . . . https://docs.mql4.com/basis/types/casting so I coded an elementary script . . .

Looks OK to me . . .

won't be the first time i've put the hoof in the mouth. but the documentation re is as clear as mud to me and didn't test.

so apologies for spreading such utter lies :)

17644

19730719:

won't be the first time i've put the hoof in the mouth. but the documentation re is as clear as mud to me and didn't test.

so apologies for spreading such utter lies :)

LOL . . . no need for apologies, but thank you all the same . . . I'm here to learn and now I know a little more about type casting than I did before. :-)
63

you're lucky, i'm still in the dark.

but imho it defeats the purpose a bit.