get the actual value of an ema

 

hi guys

I am new to this


i want get the actual value of an ema and subtract it from another value


what i cant figure out is how to get the numerical value

I am sure it is simple but i cannot find reference to it anywhere


thanks in advance

 

thanks raptor

but it was to complicated

i found this gave me what i was after


//---- get Moving Average2
ma2=iMA(NULL,0,55,0,MODE_SMA,PRICE_CLOSE,0);

Print ("mov ave 2 ",ma2);

which just prints it out in the journal


then i was able to add or subtract 2 of these

in hind site it seems obvious

but us newbies are dumb

 

The actual value of any indicator is in the data window just hover the mouse over the part of the chart you are interested in

 
Tradingjunky:

thanks raptor

but it was to complicated

You said it was too complicated then show your code using iMA ?

//---- get Moving Average2 
ma2=iMA (NULL,0,55,0,MODE_SMA,PRICE_CLOSE,0);
 
RaptorUK:

You said it was too complicated then show your code using iMA ?

this code

gives me the value of each ema

and then the last line subtracts one from the other

leaving "I" as the result

i think i can process this number to give the the information i wanted

Now i want to convert it to a whole number instead of a decimal and then compare that whole number to a setting


double i;
//---- get Moving Average
ma=iMA(NULL,0,fast,0,MODE_SMA,PRICE_CLOSE,0);
Print ("mov ave 1 ",ma);

//---- get Moving Average2
ma2=iMA(NULL,0,slow,0,MODE_SMA,PRICE_CLOSE,0);
Print ("mov ave 2 ",ma2);


i= ma-ma2;
Print ("total ",i);


I dont know if the print statements are necessary to make it work or not

but at this stage i was just happy to get a result I presume i got the result i was after



PS hope i make sense to you

regards

 
Tradingjunky:

PS hope i make sense to you

regards

Ah I see, you already had the MAs calculated . . .

Print does just that, it prints to the Experts/Journal tab . . . if you want to output to the screen you can use Comment instead, it will output on screen top left.

Comment("Total= ",i);

if you just want the whole part of i no decimals at all just do this . . .

int i;

instead of . . .

double i;

if you want i rounded to the nearest whole number so 1.5 ->2 and 1.49 - > 1 do this . . . .

double i;               //   <--------  keep this

i= MathRound( ma-ma2); 

Comment("Total= ",i);
 

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

double ma,ma2,ma3,multiplier=10000;
 //---- get Moving Average 
ma=iMA(NULL,0,fast,0,MODE_SMA,PRICE_CLOSE,0);
 Print ("mov ave 1 ",DoubleToStr(ma,Digits);

 //---- get Moving Average2 
ma2=iMA(NULL,0,slow,0,MODE_SMA,PRICE_CLOSE,0);
 Print ("mov ave 2 ",DoubleToStr(ma2,Digits);

ma3= NormalizeDouble((ma-ma2)*multiplier,0);               //will give value in pips so need to *10000
 Print ("total ",DoubleToStr(ma3,0);                //(example only for 4 digit broker) 


 
19730719:

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

I guess you are saying that what I posted was not type casting . . . I better do some reading . . .
 

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

 
RaptorUK:
I guess you are saying that what I posted was not type casting . . . I better do some reading . . .

well i am using the difference between the 2 emas


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


if it is a negative number i will remove the " - " sign before i multiply it

i am trying to get the difference of the 2 emas in pips

Reason: