I will write the indicator for free - page 104

 
ALEXEY NIKOLAEV:

My regards to the esteemed community!

Can someone write an indicator that displays on the chart the information about the current bar number in a certain period, which is specified in the settings. For example, the indicator is run on days, the reporting period is a month specified in the settings. This means that the indicator displays on the chart the number that, according to the account, is the zero bar from the beginning of the calendar month. On MT4, please)

Happy Holidays to all)

Happy hunting)

Intraday only:

function

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 26.02.2008                                                     |
//|  Описание : Возвращает расчётный номер бара от начала суток.               |
//|           : Нумерация баров начинается с 1 (единица).                      |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    tf - таймфрейм                       (0 - текущий таймфрейм)            |
//|    dt - дата и время открытия бара      (0 - текущее время)                |
//+----------------------------------------------------------------------------+
int iBarOfDayCalc(int tf=0, datetime dt=0) {
  if (tf<=0) tf=Period();
  if (dt<=0) dt=TimeCurrent();
  if (tf>PERIOD_D1) {
    Print("iBarOfDayCalc(): Таймфрейм должен быть меньше или равен D1");
    return(0);
  }
  double ms=MathMod(dt/60, 1440);      // количество минут от начала суток
  int    bd=MathFloor(ms/tf)+1;        // номер бара от начала суток

  return(bd);
}
 
Alekseu Fedotov:

Intraday only:

function

Thank you, of course.

But intraday won't work. No, it doesn't.

 
Good day to help. I have an Awesome Oscillator indicator that shows the difference between simple moving averages with periods of 5 and 34 median prices. Can someone write a new indicator or suggest how to change the AO so that the indicator shows the dynamics in the form of a histogram using the following formula: [simple moving average of median prices with period 3 times simple moving average of tick volume with period 3] minus [simple moving average of median prices with period 21 times simple moving average of tick volume with period 21]?
 
volizordlo:
Hello, help me out here. There is an indicator Awesome Oscillator that shows the difference between simple moving averages with periods of 5 and 34 median prices. Can someone write a new indicator or suggest how to change the AO to display the dynamics of the indicator as a histogram according to the following formula: [simple moving average of median prices with period 3 multiplied by

a simple tick volume moving average with a period of 3

] minus [simple moving average of median prices with period 21 multiplied by a simple moving average of tick volume with period 21]?

is there an averaging of tick volume?

 
Iurii Tokman:

you mean the averaging of tick volume?

yes

 
volizordlo:

Yeah.

ok, i will try to multiply
i wonder what the result is
but do you have a picture of what the result should be ?

 
Iurii Tokman:

ok, i will try to multiply
i wonder what the result is
but do you have a picture of what the result should be ?

It should look like the same ao or macd. but that's just an idea. thanks!
 
volizordlo:
It's supposed to look like the same ao or macd. but that's just an idea. thanks!

ok

 
volizordlo:
It's supposed to look like the same ao or macd. but that's just an idea. thank you!
//+------------------------------------------------------------------+
//|                                                      Awesome.mq4 |
//|                                               Yuriy Tokman (YTG) |
//|                       https://www.mql5.com/ru/users/satop/seller |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman (YTG)"
#property link      "https://www.mql5.com/ru/users/satop/seller"
#property version   "1.00"
#property description "Awesome Oscillator"
#property strict

//--- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 4
#property  indicator_color1  Black
#property  indicator_color2  Black
#property  indicator_color3  Green
#property  indicator_color4  Red
//--- buffers
double B1[];
double     ExtAOBuffer[];
double     ExtUpBuffer[];
double     ExtDnBuffer[];
//---
#define  PERIOD_FAST  3
#define  PERIOD_SLOW 21
//--- bars minimum for calculation
#define  DATA_LIMIT  34
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit(void)
  {
//--- drawing settings
   SetIndexStyle(0, DRAW_NONE);
   SetIndexStyle(1, DRAW_NONE);
   SetIndexStyle(2, DRAW_HISTOGRAM);
   SetIndexStyle(3, DRAW_HISTOGRAM);
   IndicatorDigits(Digits + 1);
   SetIndexDrawBegin(0, DATA_LIMIT);
   SetIndexDrawBegin(1, DATA_LIMIT);
   SetIndexDrawBegin(2, DATA_LIMIT);
   SetIndexDrawBegin(3, DATA_LIMIT);
//--- 3 indicator buffers mapping
   SetIndexBuffer(0, B1);
   SetIndexBuffer(1, ExtAOBuffer);
   SetIndexBuffer(2, ExtUpBuffer);
   SetIndexBuffer(3, ExtDnBuffer);
//--- name for DataWindow and indicator subwindow label
   IndicatorShortName("AO");
   SetIndexLabel(2, NULL);
   SetIndexLabel(3, NULL);
  }
//+------------------------------------------------------------------+
//| Awesome Oscillator                                               |
//+------------------------------------------------------------------+
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    i, limit = rates_total - prev_calculated;
   double prev = 0.0, current;
//--- check for rates total
   if(rates_total <= DATA_LIMIT)
      return(0);
//--- last counted bar will be recounted
   if(prev_calculated > 0)
     {
      limit++;
      prev = ExtAOBuffer[limit];
     }
   /*
   Доброго времени суток! Помогите. Есть индикатор Awesome Oscillator,
   который показывает разность простых скользящих средних с периодами 5 и 34 медианных цен.
   Может ли кто написать новый индикатор или подсказать, как изменить AO,
   чтобы индикатор в виде гистограммы показывал динамику по следующей формуле:

   [простая скользящая средняя медианных цен с периодом 3
   умножить
   на простую скользящую среднюю тикового объема с периодом 3]

   минус

   [простая скользящая средняя медианных цен с периодом 21
   умножить
   на простую скользящую среднюю тикового объема с периодом 21]?
   */
   for(i = 0; i < limit; i++)
      B1[i] = (double)iVolume(Symbol(), 0, i);
   for(i = 0; i < limit; i++)
      ExtAOBuffer[i] =
         iMA(NULL, 0, PERIOD_FAST, 0, MODE_SMA, PRICE_MEDIAN, i)
         *
         iMAOnArray(B1, 0, PERIOD_FAST, 0, MODE_SMA, i)
         -
         iMA(NULL, 0, PERIOD_SLOW, 0, MODE_SMA, PRICE_MEDIAN, i)
         *
         iMAOnArray(B1, 0, PERIOD_SLOW, 0, MODE_SMA, i)
         ;
//--- dispatch values between 2 buffers
   bool up = true;
   for(i = limit - 1; i >= 0; i--)
     {
      current = ExtAOBuffer[i];
      if(current > prev)
         up = true;
      if(current < prev)
         up = false;
      if(!up)
        {
         ExtDnBuffer[i] = current;
         ExtUpBuffer[i] = 0.0;
        }
      else
        {
         ExtUpBuffer[i] = current;
         ExtDnBuffer[i] = 0.0;
        }
      prev = current;
     }
//--- done
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Iurii Tokman:
Yep, thank you very much!
Reason: