implicit conversion from 'number' to 'string' warning - page 2

 
Oluwaseyi Olakojo:

Good morning house. please kindly help me, I have an indicator that displayed 33 warnings after compiling it, but I don`t have idea of what to change . I want to ask for permission before pasting it.

Thanks

You don't need permission to post, but start a new thread, and use Alt-S when pasting your code.

 

Hi I'm getting a warning - Implicit conversion to string

I have not been able to solve this warning - The indicator works but would like to have it warning free.

Any suggestions?

  GMaxDrawdown=AccountNumber()+"_MaxDrawdown";
   if (!GlobalVariableCheck(GMaxDrawdown)) GlobalVariableSet(GMaxDrawdown,0);
   GMaxPercentDD=AccountNumber()+"_GMaxPercentDD";
   if (!GlobalVariableCheck(GMaxPercentDD)) GlobalVariableSet(GMaxPercentDD,0);
   DrawdownTime=AccountNumber()+"_DrawdownTime";
   if (!GlobalVariableCheck(DrawdownTime)) GlobalVariableSet(DrawdownTime,0);
            //
            //
WorstDrawdown=GlobalVariableGet(GMaxDrawdown);
MaxPercentDD=GlobalVariableGet(GMaxPercentDD);
Drawdown=AccountEquity()-AccountBalance();

            
if (Drawdown<WorstDrawdown)
 {
  WorstDrawdown=Drawdown;
  GlobalVariableSet(GMaxDrawdown,WorstDrawdown);

 }
PercentDD=(MathAbs(WorstDrawdown)/AccountBalance())*100; 
if (PercentDD>MaxPercentDD)
 {
  MaxPercentDD=PercentDD;
  GlobalVariableSet(GMaxPercentDD,MaxPercentDD);
 }


if (WorstDrawdown<MaxDrawdown)
 {
  MaxDrawdown=WorstDrawdown;
 } 
PercentDD2=(MathAbs(MaxDrawdown)/AccountBalance())*100;
if (PercentDD2>MaxPercentDD)MaxPercentDD=PercentDD2;

     
 
Johannes Schoeman:

Hi I'm getting a warning - Implicit conversion to string

I have not been able to solve this warning - The indicator works but would like to have it warning free.

Any suggestions?

There's a line number to each warning, look that line up and examine the types of variables used - for example, if you have a = b * c, and 'a' is integer, while either b or c is double, and your 'a' cannot be double, then you'll need to change to something like a = int(b * c). 

 
Seng Joo Thio:

There's a line number to each warning, look that line up and examine the types of variables used - for example, if you have a = b * c, and 'a' is integer, while either b or c is double, and your 'a' cannot be double, then you'll need to change to something like a = int(b * c). 

These are the lines I'm getting the error on

   Line 452 - GMaxPercentDD=AccountNumber()+"_GMaxPercentDD"; 

   Line 454 - DrawdownTime=AccountNumber()+"_DrawdownTime";

---

Not sure what I have done now as I'm getting a uninitialized Variable "MaxDrawdown.

if (WorstDrawdown<MaxDrawdown)

Think that is easy enough to fix.

Surely there must be an easier way to get Drawdown

 
Johannes Schoeman:

These are the lines I'm getting the error on

   Line 452 - GMaxPercentDD=AccountNumber()+"_GMaxPercentDD"; 



Down to 1 Warning

 
Johannes Schoeman:

Down to 1 Warning

Try:

GMaxPercentDD=string(AccountNumber())+"_GMaxPercentDD"; 
 
Seng Joo Thio:

Try:

That has worked - Tried the same on the   GMaxDrawdown=string(AccountNumber())+"_MaxDrawdown";  but that still returns the Number to String warning
 
Johannes Schoeman:
That has worked - Tried the same on the   GMaxDrawdown=string(AccountNumber())+"_MaxDrawdown";  but that still returns the Number to String warning

Scratch that - I left the original string code line to copy text - it works and compile error free - Thanks so much

 

Hey Can someone have look into this for me. Having same issue.

if(!CheckOpenOrder(MagicNumber))

     {

      if(Ask >= LBBAND2 && Ask < UBBAND1 && MACDMAIN > MACDSIGNAL) //if price is between lower band 2 and upper band 1 and macd line above macd signal go long

        {


         Alert("Buy Now at "+ NormalizeDouble(Ask, Digits));

         Alert("Take Proft at "+ NormalizeDouble(UBBAND1, Digits));

         Alert("Stop Loss at "+ NormalizeDouble(LBBAND6, Digits));

         OrderId = OrderSend(MySymbol, OP_BUYLIMIT, LotSize, Ask, 10, NormalizeDouble(LBBAND6, Digits), NormalizeDouble(UBBAND1, Digits), NULL, MagicNumber);

         if(OrderId < 0)

            Alert("The Order Could Not Be Sent, ErrorCode: " + GetLastError());

        }

      else

         if(Bid <= UBBAND2 && Bid > LBBAND1 && MACDMAIN < MACDSIGNAL) //if price is between upper band 2 and lower band 1 and macd below signal go short

           {

            Alert("Sell Now at "+ NormalizeDouble(Bid, Digits));

            Alert("Take Proft at "+ NormalizeDouble(LBBAND1, Digits));

            Alert("Stop Loss at "+ NormalizeDouble(UBBAND6, Digits));

            OrderId = OrderSend(MySymbol, OP_SELLLIMIT, LotSize, Bid, 10, NormalizeDouble(UBBAND6, Digits), NormalizeDouble(LBBAND1, Digits), NULL, MagicNumber);

            if(OrderId < 0)

               Alert("The Order Could Not Be Sent, ErrorCode: " + GetLastError());

           }

      /*else

        {

         Alert("Hold Your Nerve");

        }*/

     }

 
Alvince YT: Hey Can someone have look
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor


  2. Don't Hijack other threads for your off-topic post. Next time, make your own, new, thread.

Reason: