Errors, bugs, questions - page 2457

 
Does anyone in the Market practice, when upgrading their product, to attach (via resources) the EX5 of the previous version, so that the user always has the option of rolling back in case of an error?
 
fxsaber:
Does anyone in the Market practice, when upgrading their product, to put (via resources) the EX5 of the previous version into it, so that the user always has the possibility to rollback in case of an error?

This can be done without resources...

The problem is that new versions may have different settings...

Bringing out other settings is already a problem...

 
Vladimir Pastushak:

This can be done without resources...

The problem is that new versions may have different settings...

Bringing out other settings is already a problem...

I don't see any problem with this.

 

When requesting logs from an active VPS, the error "Failed to get terminal logs" is displayed

Who knows what may be the problem? At the same time, EAs on VPS are working (opening/closing trades), but I can't load logs.

 
fxsaber:

I don't see any problem with that.

Only now I realised that EX5 of the previous version has to be with a protection mechanism.

And through the resources of the previous version EX5 will be able to transfer without protection, which is not suitable.

 

I'm writing an indicator on 5.

I can't get it to update the period of the average from the input field on the chart. On 4, this design will work.

What is wrong? The field in the inite is updated throughOnChartEvent, but the period is not. I can't change it in any way.

I am attaching a simple working example.

//+------------------------------------------------------------------+
//|                                                      Probe_2.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                                 https://mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://mql5.com"
#property description "The MA "
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot MA1
#property indicator_label1  "MA 1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDarkOrange
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1

//--- input parameters
 extern int PBB=10;  //  период МА
//--- indicator buffers
double         BufferMA1[];
//--- global variables
int            period_ma1;
int            period_max;

int            handle_ma1;
string sn,sPBB;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
  

   sPBB=IntegerToString(PBB);
   if(ObjectFind(0,"P2edit")!=0)
    {
       ObjectCreate(0,"P2edit",OBJ_EDIT,0,0,0);
       ObjectSetInteger(0,"P2edit",OBJPROP_XDISTANCE,300);
       ObjectSetInteger(0,"P2edit",OBJPROP_YDISTANCE,1);
       ObjectSetInteger(0,"P2edit",OBJPROP_XSIZE,70);
       ObjectSetInteger(0,"P2edit",OBJPROP_YSIZE,40);
       ObjectSetInteger(0,"P2edit",OBJPROP_SELECTABLE,false);
       ObjectSetInteger(0,"P2edit",OBJPROP_BGCOLOR,clrBlack);
       ObjectSetString (0,"P2edit",OBJPROP_TEXT,sPBB);
       ObjectSetInteger(0,"P2edit",OBJPROP_FONTSIZE,16);
       ObjectSetInteger(0,"P2edit",OBJPROP_COLOR,clrGray);
       ObjectSetInteger(0,"P2edit",OBJPROP_ALIGN,ALIGN_CENTER);
       ObjectSetInteger(0,"P2edit",OBJPROP_READONLY,false);
    }


//--- set global variables
   period_ma1=int(PBB<1 ? 1 : PBB);
//--- indicator buffers mapping
   SetIndexBuffer(0,BufferMA1,INDICATOR_DATA);
   ArraySetAsSeries(BufferMA1,true);
   IndicatorSetInteger(INDICATOR_DIGITS,Digits());
//--- create handle
   ResetLastError();

   Comment("Должна соответствовать зеленой, а равна= ",PBB);
   
   handle_ma1=iMA(NULL,PERIOD_CURRENT,period_ma1,0,1,PRICE_CLOSE);
   if(handle_ma1==INVALID_HANDLE)
     {
      Print("The iMA(",(string)period_ma1,") object was not created: Error ",GetLastError());
      return INIT_FAILED;
     }
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
 {
  if(id==CHARTEVENT_OBJECT_ENDEDIT)
   {
    string obj_name=sparam;
    if(!StringCompare(obj_name,"P2edit"))
     {
     string novPBB=NULL;
     if(ObjectGetString(0,obj_name,OBJPROP_TEXT,0,novPBB))
      {
       if(StringCompare(novPBB,sPBB,false))
        {
         PBB= (int)StringToInteger(novPBB);
         ObjectSetInteger(0,"P2edit",OBJPROP_BGCOLOR,clrBlack);
         ObjectSetInteger(0,"P2edit",OBJPROP_COLOR,clrLime);
        }
       }
Print("B OnChartEvent PBB=",PBB);
      ChartSetSymbolPeriod(0,_Symbol,_Period);
      }
    }
    return;
 }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//    Пробовал от сюда запускать.
