Download MetaTrader 5
To add comments, please log in or register
Download MQL5 library codes via MetaTrader. It is convenient!
mrwayne
252
mrwayne 2014.04.27 17:11 
   void Process()
   {
       
       .
       .
       int      TotalSpread ;
       .
       .


      for ( int x = HistoricalBars ; x >= 0 ; x-- )
         {
            .
            .
            TotalSpread = 0 ;
            .
            .



               for ( int y = 0 ; y < NumberOfPairs ; y++ )
               {
                  switch ( ImportList )
                  {
                     case 1  : TotalSpread += MarketInfo ( List[y] , MODE_SPREAD ) ;
                               break ;
                               



                                    .
                                    .
                                    .
                                    .
                                    .

                   }
                 }


                 .
                 .
                 .
                 FileWriteInteger ( Data , TotalSpread , INT_VALUE ) ;
            }



//finish void
}

At TotalSpread += MarketInfo ( List[y], MODE_SPREAD ) ;
it gives me an warning ( possible loss of data due to type of conversion ) when I compile it with strict property . It should be correct as I read the documentation MODE_SPREAD is an Integer type . Why is this happening ?

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.27 17:32  
You never try double instead of int ?
Keith Watford
Moderator
8009
Keith Watford 2014.04.27 17:40  
juniorlcq:

At TotalSpread += MarketInfo ( List[y], MODE_SPREAD ) ;
it gives me an warning ( possible loss of data due to type of conversion ) when I compile it with strict property . It should be correct as I read the documentation MODE_SPREAD is an Integer type . Why is this happening ?


MODE_SPREAD enumerates as an integer, but you are using the function MarketInfo and that returns a double
mrwayne
252
mrwayne 2014.04.27 17:43  
GumRai:

MODE_SPREAD enumerates as an integer, but you are using the function MarketInfo and that returns a double

Ohhhhhhhh, I see, now that make sense, how should I modify it to give no warning then ?
mrwayne
252
mrwayne 2014.04.27 17:44  
DoubleToInteger conversion ?

Edit : But there's no DoubleToInteger
Alain Verleyen
Moderator
28672
Alain Verleyen 2014.04.27 17:49  
juniorlcq:
DoubleToInteger conversion ?

Edit : But there's no DoubleToInteger

                     case 1  : TotalSpread += (int) MarketInfo ( List[y] , MODE_SPREAD ) ;
See Typecasting.
mrwayne
252
mrwayne 2014.04.27 17:56  
I tried TotalSpread += NormalizeDouble ( MarketInfo ( List[y], MODE_SPREAD ), 0 ) ; but still got warning .... NormalizeDouble turn Double type to Integer type isn't it ?
mrwayne
252
mrwayne 2014.04.27 17:57  
angevoyageur:

See Typecasting.

Strange I thought NormalizeDouble and MathRound which should also give no warning like ( int ) .... Why is ( int ) giving no warning but NormalizeDouble still gives warning, mind to explain to me @.@ ?
Alain Verleyen
Moderator
28672
Alain Verleyen 2014.04.27 18:18  
juniorlcq:

Strange I thought NormalizeDouble and MathRound which should also give no warning like ( int ) .... Why is ( int ) giving no warning but NormalizeDouble still gives warning, mind to explain to me @.@ ?
NormalizeDouble and MathRound still return a double. Please check documentation before asking the same question for all functions
mrwayne
252
mrwayne 2014.04.27 18:20  
angevoyageur:
NormalizeDouble and MathRound still return a double.

I'll stick to your suggestion with ( int ), seems like there's no other way of it ... Thanks a lot angevoyageur GumRai deysmacro

" mucks mucks mucks mucks mucks !! "
Alain Verleyen
Moderator
28672
Alain Verleyen 2014.04.27 18:55  
juniorlcq:

I'll stick to your suggestion with ( int ), seems like there's no other way of it ... Thanks a lot angevoyageur GumRai deysmacro

" mucks mucks mucks mucks mucks !! "

Perhaps you prefer this syntax :

  case 1  : TotalSpread += int(MarketInfo ( List[y] , MODE_SPREAD )) ;
/
To add comments, please log in or register