Is this possible ?

 

If I am using a Moving Average based on Closing Price. Is there a way for it to only compare the last two digits of the Indicator ?

For Example: We have the current Bar, We have the bar previous to that (Close1) and the bar previous to that one (Close2).

If Close1 = 1.2058 and Close2 = 1.2042

Is there a way to make an EA see Close1 = 58 and Close2 = 42 ?

The Main idea, would be so I could write something like.....

IF(Close1 >= 50 && Close2< 50)

....rest of the coding to open orders (I have this part down) :)

Thank you for any help.

 

Convert them to string -> strip the first 4 chars -> convert to int


it won't be very fast I'm afraid


or maybe this is better:

(1.2058 - (round(1.2058*100)/100))*1000

and

(1.2042 - (round(1.2058*100)/100))*1000


hth


Russell


--- edit --

fixed typo

 

Thank you Russell,

I am not infront of my Meta Trader...but just to make sure I understand the formula you provided:

(1.2058 - (round(1.2058*100)/100))*1000 = 58 ?

I tried to find an explination of the "round" command, but I couldnt find something that I understood, so I just wanted to clairify :)

Thank you again.

 

If Close1 = 1.2058 and Close2 = 1.2042

Is there a way to make an EA see Close1 = 58 and Close2 = 42 ?

int Close1 = MathMod(NormalizeDouble(1.2058, 4)*10000, 0);

int Close2 = MathMod(NormalizeDouble(1.2042, 4)*10000, 0);

 

yeah I wrote it in pseudo-code. But I guess Phy's solution will work just fine.


MathRound() would be the correct function...

 
phy wrote >>

int Close1 = MathMod(NormalizeDouble(1.2058, 4)*10000, 0);

int Close2 = MathMod(NormalizeDouble(1.2042, 4)*10000, 0);

If Close1 = 1.2058 and Close2 = 1.2042

Is there a way to make an EA see Close1 = 58 and Close2 = 42 ?

***CORRECTION***

int Close1 = MathMod(NormalizeDouble(1.2058, 4)*10000, 100);

int Close2 = MathMod(NormalizeDouble(1.2042, 4)*10000, 100);

Reason: