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

 

Hello everyone!

Thanks to everyone who helps newcomers, not sparing their time, despite the fact that altruism has lost its value these days.

I ask for help from forum users, I've read all of Igor's thread, but have not found what I need, so I decided to write here.

And function I suspect is not complicated and somewhere already is, but...

How to calculate the maximum/minimum of the current(previous, ...) daily (weekly, ...) candle a MINUTE(5,15,30,60, ...) BACK?

I will be very grateful to altruistic professionals.

 
KAVrus:

Hello everyone!

Thanks to everyone who helps newcomers, not sparing their time, despite the fact that altruism has lost its value these days.

I ask for help from forum users, I have read the entire thread Igor, but I have not found what I need, so I decided to write here.

I suspect the function is not complicated and already exists somewhere, but...

How do you calculate the maximum/minimum of the current (previous, ...) daily (weekly, ...) candle a MINUTE(5,15,30,60, ...) BACK?

I will be very grateful to altruistic professionals.


:)))- that's funny.

Read on - you'll find many interesting things. :)))

 
boing9267:
How to get Open[] of the current chart but not of the current timeframe?
iOpen().
 
TarasBY:

:)))-)) - made me laugh.

Read on - you'll find a lot of interesting things. :)))


It's a sin to laugh at .....)))


I read it... "Volumes of other timeframes are not modelled"

I must have misstated the point of the question then... I'll try to simplify it:

How do you calculate the maximum/minimum of the current candle a MINUTE LATER?

 
TarasBY:
iOpen().


Thank you
 
KAVrus:

It's a sin to laugh at .....)))


Read... "Volumes of other timeframes are not simulated"

I must have misstated the point of the question then... I'll try to simplify it:

How do you calculate the maximum/minimum of the current daily candle a MINUTE LATER?

It's easier to laugh than to read (let alone "dig in")... :)))

Trying to solve the problem in code:

    //---- Находим последний расчётный бар на нужном нам тамфрейме
    int li_Shift = iBarShift (Symbol(), PERIOD_M1, iTime (Sumbol(), PERIOD_D1, 0)),
        //---- Ищем на нужном промежутке номер бара с High
        li_Bar = iHighest (Symbol(), PERIOD_M1, MODE_HIGH, li_Shift, 1);
    //---- Получаем значение High
    double ld_HIGH = iHigh (Symbol(), PERIOD_M1, li_Bar);

In the image and similarity with the minimum can you handle it?! ;)

P.S. Since in the price history we have a discreteness with a minimum size of 1 minute, it is correct to say not "a minute ago", but "not counting the last minute".

 
TarasBY:

Laughing is easier than reading (let alone "getting into")... :)))

Trying to solve the problem in code:

In your image, can you handle the minimum?! ;)

P.S. Since in the price history we have a discreteness, the minimum of which is 1 minute, it is correct to say not "a minute ago", but " not counting the last minute".


Thank you!!!
 
Hello guys, please help with the indicator sAccelerator.mq4. I want to make an alert when the 0 line is crossed, and the alert to remove the repaint, it does not work, and in mql frankly I do not understand.
//+------------------------------------------------------------------+
//|                                                 sAccelerator.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2005, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Black
#property  indicator_color2  Lime
#property  indicator_color3  Red
//---- indicator buffers
double ExtBuffer0[];
double ExtBuffer1[];
double ExtBuffer2[];
double ExtBuffer3[];
double ExtBuffer4[];
// Номер бара, по которому будет искаться сигнал
#define SIGNAL_BAR 1
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(5);
//---- drawing settings
   SetIndexStyle(0, DRAW_NONE);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexStyle(2, DRAW_HISTOGRAM);
   IndicatorDigits(Digits + 2);
   SetIndexDrawBegin(0, 38);
   SetIndexDrawBegin(1, 38);
   SetIndexDrawBegin(2, 38);
//---- 4 indicator buffers mapping
   SetIndexBuffer(0, ExtBuffer0);
   SetIndexBuffer(1, ExtBuffer1);
   SetIndexBuffer(2, ExtBuffer2);
   SetIndexBuffer(3, ExtBuffer3);
   SetIndexBuffer(4, ExtBuffer4);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("sAC");
   SetIndexLabel(1, NULL);
   SetIndexLabel(2, NULL);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Accelerator/Decelerator Oscillator                               |
//+------------------------------------------------------------------+
int start()
  {
   int    limit;
   int    counted_bars = IndicatorCounted();
   double prev, current;
//---- last counted bar will be recounted
   if(counted_bars > 0) 
       counted_bars--;
   limit = Bars - counted_bars;
//---- macd counted in the 1-st additional buffer
   for(int i = 0; i < limit; i++)
       ExtBuffer3[i] = iMA(NULL, 0, 5, 0, MODE_SMA, PRICE_MEDIAN, i) - 
                       iMA(NULL, 0, 34, 0, MODE_SMA, PRICE_MEDIAN, i);
//---- signal line counted in the 2-nd additional buffer
   for(i = 0; i < limit; i++)
       ExtBuffer4[i] = iMAOnArray(ExtBuffer3, Bars, 5, 0, MODE_SMA, i);
//---- dispatch values between 2 buffers
   bool up = true;
   for(i = limit - 1; i >= 0; i--)
     {
       current = ExtBuffer3[i] - ExtBuffer4[i];
       prev = ExtBuffer3[i+1] - ExtBuffer4[i+1];
       if(current > prev) 
           up = true;
       if(current < prev) 
           up = false;
       if(!up)
         {
           ExtBuffer2[i] = current;
           ExtBuffer1[i] = 0.0;
         }
       else
         {
           ExtBuffer1[i] = current;
           ExtBuffer2[i] = 0.0;
         }
       ExtBuffer0[i] = current;
     }
//---- done
    //---- Статические переменные, в которых хранятся
    //---- время последнего бара и направление последнего сигнала
    static int PrevSignal = 0, PrevTime = 0;
 
    //---- Если баром для анализа выбран не 0-й, нам нет смысла проверять сигнал
    //---- несколько раз. Если не начался новый бар, выходим.
    if(SIGNAL_BAR > 0 && Time[0] <= PrevTime ) 
        return(0);
    //---- Отмечаем, что этот бар проверен
    PrevTime = Time[0];
          if(PrevSignal <= 0)
      {
        if(MainBuffer[SIGNAL_BAR] - 0.0 > 0 && 
           0.0 - MainBuffer[SIGNAL_BAR+1] >= 0)
          {
            PrevSignal = 1;
            Alert("sAC (", Symbol(), ", ", Period(), ")  -  BUY!!!");
          }
      }
    if(PrevSignal >= 0)
      {
        if(0.0 - MainBuffer[SIGNAL_BAR] > 0 && 
           MainBuffer[SIGNAL_BAR+1] - 0.0 >= 0)
          {
            PrevSignal = -1;
            Alert("sAC (", Symbol(), ", ", Period(), ")  -  SELL!!!");
          }
      } 
   return(0);
  }
//+------------------------------------------------------------------+

 

Gentlemen, please advise how to find the average ticks in a bar. I assume the following:

Average[i] = (total amount of ticks of bar[i])/Volume[i]; How to find the total amount of ticks of the desired bar?

 

Please tell me what I'm doing wrong. I am trying to make a simple indicator:


  {

   int limit,i;
   double last;
   int counted_bars = IndicatorCounted();
   //---- check for possible errors
   if (counted_bars < 0) 
       return(-1);
   //---- last counted bar will be recounted
   if(counted_bars > 0) 
       counted_bars--;
   limit = Bars - counted_bars;
//----
   for(i=limit; i>=0; i--)
   {
      double OptClose = Close[i]*10000;
      if (MathMod(OptClose,step1)==0)
      {
      Buffer0[i] = Close[i];
      last = Close[i];
      }
      else
      Buffer0[i] = last;
   }

//----
   return(0);
  }
//+------------------------------------------------------------------+

It works in the chart window, but when I try to test it in the Expert Advisor, it either draws whatever it is or "no steps".

Reason: