Errors, bugs, questions - page 1488

 
Aleksandr Novikov:

Will there be an answer, or will it go down in history as an uncomfortable question as usual?

Or is the administration only able to change the sequence of links in the top menu?

The fourth forum has long been unsupported, but as a reference material remains. At least this decision was voiced by the administration.
 
Alexey Kozitsyn:

Even though I'm not from the administration, you haven't answered my question either...

Yes, I logged into the forum under my account and what does that get you? Just satisfy your curiosity?


Artyom Trishkin:
The fourth forum hasn't been supported for a long time, but it was preserved as a reference material. At least this decision was voiced by the administration.

So they would have closed it and redirected everything to the mql5 forum. Why neuter it?

People continue to use it and communicate, which means it's needed and its functionality should be maintained!

So it turns out that, as always, the users and their opinion are ignored and everything is decided unilaterally.

 
Aleksandr Novikov:

Yes, I logged into the forum under my account and what does that get you? Just satisfy your curiosity?

How should I know, maybe you want to see an asterisk without logging into your account? Then it's logical that you won't see it there.
 
Aleksandr Novikov:

Yes, I logged into the forum under my account and what does that do for you? Will it just satisfy your curiosity?


So why not close it and redirect it to the mql5 forum? Why do you want to neuter it?

People are still using it and communicating, which means it's needed and its functionality should be maintained!

But it turns out that, as always, the users and their opinion are ignored and everything is decided unilaterally.

That's exactly why you were not asked about a year ago, when they made the decision to stop supporting the fourth forum. Precisely because there is a lot of useful information there, it was not destroyed - use it. But as a reference.
 
Andrey Voytenko:

About initialisation. Is it possible to write it this way?

...

Anyway, my favourite initialization via ={0} with strings doesn't work. That's a shame.

Thanks for the post, bug fixed. The fix will be included in the next build.
 

Question on MT4 .

Good afternoon. Faced with a problem with lot size definition. Here is the code.

Specifically on Alpari. Specifically for USD-JPY. It should output the data on orders to the chart, but .....for USD-JPY cannot show the correct value! I'm interested in the data from the array!

What can I do additionally ???

#property version "1.00"
#property strict
#property indicator_chart_window
double Mas_Ord_Old[1000][19];
double Mas_Ord_New[1000][19];
double Mas_Tip[6];
string Mas_tip[6];
extern int FontSize=12;
extern color TextColor=clrIvory;
extern color TextColor1=clrGray;
extern color TextColor2=clrRed;
extern color TextColor3=clrYellow;
extern int X=20;
extern int Y=15;
int n;

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
Terminal();
//---
Comment(" пример неправильного лота ");
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
DeleteLabel();
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
Terminal();
int shift=15;
DeleteLabel();
n=13;
double proffit=0;
double pro=0;
double stloss=0;
double los=0;
int a9=(int)NormalizeDouble( Mas_Ord_Old [0][10],0);//MathIsValidNumber
//for(int cnt=OrdersTotal()-1;cnt>=0;cnt--)
for(int cnt=a9-1;cnt>=0;cnt--)
{
//.. и наша вал.пара
double a0= Mas_Ord_Old [cnt][0]; // OrderTicket(); I // Тикет ордера
double a1= Mas_Ord_Old [cnt][1]; // OrderOpenPrice(); D // Курс открытия орд
double a2= Mas_Ord_Old [cnt][2]; // OrderLots(); D // Количество лотов !!!!!!!!!!!!!!!!
double a3= Mas_Ord_Old [cnt][3]; // OrderTakeProfit(); D // Курс ТР
double a4= Mas_Ord_Old [cnt][4]; // OrderSwap(); D // Своп
double a5= Mas_Ord_Old [cnt][5]; // OrderStopLoss(); D // Курс SL
double a6= Mas_Ord_Old [cnt][6]; // OrderType(); I // Тип ордера
double a7= Mas_Ord_Old [cnt][7]; // OrderMagicNumber(); I // Магическое число
double a8= Mas_Ord_Old [cnt][8]; //
double Aa2= (double)((NormalizeDouble( a2,2))*100);
double Aaa2=(double)((NormalizeDouble( Aa2,2))/100);
// Print("2- OrderLots= ",Aa2," OrderType= ",Aaa2," OrderMagicNumber= ",a7," Ciomment= ",a8," кол-во = ",a0);
string text=StringConcatenate(" Тикет= Опен= ",a1," ЛОТ!!!= ",a2," ЛОТ 2= ",Aa2," 4= ",a4," 5= ",a5," 6= ",a6," 7= ",a7," 8= ",a8);
CreateLabel(StringConcatenate("Label_",n),text,X,Y+n*shift,clrYellow);
}

//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
// double Mas_Ord_Old[1000][9];
// double Mas_Ord_New[1000][9];
// double Mas_Tip[6];
// ~~~~~~~~~~~~~~~~~~ Работа с ордерами ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool Terminal()
{
int Qnt=0; // Счётчик количества ордеров

//--------------------------------------------------------------- 3 --
ArrayCopy(Mas_Ord_Old, Mas_Ord_New,0,0,WHOLE_ARRAY);// Сохраняем предыдущую историю
Qnt=0; // Обнуление счётчика ордеров
ArrayInitialize(Mas_Ord_New,0); // Обнуление массива
// ArrayInitialize(Mas_Tip, 0); // Обнуление массива
//--------------------------------------------------------------- 4 --
for(int i=OrdersTotal()-1; i>=0; i--) // По рыночн. и отлож. ордерам
{ //.. и наша вал.пара && (OrderSymbol()==Symbol())
if((OrderSelect(i,SELECT_BY_POS)==true) )
{
//------------------------------------------------------ 5 --
Mas_Ord_New[Qnt][0]=OrderTicket(); // Курс открытия орд
Mas_Ord_New[Qnt][1]=OrderOpenPrice(); // Курс открытия орд
Mas_Ord_New[Qnt][2]= OrderLots(); // Курс SL
Mas_Ord_New[Qnt][3]=OrderTakeProfit(); // Курс ТР
Mas_Ord_New[Qnt][4]=OrderSwap(); // Номер ордера
Mas_Ord_New[Qnt][5]=OrderStopLoss(); // Количество лотов
// Mas_Tip[OrderType()]++; // Кол. ордеров типа
Mas_Ord_New[Qnt][6]=OrderType(); // Тип ордера
Mas_Ord_New[Qnt][7]=OrderMagicNumber(); // Магическое число
if (OrderComment()=="")
Mas_Ord_New[Qnt][8]=0; // Если нет коммент
else
Mas_Ord_New[Qnt][8]=1; // Если есть коммент
Qnt++; // Колич. ордеров
//------------------------------------------------------ 6 --
}
}
Mas_Ord_New[0][10]=Qnt; // Колич. ордеров
//--------------------------------------------------------------- 7 --
return 0;
}
// ~~~~~~~~~~~~~~~~~~ Работа с ордерами ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//+--------------------------------------------------------------------+
void CreateLabel(string name, string text,int x, int y, color c) //
{ //
ObjectCreate(name, OBJ_LABEL,0,0,0); //
ObjectSetText(name,text,FontSize,"Times New Roman",TextColor); //
ObjectSet(name,OBJPROP_CORNER,0
); //
ObjectSet(name,OBJPROP_XDISTANCE,x); //
ObjectSet(name,OBJPROP_YDISTANCE,y); //
ObjectSet(name,OBJPROP_COLOR,c); //
n++; //
} //
void DeleteLabel() //
{ //
for(int i=ObjectsTotal();i>=0;i--) //
{ //
if(StringSubstr(ObjectName(i),0,6)=="Label_") //
ObjectDelete(ObjectName(i)); //
} //
} //
//+--------------------------------------------------------------------+
 
Sergey Vedmanov:

Question on MT4 .

Good afternoon. Faced with a problem with lot size definition. Here is the code.

Specifically on Alpari. Specifically for USD-JPY. It should output the data on orders to the chart, but .....for USD-JPY cannot show the correct value! I'm interested in the data from the array!

What can I do additionally ???

But it does work in Kovalev's tutorial. What prevents me from copying it correctly and adjusting it to the new requirements?
 
Artyom Trishkin:
But the Kovalev's tutorial still works. What is preventing us from copying it correctly and adjusting it to the new requirements?

I'll surprise you, but it works in other shopping centres too. If you read the post carefully from the beginning...

Specifically on Alpari. Specifically on USD-JPY.

What can we do additionally ???

 
Sergey Vedmanov:

I'll surprise you, but it works in other shopping centres too. If you read the post carefully from the beginning...

Specifically on Alpari. Specifically on USD-JPY.

What you can do additionally ???

... ... in other Trading Centres? :)

I saw your specifics. I didn't poke around because I think it's redundant. All those Kovalev terminals...

But in your code I see a discrepancy between stored data and description of this data in the comments - it's already confusing.

Further:

string text=StringConcatenate(" Тикет= Опен= ",a1," ЛОТ!!!= ",a2," ЛОТ 2= ",Aa2," 4= ",a4," 5= ",a5," 6= ",a6," 7= ",a7," 8= ",a8);

your lot is printed from variable a2, but what are we saving to it? Here it is:

Mas_Ord_New[Qnt][2]= OrderLots(); // Курс SL

Or maybe we should print it using DoubleToString() ?

And you are normalizing the lot incorrectly. You need function for lot normalization. I won't search for it. You can search for it at Kim's - it will do for you.

 
Artyom Trishkin:

... in other shopping centres? :)

I saw your specifics. I didn't poke around because I think it's all redundant. All those Kovalev terminals...

But in your code I see a discrepancy between stored data and description of this data in the comments - it's already confusing.

Further:

your lot is printed from variable a2, but what are we saving to it? Here it is:

Or maybe we should output it through DoubleToString() ?

The lot is normalized incorrectly. We need function for lot normalization. I will not search for it. You may look for it in Kim's - it will work for you.

Found it. Thank you. But it does not solve the task at hand.

It works correctly on other CAs and with this code.

It works incorrectly with Kim's function.

It reads correctly via DoubleToString() but calculates incorrectly. I will not count through DoubleToString(). If I go there and back, it transfers strings correctly but doublings of strings are again wrong.

The problem is in Alpari and we need a crutch to bypass it.

USD-SEK incorrectly displays the opening price on another pair.

#property version   "1.00"
#property strict
#property indicator_chart_window
  double Mas_Ord_Old[1000][19];
  double Mas_Ord_New[1000][19];
  double Mas_Tip[6];
  string Mas_tip[6];
extern int FontSize=12;
extern color TextColor=clrIvory;
extern color TextColor1=clrGray;
extern color TextColor2=clrRed;
extern color TextColor3=clrYellow;
extern int X=20;
extern int Y=15;
int n;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   Terminal();
//---
Comment(" пример неправильного лота ");
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
 DeleteLabel();
 }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
Terminal();
int shift=15;
DeleteLabel();
n=13;
double proffit=0;
double pro=0;
double stloss=0;
double los=0;
      int a9=(int)NormalizeDouble( Mas_Ord_Old [0][10],0);//MathIsValidNumber
