Напишу индикатор бесплатно - страница 103

 

Помогите найти ошибку

Добавил в индикатор два буфера, но они не выводится на график

//+------------------------------------------------------------------+
//|                                                   MTF_Moving.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                             https://www.mql5.com/ru/users/melnik |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com/ru/users/melnik"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Black
#property indicator_color4 Black
#property indicator_type1 DRAW_LINE
#property indicator_type2 DRAW_LINE
#property indicator_type3 DRAW_LINE
#property indicator_type4 DRAW_LINE

double ma_buffer_slow[];
double ma_buffer_fast[];
double ma_buffer_s_01[];
double ma_buffer_s_02[];

//--- input parameters
input int                     PeriodMaSlow   =21;  //Period slow Ma
input int                     PeriodMaFast   =13;  //Pertiod fast Ma
input int                     Points         =50;  //Отклонение
input ENUM_APPLIED_PRICE      PriceMa        = 0;  //Applied price
input ENUM_MA_METHOD          MethodMa       = 0;  //Method Ma
input ENUM_TIMEFRAMES         Timeframe      =60;  //Timeframe for calculate

ENUM_TIMEFRAMES prd;

int index=-1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0, ma_buffer_slow, INDICATOR_DATA);
   SetIndexBuffer(1, ma_buffer_fast, INDICATOR_DATA);
   SetIndexBuffer(2, ma_buffer_s_01, INDICATOR_DATA);
   SetIndexBuffer(3, ma_buffer_s_02, INDICATOR_DATA);
//---
   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[])
  {
//---
   if((rates_total-prev_calculated-PeriodMaSlow)<=0)return(0);
  
   if(Period()>Timeframe) prd=PERIOD_CURRENT;
   if(Period()<=Timeframe) prd=prd=Timeframe;
  
   for(int i=rates_total-prev_calculated-PeriodMaSlow-1;i>=0;i--)
   {
      if(TimeMinute(time[i])==0)index=iBarShift(Symbol(), prd, time[i], false);
      
      ma_buffer_fast[i]=iMA(Symbol(), prd, PeriodMaFast, 0, MethodMa, PriceMa, index);
      ma_buffer_slow[i]=iMA(Symbol(), prd, PeriodMaSlow, 0, MethodMa, PriceMa, index);
      
      if(ma_buffer_fast[i+1]>=ma_buffer_slow[i+1] && ma_buffer_fast[i]<ma_buffer_slow[i])
      {ma_buffer_s_01[i]=ma_buffer_slow[i]+Points*Point;}
      
      if(ma_buffer_fast[i+1]<=ma_buffer_slow[i+1] && ma_buffer_fast[i]>ma_buffer_slow[i])
      {ma_buffer_s_02[i]=ma_buffer_slow[i]-Points*Point;}
   }
  
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
MakarFX:

Помогите найти ошибку

Добавил в индикатор два буфера, но они не выводится на график

я пытался - но получился этот https://www.mql5.com/ru/code/32179

Semaphore MAMA
Semaphore MAMA
  • www.mql5.com
Cигнальный Индикатор - при пересечении двух МА
 
SanAlex:

я пытался - но получился этот https://www.mql5.com/ru/code/32179

А для МТ4 есть?
 
MakarFX:
А для МТ4 есть?

этот тоже должен работать на мт4 - сейчас проверю, если что сделаем 

--------------------

попробую исправить - в мт4 выдаёт 6 ошибок 

Снимок.PNG

 
SanAlex:

этот тоже должен работать на мт4 - сейчас проверю, если что сделаем 

--------------------

попробую исправить - в мт4 выдаёт 6 ошибок 


Ты можешь посмотреть мой код, а то мне в нем проще разобраться. Я не программист.
 
MakarFX:
Ты можешь посмотреть мой код, а то мне в нем проще разобраться. Я не программист.

я пытался твой код разобрать - но я так и не разобрался, что удалось из него слепить для мт4 и мт5 Сигнальный Индикатор по двум МА.

https://www.mql5.com/ru/forum/356653#comment_19450441

Индикаторы: Semaphore MAMA
Индикаторы: Semaphore MAMA
  • 2020.11.27
  • www.mql5.com
Статьи и техническая библиотека по автоматическому трейдингу: Индикаторы: Semaphore MAMA
 
MakarFX:

Помогите найти ошибку

Добавил в индикатор два буфера, но они не выводится на график

#property indicator_color3 Black
#property indicator_color4 Black

цвет поменяй, ато черное на черном, как то не комильфо

 
MakarFX:
Ты можешь посмотреть мой код, а то мне в нем проще разобраться. Я не программист.

Вот рабочий вариант - только может ты другое что то задумывал ?

//+------------------------------------------------------------------+
//|                                                   MTF_Moving.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                             https://www.mql5.com/ru/users/melnik |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com/ru/users/melnik"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
#property indicator_color1 Wheat
#property indicator_color2 LightSeaGreen
#property indicator_color3 Red
#property indicator_color4 Blue
#property indicator_type1 DRAW_ARROW
#property indicator_type2 DRAW_ARROW
#property indicator_type3 DRAW_LINE
#property indicator_type4 DRAW_LINE

double ma_buffer_slow[];
double ma_buffer_fast[];
double ma_buffer_s_01[];
double ma_buffer_s_02[];

//--- input parameters
input int                     PeriodMaSlow   =21;  //Period slow Ma
input int                     PeriodMaFast   =13;  //Pertiod fast Ma
input ENUM_APPLIED_PRICE      PriceMa        = 0;  //Applied price
input ENUM_MA_METHOD          MethodMa       = 0;  //Method Ma
input ENUM_TIMEFRAMES         Timeframe      =60;  //Timeframe for calculate

ENUM_TIMEFRAMES prd;

int index=-1;
//--- right input parameters flag
bool flag_buy   = false;
bool flag_sell  = false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   string short_name;
   IndicatorDigits(Digits+1);
   IndicatorBuffers(4);
//--- indicator buffers mapping
   SetIndexBuffer(2, ma_buffer_slow, INDICATOR_DATA);
   SetIndexBuffer(3, ma_buffer_fast, INDICATOR_DATA);
   SetIndexBuffer(0, ma_buffer_s_01, INDICATOR_DATA);
   SetIndexBuffer(1, ma_buffer_s_02, INDICATOR_DATA);
//--- setting the indicator to be drawn as a line
   SetIndexStyle(0,DRAW_ARROW,EMPTY,2,clrWheat);
   SetIndexArrow(0,72);
   SetIndexBuffer(0,ma_buffer_s_01);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,2,clrLightSeaGreen);
   SetIndexArrow(1,71);
   SetIndexBuffer(1,ma_buffer_s_02);
//--- setting the indicator to be drawn as a line
   SetIndexStyle(2,DRAW_LINE,EMPTY,2,clrRed);
   SetIndexBuffer(2,ma_buffer_slow);
   SetIndexStyle(3,DRAW_LINE,EMPTY,2,clrBlue);
   SetIndexBuffer(3,ma_buffer_fast);
//--- setting a name in the DataWindow window and a label
   short_name="MTF_Moving";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//---
   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[])
  {
//---
   if((rates_total-prev_calculated-PeriodMaSlow)<=0)
      return(0);
   if(Period()>Timeframe)
      prd=PERIOD_CURRENT;
   if(Period()<=Timeframe)
      prd=prd=Timeframe;
   for(int i=rates_total-prev_calculated-PeriodMaSlow-1; i>=0; i--)
     {
      if(TimeMinute(time[i])==0)
         index=iBarShift(Symbol(), prd, time[i], false);
      ma_buffer_fast[i]=iMA(Symbol(), prd, PeriodMaFast, 0, MethodMa, PriceMa, index);
      ma_buffer_slow[i]=iMA(Symbol(), prd, PeriodMaSlow, 0, MethodMa, PriceMa, index);
        {
         if(flag_sell==false)
            //--- check for short position (SELL) possibility
            if(ma_buffer_fast[i]>ma_buffer_slow[i])
              {
               ma_buffer_s_02[i]=Low[i];
               flag_buy=false;
               flag_sell=true;
              }
         if(flag_buy==false)
            //--- check for long position (BUY) possibility
            if(ma_buffer_fast[i]<ma_buffer_slow[i])
              {
               ma_buffer_s_01[i]=High[i];
               flag_buy=true;
               flag_sell=false;
              }
        }
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

--------------------------------------------------------

И сигналы от индикатора поступают 

rabotaet

 
как переделать индикатор Stochastic-3 из мт 4 в мт 5
 

Моё почтение уважаемому сообществу!

Кто нибудь сможет написать индикатор, который будет выводить на чарт информацию о порядковом номере текущего бара, в определённом, указанном в настройках периоде. Например, индикатор запущен на днёвках, в настройках выбран отчётный период месяц. Значит, индюк выводит на график число, каким по счёту является нулевой бар от начала календарного месяца. На МТ 4, пожалуйста)

С Наступающем всех)

Удачной охоты)

Причина обращения: