Errors, bugs, questions - page 886

 
Yedelkin:
There could be any number of reasons... The best-known ones are division by zero, leaving the array.

Thank you.

What is output outside the array? I apologise for my ignorance.

I only have 3 divisions:

TradeLot=AccountInfoDouble(ACCOUNT_BALANCE)*(PercentSize/100)/(100); 
MaxLotAllowed=MathFloor((MeansFree/MeansOneLot)*100)/100;
(PositionVolume()+Volume())*(100)*(100))/AccountInfoDouble(ACCOUNT_BALANCE)
 
G001: I only have 3 divisions:

This is where division by zero could potentially occur:

/AccountInfoDouble(ACCOUNT_BALANCE)

A basic check is needed.

G001 : What is output outside the array? Apologies for my ignorance.

It is when, for example:

double array[3];
for (int i=0; i<=3; i++) array[i];

On the last iteration there will be an exit outside the array.

 
Yedelkin:

This is where division by zero could potentially occur:

A basic check is needed.

This is when, for example:

At the last iteration there will be an exit outside the array.

Thank you.

Cool, should we check if the function works correctly?

AccountInfoDouble(ACCOUNT_BALANCE)

 
G001: Cool, you have to check if the function works correctly?
Well, what happens when the balance goes to zero and the function works correctly? :)
 

Is there no problem with a meter like this?

int TotalBullStopOrders()
{
  int BullCounter=0;
  int Total = OrdersTotal();
  for(i = 0; i < Total; i++)
  {
    if(OrderSelect(OrderGetTicket(i)))
    {
      if(OrderGetString(ORDER_SYMBOL)==Symbol() && OrderGetInteger(ORDER_MAGIC)==Magic)
      {
        if(OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_BUY_STOP)
        {
          BullCounter++;
        }
      }
    }
  }
  return(BullCounter);
}
 
Yedelkin:
Well, what happens when the balance goes to zero and the function works correctly? :)
You're right, I'll fix it there.
But now my balance is not zero and my EA smiles green but stops working, Abnormally and without any warnings, it would be better not to smile... :)
 
G001: There is no problem with this counter?

The for statement does not have the type of variable i defined. The variable Magic is not defined. In the line.

if(OrderSelect(OrderGetTicket(i)))
OrderSelect() function is unnecessary. I haven't noticed anything else.
Документация по MQL5: Основы языка / Операторы / Оператор цикла for
Документация по MQL5: Основы языка / Операторы / Оператор цикла for
  • www.mql5.com
Основы языка / Операторы / Оператор цикла for - Документация по MQL5
 
AndreyS:

issue with error (Error CopyBuffer - error number: 4806) - I remove it, I cure it bySleep(1000); - I put it down to indicator not having enough time to create.

The issue with the error (4194304 bytes not available) remains.

It will most likely be created. But before copying the data, we must check whether the data we want to receive (has the indicator had time to calculate?). The BarsCalculated function should help.

Then you request all timeframes by symbol. If this data is ready - it is downloaded from the disk into the memory, if not - it starts to be built (the memory is also consumed) + 100 indicators with a different period for each TF, and all this in the memory. The data is not immediately unloaded from the memory (in case you want to request it again)...

Reduce the number of bars on the chart.

Документация по MQL5: Доступ к таймсериям и индикаторам / BarsCalculated
Документация по MQL5: Доступ к таймсериям и индикаторам / BarsCalculated
  • www.mql5.com
Доступ к таймсериям и индикаторам / BarsCalculated - Документация по MQL5
 
Yedelkin:

The for statement does not have the type of variable i defined. The variable Magic is not defined. In the line

OrderSelect() is redundant. I haven't noticed anything else.

Thank you.

There is one outside the operator.

input int    Magic          = 55;

MqlTradeRequest request={0};
MqlTradeResult result={0};
MqlTradeCheckResult check={0};
//-----
int LotsDigits;
int Indicator;
double IndicatorVal[5];
double Ask;
double Bid;
int i;
int pos;
double TradeLot;
ulong StopLevel;
double MeansFree;
double MaxLotAllowed;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
 
alexvd:

It is likely to have been created. Only before copying the data, you should check if the data is available (has the indicator settled?). The BarsCalculated function should help.

Then you request all timeframes by symbol. If the data is ready - it is downloaded from the disk into the memory, if not - it starts to be built (the memory is also consumed) + 100 indicators with a different period for each TF, and all this in the memory. The data is not immediately unloaded from the memory (in case you want to request it again)...

Reduce the number of bars on the chart.

        while(BarsCalculated(m_handle)==-1 && !IsStopped()) Sleep(1); // Спасибо alexvd - откоректировал строку с учётом замечаний

The number of bars does not change anything,

The problem is hidden in the periods, for variants

for(int iperiod=5; iperiod<=19; iperiod++) 

does not work, 19-5=14 - different periods,

If they are reduced to 4, then everything works, for example:

for(int iperiod=16; iperiod<=19; iperiod++)

Although foru IndicatorRelease(m_handle) - is indeed incorrectly used.

I think that even if you don't release handles with IndicatorRelease function, it should work anyway,

So, the problem is in the number of different periods.

Or...