Download MetaTrader 5
To add comments, please log in or register
Millions of traders download codes from MQL5 library. Share your app with them!
rod178
276
rod178 2014.10.27 05:33 

why does the following line of code produce these two warning messages -

"implicit conversion from 'string' to 'number' "

"implicit conversion from 'number' to 'string' "   


Also it returns a value (Price) of 0.0, despite the Trendline ("test2a") intersecting m15 Time[1] 

Print(ObjectGetValueByTime("test2a",Time[1],0));
whroeder1
13620
whroeder1 2014.10.27 13:54  
rod178: why does the following line of code produce these two warning messages -
Print(ObjectGetValueByTime("test2a",Time[1],0));

"implicit conversion from 'string' to 'number' "

"implicit conversion from 'number' to 'string' "   

Also it returns a value (Price) of 0.0, despite the Trendline ("test2a") intersecting m15 Time[1]

  1. No idea, probably code not posted.
  2. OGVBT returns a double, so you have Print(aDouble). Print requires a string so the double must be implicitly converted.
  3. All code not posted. Probably a typeo on the name (case matters.) Don't duplicate code, write it once:
    const string tlName2 = "test2a";
    :
       CreateTL(tlName2, ...);
    :
       double tl2Value = ObjectGetValueByTime(tlName2,Time[1],0);
       Print( DoubleToString(tl2Value) );
rod178
276
rod178 2014.10.27 14:25  
WHRoeder:
rod178: why does the following line of code produce these two warning messages -

"implicit conversion from 'string' to 'number' "

"implicit conversion from 'number' to 'string' "   

Also it returns a value (Price) of 0.0, despite the Trendline ("test2a") intersecting m15 Time[1]

  1. No idea, probably code not posted.
  2. OGVBT returns a double, so you have Print(aDouble). Print requires a string so the double must be implicitly converted.
  3. All code not posted. Probably a typeo on the name (case matters.) Don't duplicate code, write it once:

Well, here is the code in its entirety . Print usually performs automatic type conversion. Nevertheless I added DoubleToString and it still produces the same warnings

//+------------------------------------------------------------------+
//|                                                         test.mq4 | 
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property version   "1.00"
#property strict
//#property script_show_inputs
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{

   Print(DoubleToString(ObjectGetValueByTime("test2a",Time[1],0),4));   
}

 

 

 

PS  Furthermore this returns a value of 2, which is OBJ_TREND

Print("****object type integer ",ObjectType("test2a"));
/
To add comments, please log in or register