//   sPBB=IntegerToString(PBB);
//   if(ObjectFind(0,"P2edit")!=0)
//    {
//       ObjectCreate(0,"P2edit",OBJ_EDIT,0,0,0);
//       ObjectSetInteger(0,"P2edit",OBJPROP_XDISTANCE,300);
//       ObjectSetInteger(0,"P2edit",OBJPROP_YDISTANCE,1);
//       ObjectSetInteger(0,"P2edit",OBJPROP_XSIZE,70);
//       ObjectSetInteger(0,"P2edit",OBJPROP_YSIZE,40);
//       ObjectSetInteger(0,"P2edit",OBJPROP_SELECTABLE,false);
//       ObjectSetInteger(0,"P2edit",OBJPROP_BGCOLOR,clrBlack);
//       ObjectSetString (0,"P2edit",OBJPROP_TEXT,sPBB);
//       ObjectSetInteger(0,"P2edit",OBJPROP_FONTSIZE,16);
//       ObjectSetInteger(0,"P2edit",OBJPROP_COLOR,clrGray);
//       ObjectSetInteger(0,"P2edit",OBJPROP_ALIGN,ALIGN_CENTER);
//       ObjectSetInteger(0,"P2edit",OBJPROP_READONLY,false);
//    } 
//   
//   if(PBB==0) PBB=(int)StringToInteger(sPBB);
// 
//   if(PBB<5) period_ma1=5; else  period_ma1=PBB;
//   if(PBB>300) period_ma1=300; else  period_ma1=PBB;
   
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

   ArraySetAsSeries(close,true);//--- Установка массивов буферов как таймсерий
//--- Проверка количества доступных баров
   if(rates_total<fmax(period_max,4)) return 0;
//--- Проверка и расчёт количества просчитываемых баров
   int limit=rates_total-prev_calculated;
   if(limit>1)
     {
      limit=rates_total-2;
      ArrayInitialize(BufferMA1,EMPTY_VALUE);
     }

//--- Подготовка данных
   int count=(limit>0 ? rates_total : 1),copied=0;
   copied=CopyBuffer(handle_ma1,0,0,count,BufferMA1);
   if(copied!=count) return 0;

 //Comment("ошибка = ");
 
//--- возвращаемое значение prev_calculated для следующего вызова
   return(rates_total);
  }

//+------------------------------------------------------------------+
//|            deinit                                                |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   int i;
   int obj_total=ObjectsTotal(0,0,-1);
   for(i=obj_total-1;i>=0;i--)
     {
      sn=ObjectName(0,i,0,-1);
      if(ObjectFind(0,sn)==0) 
        {
         if (StringFind(sn,"P2edit",0)==0) ObjectDelete(0,sn);
        }
     }
  
   Comment("");
   return;
  }
 
Zakhar Chumak:

When requesting logs from an active VPS, the error "Failed to get terminal logs" is displayed

Who knows what may be the problem? At the same time EAs on VPS are working (opening/closing trades), but I can't load logs.

Looks like the path to temp folder is too long.

The archived logs are first read into a temporary file (with tmp extension) in the system temp folder. A temporary file name formation error has occurred

 

Am I correct in assuming that after a pass, agents sleep and wait for the remaining busy agents to finish their work ?


 

What?

No one can answer my question?

What's interesting. With this variantOnCalculate works. But this variant doesn't work.

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
 
Uladzimir Izerski:

What?

No one can answer my question?

What's interesting. With this variantOnCalculate works. But this variant does not work.

When you change the schedule / period, PBB gets a value of 10, no matter what value you specified in the input field.

At the moment of re-initialisation, it happens as if it were the first run.

There are two ways to solve your problem

1 - Storing PBB value in global variables and get the period from there.

2 - When OnChartEvent triggers, reinitialize MA indicator and get new handle...