[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 831

 

Good afternoon, distinguished experts.

Could you please advise me on this question?

Are there any standard functions in MQL4 that allow determining the maximum/minimum value that the price took on the interval from the i-th bar to the j-th one?

Thank you very much in advance.

 
Morzh09:

Good afternoon, distinguished experts.

Could you please advise me on this question?

Are there any standard functions in MQL4 that allow determining the maximum/minimum value that the price took on the interval from the i-th bar to the j-th one?

Thank you very much in advance.

https://docs.mql4.com/ru/series/iHighest

https://docs.mql4.com/ru/series/iLowest

 
How about this
void CheckForOpen() { 

//

s=0;
     t_up=icustom(.........................);
     if(t_up==1)
        {
          s=1;
          for(k=0;k<10;k++)             //количество раз проверки
            {
               sleep(30000);             //
             //думаю что в этом месте рефреш ????????
               if(t_up==1)
                    s=1;
                else
                    {
                       s=0;
                       break;
                    }
             }
           if(s==1)op="buy";
        }
      else
        {
          s=0;
          break;
        }
return;
}
You have to refresh somewhere. And a question - what are the consequences of using Slap?
 
gince:
And if you do it like this, you have to refresh somewhere. And a question - what are the consequences of using slap ?

Sleep in the tester does not work.

Why doesn't the check on every tick work for you? Is the indicator "heavy"?

 

Good afternoon, dear experts! I am learning to program in MOL4. I cannot figure out how to correctly write the condition: "If there are more buy orders than there are sell orders".

 
fanat:

Good afternoon, dear experts! I am learning to program in MOL4. I cannot figure out how to correctly write the condition: "If there are more buy orders than there are sell orders".

Open? Closed? Market? Deferred?
There is a difference.
 
fanat:

Good afternoon, dear experts! I am learning to program in MOL4. I do not know how to correctly write the condition: "If there are more buy orders than sell orders". Please help.


1. Count the number of orders of the first type

2. Count the number of orders of the second type

3. Compare results

extern int Magic=20100906;
//+------------------------------------------------------------------+
//|     Массив для хранения количества открытых позиций каждого типа |
//|                                Copyright © 2010, Victor Nicolaev |
//|                                            e-mail: vinin@mail.ru |
//+------------------------------------------------------------------+
//| int Order_Count[6];                                              |
//+------------------------------------------------------------------+
int Order_Count[6];

//+------------------------------------------------------------------+
//|       Функция возвращаюшая количество ордеров определенного типа |
//|                                   исхода из заданных ограничений |
//|                                Copyright © 2010, Victor Nicolaev |
//|                                            e-mail: vinin@mail.ru |
//+------------------------------------------------------------------+
//| int Order_Count_Calculate(string lSymbol, int lMagic, int lOP=-1)|
//+------------------------------------------------------------------+
int Order_Count_Calculate(string lSymbol, int lMagic, int lOP=-1){
   ArrayInitialize(Order_Count,0);
   for (int i = OrdersTotal() - 1;  i >= 0;  i--) {
      if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
      if (OrderSymbol() != lSymbol)                   continue;
      if (OrderMagicNumber() != lMagic)                continue;
      Order_Count[OrderType()]++;
   }
   if (lOP!=-1) return(Order_Count[lOP]);
   return(0);
}

int start(){
   Order_Count_Calculate(Symbol(), Magic);
   if (Order_Count[OP_BUY]>Order_Count[OP_SELL])
   // Ваши действия
   return(0);
}

 

Hello!!!

A simple indicator with arrows. Yesterday both ways.... no way... Thought today with a clear head I still can't see the error.....

IT'S NOT DRAWING ANYTHING!!!!! Please tell me where I made a mistake....

//+------------------------------------------------------------------+
//|                                         Indicator_OsMA_Stoch.mq4 |
//|                                                                  |
//|           огромное cпасибо за помощь Vinin и granit77            |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- input parameters
extern int       Fast_EMA=8;      // пар-ры OsMA
extern int       Slow_EMA=34;     // пар-ры OsMA
extern int       Signal_EMA=1;    // пар-ры OsMA
extern double    N = 0.0002;      // контр. линия
extern int     KPeriod     = 21;  // Период (количество баров) для вычисления линии %K.
extern int     DPeriod     = 5;   // Период усреднения для вычисления линии %D.
extern int     Slowing     = 8;   // Значение замедления.
extern int       A = 20;          // расстояние от бара
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double OsMA[];
double Stoch[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_ARROW, EMPTY, 1);
   SetIndexArrow(0,234);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW, EMPTY, 1);
   SetIndexArrow(1,233);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
   SetIndexBuffer(2,OsMA);
   SetIndexBuffer(3,Stoch);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int limit = Bars-counted_bars-1;
   
   for(int i = limit; i>= 0; i--) {
      ExtMapBuffer2[i] = EMPTY;
      ExtMapBuffer1[i] = EMPTY;
      OsMA[i]=iOsMA(NULL,0,Fast_EMA,Slow_EMA,Signal_EMA,PRICE_OPEN,i);
      Stoch[i]=iStochastic(NULL,0,KPeriod,DPeriod,Slowing,1,0,MODE_MAIN,i);
      if(true                &&
        (OsMA[i]>OsMA[i+1])  ||
        (OsMA[i]<OsMA[i+1])  &&
        (Stoch[i+1]>Stoch[i])||
        (Stoch[i+1]<Stoch[i])
        )
      {
       if((OsMA[i]<-N)&&(Stoch[i]<20)) ExtMapBuffer2[i] = Low[i] -A*Point;
       if((OsMA[i]> N)&&(Stoch[i]>80)) ExtMapBuffer1[i] = High[i]+A*Point; 
      }
   }
   return(0);
}
//+------------------------------------------------------------------+ 
 
Please help. There are several pending orders (10 for example). One of them opens and triggers (no matter if it is a take or loss order). On the next tick, the next pending order should be set up. It is difficult to identify the order by a tick or a magik (the number of positions that may trigger is not limited). That is why I decided the easiest way to choose a time to set a pending order would be to compare the last and penultimate variable values (whatever) of positions that have already been closed. Thanks!
 
dimon74:
Please help. There are several pending orders (10 for example). One of them opens and triggers (no matter if it is a take or loss order). On the next tick, the next pending order should be set up. It is difficult to identify the order by a tick or a magik (the number of positions that may trigger is not limited). That is why I decided the easiest way to choose a time to set a pending order would be to compare the last and penultimate variable values (whatever) of positions that have already been closed. Thank you!

What will change next time?