 Группа "Программирование на MQL"
Группа "Программирование на MQL" Лучшее от AM2
Лучшее от AM2 19
 19			 0
 0
			 8
 8			 0
 0
			 24
 24			 0
 0
			 33
 33			 0
 0
			 3
 3			 0
 0
			| Пишем простейший цветной индикатор для МТ5 | 
#property indicator_buffers 2
#property indicator_plots 1
#property indicator_label1  "Color MA"
#property indicator_type1   DRAW_COLOR_LINE
#property indicator_color1  clrBlue,clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
input int MAPeriod=22;
int ind=0;
double ma[],col[];
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ma,INDICATOR_DATA);
   SetIndexBuffer(1,col,INDICATOR_COLOR_INDEX);
   ind=iMA(NULL,0,MAPeriod,0,0,0);
//---
   return(INIT_SUCCEEDED);
  }
CopyBuffer(ind,0,0,rates_total-1,ma);
   for(int i=prev_calculated;i<=rates_total-1;i++)
     {
      if(ma[i]>ma[i+1])
        {
         col[i]=1;
        }
      if(ma[i]<ma[i+1])
        {
         col[i]=0;
        }
     }
 
 
//+------------------------------------------------------------------+
//|                                                      ColorMA.mq5 |
//|                                              Copyright 2020, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, AM2"
#property link      "http://www.forexsystems.biz"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 1
#property indicator_label1  "Color MA"
#property indicator_type1   DRAW_COLOR_LINE
#property indicator_color1  clrBlue,clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
input int MAPeriod=22;
int ind=0;
double ma[],col[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ma,INDICATOR_DATA);
   SetIndexBuffer(1,col,INDICATOR_COLOR_INDEX);
   ind=iMA(NULL,0,MAPeriod,0,0,0);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
   CopyBuffer(ind,0,0,rates_total-1,ma);
   for(int i=0;i<=rates_total-1;i++)
     {
      if(ma[i]>ma[i+1])
        {
         col[i]=1;
        }
      if(ma[i]<ma[i+1])
        {
         col[i]=0;
        }
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
 |  Предыдущая запись в
	 группе Запускаем стороннее приложение и выключаем компьютер с помощью средств MQL | |
| 
	22 октября 2017
 | 
	11 апреля 2020
 | 
Комментарии (1)
5 Gatti Сообщений: 53
Зарегистрируйтесь или авторизуйтесь, чтобы оставить комментарий