Warning

 

I have this code which ensures price is always rounded to the correct number of decimal points. It works fine but I keep getting the warning "implicit conversion from string to number". Is there anyway of performing the same function without getting this warning. If not, what could happen as a result of getting this warning repeatedly ? 


   string stopLossPrice(double SLPrice)
   {
      return DoubleToStr(SLPrice, Digits);
   }
 
luxecapital:

I have this code which ensures price is always rounded to the correct number of decimal points. It works fine but I keep getting the warning "implicit conversion from string to number". Is there anyway of performing the same function without getting this warning. If not, what could happen as a result of getting this warning repeatedly ? 

   string stopLossPrice(double SLPrice)
   {
      return DoubleToStr(SLPrice, Digits);
   }

Is this meant to be MQL4 or MQL5?

It appears to be MQL4, but if you are using it in MQL5 it will not work.

MQL5 does not have DoubleToStr, it's DoubleToString. Neither does it have Digits, it's _Digits or Digits().

 
Keith Watford #:

Is this meant to be MQL4 or MQL5?

It appears to be MQL4, but if you are using it in MQL5 it will not work.

MQL5 does not have DoubleToStr, it's DoubleToString. Neither does it have Digits, it's _Digits or Digits().

Yes its MQL4. Does anyone have any ideas? Thanks in advance

 
luxecapital #:

Yes its MQL4. Does anyone have any ideas? Thanks in advance

Maybe you are trying to edit/compile it in an MQL5 editor?


Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.

 
luxecapital:

I have this code which ensures price is always rounded to the correct number of decimal points. It works fine but I keep getting the warning "implicit conversion from string to number". Is there anyway of performing the same function without getting this warning. If not, what could happen as a result of getting this warning repeatedly ? 


My compiler does not Trigger an Error with the Code you shared.
Perhaps you passed a string to the parameter "double SLPrice"?
Meaning that the implicit conversion would be made in the Function Call and not the Function itself.
 
luxecapital:

I have this code which ensures price is always rounded to the correct number of decimal points. It works fine but I keep getting the warning "implicit conversion from string to number". Is there anyway of performing the same function without getting this warning. If not, what could happen as a result of getting this warning repeatedly ? 


Nothing wrong with the code 

As previous poster stated most likely you have passed a string value to the function rather than a double.

Check the line number the error is reported on in the compiler to get your answer.

Also, you have a habit of never replying so post back the answer otherwise people will lose interest in your questions...

 
Paul Anscombe #:

Nothing wrong with the code 

As previous poster stated most likely you have passed a string value to the function rather than a double.

Check the line number the error is reported on in the compiler to get your answer.

Also, you have a habit of never replying so post back the answer otherwise people will lose interest in your questions...

Think that's correct, I'm also getting a warning that the "declaration of 'SLPrice' hides global variable". Not sure what that means or how that must be solved. This is the code in full:


 double StopLossPrice()
   {// Buying Opportunities
      if(BullishCandlestick() == true && BullishHammer() == true)
      {
         SLPrice = (iClose(pair[0||1||2||3||4||5||6||7||8||9||10||11||12||13], TimeFrame[1 || 2 || 3], 1)) - (stopLossinPips * GetPipValue());
      }
      else if(BullishCandlestick() == false && BullishHammer() == true)
      {
         SLPrice = (iClose(pair[0||1||2||3||4||5||6||7||8||9||10||11||12||13], TimeFrame[1 || 2 || 3], 1)) - (stopLossinPips * GetPipValue());
      }
      return SLPrice;
   }

  double SLPrice = StopLossPrice(); 
  
  
   string stopLossPrice(double SLPrice)
   {
      return DoubleToStr(SLPrice, Digits);
   }
 
double click on the warning and it would take you to one of those lines with "double SLPrice". you need to change 1 of those value names. But you said that is the full code, but there is nothing that refers to the string function, therefore there is missing code from the above. Do not say it is full code unless it is "the full code". We arent dumb. :D.
 
Close(pair[0||1||2||3||4||5||6||7||8||9||10||11||12||13],
That code is utter bull crap. Zero is false and non-zero is one. Therefor your code is
Close(pair[1],
 
William Roeder #:
That code is utter bull crap. Zero is false and non-zero is one. Therefor your code is

Thanks

 
Revo Trades #:
double click on the warning and it would take you to one of those lines with "double SLPrice". you need to change 1 of those value names. But you said that is the full code, but there is nothing that refers to the string function, therefore there is missing code from the above. Do not say it is full code unless it is "the full code". We arent dumb. :D.

Anyone creating expert advisors aren't dumb. But if there's anyone on this forum who is, its me 🙃

Reason: