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

 
Roman.:

Guys, how do you interpret this warning?

Thank you.


function must be set to a variable

for example bool closee=OrderClose...........

  • return value of 'OrderSelect' should be checked
  • return value of 'OrderDelete' should be checked
  • return value of 'OrderSend' should be checked
  • return value of 'OrderClose' should be checked
  • return return value of 'OrderModify' should be checked


To avoid such warnings, return to the variable must be specified explicitly
for example like this:
  • bool select1=OrderSelect..........
  • bool delete1=OrderDelete..........
  • bool close1=OrderClose..........
  • bool modify1=OrderModify..........
  • int send1=OrderSend..........
 
Good afternoon. Can you tell me if it is possible to define or calculate the width/height on a graph of an OBJ_TEXT object?
 
alxm:
Good afternoon. Can you tell me if it's possible to determine or calculate the width/height on a graph of an OBJ_TEXT object?

How to calculate the number of characters, + font size or something like that?
 
cipsi:

How to find the OrderOpenPrice of the very first open order if known:

1.Symbol

2.BUY orders can be open from one to many

3.Magic

4.Differences between orders, probably by ticket - find the smallest ticket.


double PriceOpenFirstPos(string sy="", int op=-1, int mn=-1) {
  datetime t==0;
  double   r=0;
  int      i, k=OrdersTotal();

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sy || sy=="") {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (t>OrderOpenTime() || t==0) {
                t=OrderOpenTime();
                r=OrderOpenPrice();
              }
            }
          }
        }
      }
    }
  }
  return(r);
}
 
psdmaster:
Read the article about creating an EA: https://book.mql4.com/ru/samples/expert

Can you tell me how to open a deal on one bar and close it when the next bar appears?


1. When opening a deal, remember the time of the bar

like this:

outside the start:

 int timeopen;

at the start where you have a trade open:

 timeopen=Time[0];

Closing like this:

if(timeopen!= Time[0]) OrderClose............
 
Zolotai:
Please tell me. How can I find out the number of open orders for a given symbol, without loops...


There is no way to do it without a cycle.

 

Dear, I need your help.

I'm optimising an EA using an indicator, the code of the indicator is below.

Optimization is slow, I have made a code in the EA to recalculate the indicator on a new bar, which is not quite suitable.

Please see the code of the indicator, what can be done in it to make the recalculation happen faster.

#property indicator_separate_window
#property indicator_buffers 4
#property  indicator_color1 Lime
#property  indicator_color2 Yellow
#property  indicator_color3 Red
#property  indicator_color4 Aqua

//--- input parameters
extern int       Period_MA_1=14;
extern int       p2          =7;
extern int       p3          =5;
extern int       p4          =3;
extern int Limit=70;
//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_NONE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,ExtMapBuffer4);
   IndicatorDigits(Digits+1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted(),
   i,limit1,limit2,limit3,limit4;
   double impuls;
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
 
   limit1=Bars-counted_bars-1;
   if (limit1>Limit && Limit>0) limit1=Limit;
   limit2=limit1;
   limit3=limit2;
   limit4=limit3;
   if(limit1>0) 
     {
      limit1=500-Period_MA_1-1;
      limit2=limit1-p2;
      limit3=limit2-p3;
      limit4=limit3-p4;
     }
   for(i=limit1;i>=0;i--) {ExtMapBuffer1[i]=Close[i]-Close[i+Period_MA_1];}
   for(i=limit2;i>=0;i--) {ExtMapBuffer2[i]=iMAOnArray(ExtMapBuffer1, 0, p2, 0, MODE_EMA,i);}
   for(i=limit3;i>=0;i--) {ExtMapBuffer3[i]=iMAOnArray(ExtMapBuffer2, 0, p3, 0, MODE_EMA,i);}
   for(i=limit4;i>=0;i--) {ExtMapBuffer4[i]=iMAOnArray(ExtMapBuffer3, 0, p4, 0, MODE_EMA,i);}

   return(0);
  }
 

where can i read about classes in mt4?

I read the help, but it doesn't explain what the following lines mean

CArray::CArray(void) : m_step_resize(16),
                       m_data_total(0),
                       m_data_max(0),
                       m_sort_mode(-1)
  {
  }

where to read about variable initialization...

 
Vladon:


function must be set variable

e.g. bool closee=OrderClose...........

  • return value of 'OrderSelect' should be checked
  • return value of 'OrderDelete' should be checked
  • return value of 'OrderSend' should be checked
  • return value of 'OrderClose' should be checked
  • return return value of 'OrderModify' should be checked


To avoid such warnings, return to the variable must be specified explicitly
like this:
  • bool select1=OrderSelect..........
  • bool delete1=OrderDelete..........
  • bool close1=OrderClose..........
  • bool modify1=OrderModify..........
  • int send1=OrderSend..........


Thank you. It worked without any warnings:


Guided by an example from the handbook :-)


OrderDelete

Deletes a previously placed pending order.

bool OrderDelete(
int ticket, //order number
color arrow_color // colour
);

Parameters

ticket

[Unique serial number of the order.

arrow_color

[in] Color of the arrow on the chart. If this parameter is missing or its value is CLR_NONE, the arrow is not shown in the chart.

Returned value

Returns true if function completed successfully or false if there was an error. To get the error information, call GetLastError().

Example:

if(Ask>var1)
{
OrderDelete(order_ticket);
return(0);
}

 
Forexman77:

Dear, I need your help.

I'm optimizing my Expert Advisor by the indicator, the code of the indicator is below.

Optimization is slow, I have made a code in the EA to recalculate the indicator on a new bar, which is not quite suitable.

Please see the code of the indicator, what can be done in it to make the recalculation happen faster.


why did you think it was the indicator's fault?