Download MetaTrader 5
To add comments, please log in or register
Download MetaTrader 5 for iPad and trade anywhere!
Mindexperiment
87
Mindexperiment 2014.05.09 09:02 

Hi there,


why if

double getDigits() {
    return MarketInfo( Symbol(), MODE_DIGITS );
}


getDigits() = 5


then

int start() {
        double prevClose = Close[1];
        double actOpen = Open[0];

        gapSize = ( actOpen - prevClose );
        Print( "Gap detect - Size: ", gapSize );
}


Prints -> "Gap detect - Size: 0"


Because prevClose and actOpen is 4 digits....

so for example 1.38157 - 1.38151 = 0 but should be 0.00006


I'm a bit confuse

Andy

honest_knave
970
honest_knave 2014.05.09 09:44  
What is gapSize cast as?
Mindexperiment
87
Mindexperiment 2014.05.09 09:47  
gapSize is double.. :) I omitted the definition
qjol
3243
qjol 2014.05.09 10:36  
Print( "Gap detect - Size: ", DoubleToString(gapSize, Digits));
Halley
198
Halley 2014.05.09 10:45  

( actOpen - prevClose ) is boolean. Remove parenthesis.

Mindexperiment
87
Mindexperiment 2014.05.09 12:17  

I found that


Print( "prevClose: ", prevClose );


is 1.3783...... so Close[1] is 4 digits...


I need 5digits, why I lost a digit?

Mindexperiment
87
Mindexperiment 2014.05.09 12:38  

The use of DoubleToString( gapSize, Digits ); only give: 0.00000


:/

Mindexperiment
87
Mindexperiment 2014.05.09 12:57  

Ok,

this works....


int start() {
        double prevClose = NormalizeDouble( Close[1], Digits );
        double actOpen = NormalizeDouble( Open[0], Digits );
        double range = prevClose - actOpen;

        Print( "prevClose = ", DoubleToString( prevClose, Digits ) );
        Print( "actOpen = ", DoubleToString( actOpen, Digits ) );
        Print( "range = ", DoubleToString( range, Digits ) );

        return(0);
}


but is fuckin' insane.

Alain Verleyen
Moderator
28699
Alain Verleyen 2014.05.09 18:50  
Mindexperiment:

Ok,

this works....



but is fuckin' insane.

Please watch your language and read the documentation before becoming rude.

Current build is 646, you are using an old build.

/
To add comments, please log in or register