//for(int cnt=OrdersTotal()-1;cnt>=0;cnt--)
for(int cnt=a9-1;cnt>=0;cnt--)
 {
                                 //.. и наша вал.пара
    double a0= Mas_Ord_Old [cnt][0];  //  OrderTicket();      I // Тикет ордера
    double a1= Mas_Ord_Old [cnt][1];  //  OrderOpenPrice();   D // Курс открытия орд
    string a2= DoubleToString(Mas_Ord_Old [cnt][2],2);  //  OrderLots();        D // Количество лотов !!!!!!!!!!!!!!!!
    double a3= Mas_Ord_Old [cnt][3];  //  OrderTakeProfit();  D // Курс ТР
    double a4= Mas_Ord_Old [cnt][4];  //  OrderSwap();        D // Своп
    double a5= Mas_Ord_Old [cnt][5];  //  OrderStopLoss();    D // Курс SL
    double a6= Mas_Ord_Old [cnt][6];  //  OrderType();        I // Тип ордера
    double a7= Mas_Ord_Old [cnt][7];  //  OrderMagicNumber(); I // Магическое число 
    double a8= Mas_Ord_Old [cnt][8];  //  
    double Aa2= (double)(StringToDouble(a2));
    double Aaa2=(double)((NormalizeDouble( Aa2,2))/100); 
   //   Print("2-  OrderLots= ",Aa2," OrderType= ",Aaa2," OrderMagicNumber= ",a7," Ciomment= ",a8," кол-во = ",a0);
    string text=StringConcatenate(" Опен= ",a1," ЛОТ string= ",a2," ЛОТ double= ",Aa2 );
    CreateLabel(StringConcatenate("Label_",n),text,X,Y+n*shift,clrYellow);
  }
  
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//  double Mas_Ord_Old[1000][9];
//  double Mas_Ord_New[1000][9];
//  double Mas_Tip[6];
// ~~~~~~~~~~~~~~~~~~ Работа с ордерами  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  bool Terminal()
  {
   int Qnt=0;                          // Счётчик количества ордеров
 
//--------------------------------------------------------------- 3 --
   ArrayCopy(Mas_Ord_Old, Mas_Ord_New,0,0,WHOLE_ARRAY);// Сохраняем предыдущую историю
   Qnt=0;                              // Обнуление счётчика ордеров
   ArrayInitialize(Mas_Ord_New,0);     // Обнуление массива
 //  ArrayInitialize(Mas_Tip,    0);     // Обнуление массива
//--------------------------------------------------------------- 4 --
   for(int i=OrdersTotal()-1; i>=0; i--) // По рыночн. и отлож. ордерам
     {                                //.. и наша вал.пара && (OrderSymbol()==Symbol())
      if((OrderSelect(i,SELECT_BY_POS)==true) )              
        {
         //------------------------------------------------------ 5 --
         Mas_Ord_New[Qnt][0]=OrderTicket();       // Курс открытия орд
         Mas_Ord_New[Qnt][1]=OrderOpenPrice();    // Курс открытия орд
         Mas_Ord_New[Qnt][2]=NormalizeLot( OrderLots(),0,Symbol());     // Курс SL
         Mas_Ord_New[Qnt][3]=OrderTakeProfit();   // Курс ТР
         Mas_Ord_New[Qnt][4]=OrderSwap();         // Номер ордера
         Mas_Ord_New[Qnt][5]=OrderStopLoss();        // Количество лотов
       //  Mas_Tip[OrderType()]++;                // Кол. ордеров типа
         Mas_Ord_New[Qnt][6]=OrderType();         // Тип ордера
         Mas_Ord_New[Qnt][7]=OrderMagicNumber();  // Магическое число 
         if (OrderComment()=="")
            Mas_Ord_New[Qnt][8]=0;                // Если нет коммент
         else
            Mas_Ord_New[Qnt][8]=1;                // Если есть коммент
          Qnt++;                                   // Колич. ордеров
        //------------------------------------------------------ 6 --
        }
     }
   Mas_Ord_New[0][10]=Qnt;                         // Колич. ордеров
//--------------------------------------------------------------- 7 --
   return 0;
  }
// ~~~~~~~~~~~~~~~~~~ Работа с ордерами ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//+----------------------------------------------------------------------------+
double NormalizeLot(double lo, bool ro=False, string sy="") {
  double l, k;
  if (sy=="" || sy=="0") sy=Symbol();
  double ls=MarketInfo(sy, MODE_LOTSTEP);
  double ml=MarketInfo(sy, MODE_MINLOT);
  double mx=MarketInfo(sy, MODE_MAXLOT);

  if (ml==0) ml=0.1;
  if (mx==0) mx=100;

  if (ls>0) k=1/ls; else k=1/ml;
  if (ro) l=MathCeil(lo*k)/k; else l=MathFloor(lo*k)/k;

  if (l<ml) l=ml;
  if (l>mx) l=mx;

  return(l);
//+----------------------------------------------------------------------------+
}
//+--------------------------------------------------------------------+
void CreateLabel(string name, string text,int x, int y, color c)              // 
   {                                                                 //
   ObjectCreate(name, OBJ_LABEL,0,0,0);                              //
   ObjectSetText(name,text,FontSize,"Times New Roman",TextColor);    //
   ObjectSet(name,OBJPROP_CORNER,0
   );                                 //
   ObjectSet(name,OBJPROP_XDISTANCE,x);                              //
   ObjectSet(name,OBJPROP_YDISTANCE,y);                              //
   ObjectSet(name,OBJPROP_COLOR,c);                              //
   n++;                                                              //
   }                                                                 //
void DeleteLabel()                                                   //
   {                                                                 //
   for(int i=ObjectsTotal();i>=0;i--)                                //
      {                                                              //
      if(StringSubstr(ObjectName(i),0,6)=="Label_")                  //
      ObjectDelete(ObjectName(i));                                   //
      }                                                              //
   }                                                                 //
//+--------------------------------------------------------------------+
Reason: