Download MetaTrader 5

External Integer miscalculation; Is it a problem of compiler?

To add comments, please log in or register
Register as a seller and start making profit!
Micky
58
Micky 2010.08.16 09:48 

I made a simple test indicator.

//+------------------------------------------------------------------+
//|                                                    testInput.mq5 |
//+------------------------------------------------------------------+
#property indicator_chart_window
//---
input   int     InpINT_Plus_10      = +10;
input   int     InpINT_Minus_10     = -10;
input   long    InpLONG_Plus_10     = +10;
input   long    InpLONG_Minus_10    = -10;
        int     ExtINT_Plus_10      = +10;
        int     ExtINT_Minus_10     = -10;
//---
int OnInit() { return(0); }
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
   if (prev_calculated > 0) return(rates_total);
//---
   int intPlus_10  = +10;
   int intMinus_10 = -10;
//---
   Print(" Time Current + +10 * 3600 = ", datetime(TimeCurrent() + +10 * 3600));
   Print(" Time Current + intPlus_10 * 3600 = ", datetime(TimeCurrent() + intPlus_10 * 3600));
   Print(" Time Current + ExtINT_Plus_10 * 3600 = ", datetime(TimeCurrent() + ExtINT_Plus_10 * 3600));
   Print(" Time Current + InpINT_Plus_10 * 3600 = ", datetime(TimeCurrent() + InpINT_Plus_10 * 3600));
   Print(" Time Current + InpLONG_Plus_10 * 3600 = ", datetime(TimeCurrent() + InpLONG_Plus_10 * 3600));
   Print(" ExtINT_Plus_10 * 3600 = ", ExtINT_Plus_10 * 3600);
//---
   Print(" Time Current + -10 * 3600 = ", datetime(TimeCurrent() + -10 * 3600));
   Print(" Time Current + intMinus_10 * 3600 = ", datetime(TimeCurrent() + intMinus_10 * 3600));
   Print(" Time Current + ExtINT_Minus_10 * 3600 = ", datetime(TimeCurrent() + ExtINT_Minus_10 * 3600));
   Print(" Time Current + InpINT_Minus_10 * 3600 = ", datetime(TimeCurrent() + InpINT_Minus_10 * 3600));
   Print(" Time Current + InpLONG_Minus_10 * 3600 = ", datetime(TimeCurrent() + InpLONG_Minus_10 * 3600));
   Print(" ExtINT_Minus_10 * 3600 = ", ExtINT_Minus_10 * 3600);
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Results are like this:
testInput (EURUSD,M5) 14:32:48  Time Current + +10 * 3600 = 2010.08.16 17:32:34
testInput (EURUSD,M5) 14:32:48  Time Current + intPlus_10 * 3600 = 2010.08.16 17:32:34
testInput (EURUSD,M5) 14:32:48  Time Current + ExtINT_Plus_10 * 3600 = 2010.08.16 17:32:34
testInput (EURUSD,M5) 14:32:48  Time Current + InpINT_Plus_10 * 3600 = 2010.08.16 17:32:34
testInput (EURUSD,M5) 14:32:48  Time Current + InpLONG_Plus_10 * 3600 = 2010.08.16 17:32:34
testInput (EURUSD,M5) 14:32:48  ExtINT_Plus_10 * 3600 = 36000
testInput (EURUSD,M5) 14:32:48  Time Current + -10 * 3600 = 2010.08.15 21:32:34
testInput (EURUSD,M5) 14:32:48  Time Current + intMinus_10 * 3600 = 2010.08.15 21:32:34
testInput (EURUSD,M5) 14:32:48  Time Current + ExtINT_Minus_10 * 3600 = 2146.09.22 04:00:50    <<< miscalculation of time
testInput (EURUSD,M5) 14:32:48  Time Current + InpINT_Minus_10 * 3600 = 2146.09.22 04:00:50    <<< miscalculation of time
testInput (EURUSD,M5) 14:32:48  Time Current + InpLONG_Minus_10 * 3600 = 2010.08.15 21:32:34
testInput (EURUSD,M5) 14:32:48  ExtINT_Minus_10 * 3600 = -36000

Result times of ExtINT_Minus_10 and InpINT_Minus_10 are miscalculated,
otherwise the form of my code may be something wrong...

Alexey Da
Moderator
6606
Alexey Da 2010.08.16 12:35  

Thank you for message.

Wait for the next build. 

Micky
58
Micky 2010.08.16 13:31  

OK. I'll wait for update.

To add comments, please log in or register