Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 495

 
rustein:

The terminal has updated from 509 to 600 and the EA gives this warning on compilation:

declaration of 'ErrNum' hides global declaration at line 81

and a part of the code:

Can you please tell me what the problem is?

You have ErrNum declared globally. A variable with the same name inside the function hides the value of the global variable. In the function, give a different name
 

Thanks, so changed ErrNum to ErrNumber and that's it? The warning is gone, everything will work correctly?

string ErrorDescription(int ErrNumber)
{
  switch(ErrNum)
  {
    case 0: return("NO ERROR");
    case 1: return("NO RESULT");                                 
    case 2: return("COMMON ERROR");                              
    case 3: return("INVALID TRADE PARAMETERS");                  
    case 4: return("SERVER BUSY");                               
    case 5: return("OLD VERSION");                               
    case 6: return("NO CONNECTION");                             
    case 7: return("NOT ENOUGH RIGHTS");   
 
Great, thank you so much again.

And one last warning in the code:

not all control paths return a value

double FractalUp()
{
  if(iCustom(Symbol(),0,"SR",FractalRange,false,1,2,TradeBar) != EMPTY_VALUE)  
  return(iCustom(Symbol(),0,"SR",FractalRange,false,1,2,TradeBar));
}

Can you tell me what's wrong here too, please.

 
rustein:
Great, thank you so much again.

And one last warning in the code:

not all control paths return a value

Can you tell me what's wrong here too, please.

If the condition is fulfilled, the function returns a value.

Otherwise, there is no return from the function. Return some default value from the function

 
hehe :),

did so and the warning disappeared:

double FractalUp()
{
  if(iCustom(Symbol(),0,"SR",FractalRange,false,1,2,TradeBar) != EMPTY_VALUE)
  {
    return(iCustom(Symbol(),0,"SR",FractalRange,false,1,2,TradeBar));
  }
  else return (0);
}

hope that's good, life in mt4 goes on :), thanks again!

 
rustein:
hehe :),

did so and the warning disappeared:

hope that's good, life in mt4 goes on :), thanks again!

You're welcome.
 

Guys, there are 4 simple self-made functions, apparently there is a bug in them. Please help a beginner!

(The name of each function speaks for itself, what this function should do)

extern double LOT =0.1;


double GetLastOrderProfit()
{
  int time = 0; double profit = 0; 
  for(int i = OrdersHistoryTotal()-1; i>=0; i--)
  {
    if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
    {
      if(OrderSymbol() == Symbol()&& OrderMagicNumber() == Magic)
      {
        if(time<OrderCloseTime())
        {
          time=OrderCloseTime();
          profit=OrderProfit();
        }
      }
    }
  }
  return(profit);
}

//+------------------------------------------------------------------+
double GetLastLot()
{
  int time = 0; double Lot = 0; 
  for(int i = OrdersHistoryTotal()-1;i>=0;i--)
  {
    if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
    {
      if(OrderSymbol() == Symbol()&& OrderMagicNumber() == Magic)
      {
        if(time<OrderCloseTime())
        time=OrderCloseTime();
        Lot = OrderLots(); 
      }
    }
  }

  if(Lot <= 0) Lot = LOT;

  return(Lot);
}

//+------------------------------------------------------------------+
double GetLastTenOrdersProfit()
{
  double profit = 0; int count = 0; 
  for(int i = OrdersHistoryTotal()-1;i>=0;i--)
  {
    if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
    {
      if(OrderSymbol() == Symbol()&& OrderMagicNumber() == Magic)
      {
        if (count<10)
        {
          profit=profit+OrderProfit();
          count++;
        } 
      }
    }
  }

  return(profit);
}
//+------------------------------------------------------------------+
double GetLot()
{
  double Lot = 0; double n = GetLastLot();
  
  if (GetTotalProfit() < 0 || GetLastLotProfit() < 0)
  Lot = NormalizeDouble (n * MartinStep,2);
  
  if (GetTotalProfit() >= 0 || GetLastLotProfit() >= 0)
  Lot = LOT;
  
  return (Lot);
}

 

help me understand

double b=NormalizeDouble(ObjectGet("b",OBJPROP_TIME1),Digits);

int shiftb=iBarShift(NULL,0,b);

Writes one warning possible loss of data due to type conversion referring to the selected b, yes, it is not datetime, but if you do so:

datetime b=ObjectGet("b",OBJPROP_TIME1);

int shiftb=iBarShift(NULL,0,b);

there will be a warning on datetime b for some reason , it seems correct and there should be no warnings.

 
Alexandr24:

help me understand

double b=NormalizeDouble(ObjectGet("b",OBJPROP_TIME1),Digits);

int shiftb=iBarShift(NULL,0,b);

Writes one warning possible loss of data due to type conversion referring to the selected b, yes, it is not datetime, but if you do so:

datetime b=ObjectGet("b",OBJPROP_TIME1);

int shiftb=iBarShift(NULL,0,b);

there will be a warning on datetime b for some reason , it seems correct and there should be no warnings.

And set int b
 
artmedia70:
You're welcome.

Don't be modest, you're welcome, you've saved me a lot of time...
I wish you all the best and good luck.