Global variable warning - page 2

 
jsc #:

Not sure if you understood what I meant. How would I replace what I currently have as my StopLoss (stopLossPrice(SLPrice)) so the warning " implicit conversion from number to string" doesn't appear

I've obviously tried stopLossPrice(SLPrice)/ stopLossPrice(_SLPrice)/ stopLossPrice(double _SLPrice) but they don't wor?

I understand that however I haven't been able to find a solution to this issue independently. Do you have ideas as to how best solve this ?

I tried changing it to a double instead of string which got rid of all errors aside from one crucial one. 

 double stopLossPrice(double _SLPrice)
   {
      return DoubleToStr(_SLPrice, Digits);
   }

Now its saying  " implicit conversion from string to number". The error takes me to where I've added ***

double stopLossPrice(double _SLPrice)
   {
      return ***DoubleToStr(_SLPrice, Digits);
   }


How can I keep this as a double??


Thank you!!

 
You need to go ahead and read about data types.


You are using a function to change a double into a string, then you force the function to return this string as a double?

Where is the sense in this?

Think of what you are doing, and why you are doing it.

Every step in a program has a cause to achieve a goal.


 
jsc:

I am getting the warning "declaration of 'SLPrice' hides global variable". (When I click on the error it takes me to where I've added ***). Pretty sure this warning leads to another one as I input my stop loss as "stopLossPrice(SLPrice)". The subsequent warning is as follows: "implicit conversion from number to string". Think solving the first issue will help with the second. Ive looked online for hours yet still unsure how to solve this problem. Appreciate everyone's help in advance!


bonkers...   

we have already been around this with you in your other thread  https://www.mql5.com/en/forum/384612

all you've done is changed your name and started a new thread...

why keep asking the same question..

Warning
Warning
  • 2021.12.22
  • www.mql5.com
I have this code which ensures price is always rounded to the correct number of decimal points...
 
jsc #:

I understand that however I haven't been able to find a solution to this issue independently. Do you have ideas as to how best solve this ?

I tried changing it to a double instead of string which got rid of all errors aside from one crucial one. 

Now its saying  " implicit conversion from string to number". The error takes me to where I've added ***


How can I keep this as a double??


Thank you!!

I have deleted your new topic as it is basically the same as this one.

The answer is quite simple.

Do not attempt to assign string values to double variables/arrays.
Do not attempt to assign double values to string variables/arrays.

Do not attempt to return string values from double functions.

Do not attempt to return double values from string functions.

 

I have deleted another new topic of yours concerning issues that you have already been told about in this topic.

Do not keep opening unnecessary new topics!

Reason: