Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1535

 
Artyom Trishkin:

And the right option is, well, very simple...

So what is it?

 
Andrey Sokolov:

So which one?

So simple :)

If there is no data, exit until the next tick.

 
Good afternoon, is it possible to register a signal in MT4 from a demo account? Thank you.
 
Artyom Trishkin:

So simple :)

If there is no data, exit until the next tick.

No, I wrote that calculations and displays on them are needed at once.

If there will be problems with the existing solution, I think, as an alternative, one can write a function of bollinger calculation, it seems not difficult. But for now and what we have works.

 
Hello! How can I know the future price of the graphical objectOBJ_TREND? For example, we have a ray to the right and need to know at each new bar the value of this ray. thank you!
 
MakarFX:

This structure should be

I did it, it worked. Thank you

 
Andrey Sokolov:

No, I wrote that calculations and displays are needed immediately.

If there will be problems with the existing solution, then I think, as an option, you can write a function to calculate the bollinger, it seems not complicated. But for now the existing one works.

The indicator, if properly designed, always calculates the entire history first. What do you have?

 
Artyom Trishkin:

What have you got?

I don't understand the question.

 
Guys, help me make an alert to an indicator. I want to test a combination of different indicators, but I need an alert function. I need the alert to be shown only once when the arrow appears. If you're not hard please help me write this function, I can not do it, alerts pop up a whole minute or all the time, even mt4 hangs.
//+------------------------------------------------------------------+
//| 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[])
  {
//---

    int limit=rates_total-prev_calculated-2;
   if(limit<1) return(0);
   for(int i=limit;i>=0;i--)
     {
     
      // Снимем показания индикатора
     double in1b = iCustom(NULL,0,"in1",1,i); // индикатор 1 стрелка вверх
     double in1s = iCustom(NULL,0,"in1",0,i); // индикатор 1 стрелка вниз
      
     
     
     double in2b = iCustom(NULL,0,"in2",0,i); // индикатор 2 стрелка вверх
     double in2s = iCustom(NULL,0,"in2",1,i); // индикатор 2 стрелка вниз
    
    Comment("in1v = "+DoubleToString(in1b)+"\n" +"in1n = "+DoubleToString(in1s)+"\n"
    +"in2v = "+DoubleToString(in2b)+"\n" +"in2n = "+DoubleToString(in2s));
     
    if(in1b > 2147483647 && in2b > 2147483647) // индикатор стрелка вверх
           {
           Sell[i]=low[i];
                      
          
          // Alert(Symbol()+"BUY";
              
           
           
           
         
           }
   
     if(in1s > 2147483647 && in2s > 2147483647) // индикатор стрелка вниз
           {
            Buy[i]=high[i];
            
              // Alert(Symbol()+"SELL М"+Period());
              
              
           
           }
         
   
     }
   
     
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
jarikn:
Guys, help me make an alert for an indicator. I want to test a combination of different indicators, but I need an alert function. I need the alert to be shown only once when the arrow appears. If you are not hard please help me write this function, I can not do it, alerts pop up a whole minute or all the time, even mt4 hangs.

Try this, it seems to work

//+------------------------------------------------------------------+
//| 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[])
  {
//---
   datetime show_alert=time[1];
   int limit=rates_total-prev_calculated-2;
   if(limit<1) return(0);
   for(int i=limit;i>=0;i--)
     {
     
      // Снимем показания индикатора
      double in1b = iCustom(NULL,0,"in1",1,i); // индикатор 1 стрелка вверх
      double in1s = iCustom(NULL,0,"in1",0,i); // индикатор 1 стрелка вниз
      
      double in2b = iCustom(NULL,0,"in2",0,i); // индикатор 2 стрелка вверх
      double in2s = iCustom(NULL,0,"in2",1,i); // индикатор 2 стрелка вниз
    
      Comment("in1v = "+DoubleToString(in1b)+"\n" +"in1n = "+DoubleToString(in1s)+"\n"
      +"in2v = "+DoubleToString(in2b)+"\n" +"in2n = "+DoubleToString(in2s));
     
      if(in1b > 2147483647 && in2b > 2147483647) // индикатор стрелка вверх
        {
         Sell[i]=low[i];
         if(show_alert!=time[i])
           {
            Alert(Symbol()+"BUY М"+Period()); show_alert=time[i];
           }
        }
   
      if(in1s > 2147483647 && in2s > 2147483647) // индикатор стрелка вниз
        {
         Buy[i]=high[i];
         if(show_alert!=time[i])
           {
            Alert(Symbol()+"SELL М"+Period()); show_alert=time[i];
           }
        }
     }
     
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
Reason: