Voy a escribir el indicador de forma gratuita - página 103

 

Ayuda para encontrar un error

Se han añadido dos topes al indicador, pero no aparecen en el gráfico

//+------------------------------------------------------------------+
//|                                                   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:

Ayuda para encontrar un error

He añadido dos topes al indicador, pero no se muestran en el gráfico

Lo he intentado, pero he conseguido estohttps://www.mql5.com/ru/code/32179

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

Lo he intentado, pero he conseguido estohttps://www.mql5.com/ru/code/32179

¿Hay uno para MT4?
 
MakarFX:
¿Tienes uno para mt4?

este también debe funcionar en mt4 - Voy a comprobar ahora, si algo

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

Voy a tratar de arreglarlo - mt4 da 6 errores

Instantánea.PNG

 
SanAlex:

este también debe funcionar en mt4 - Voy a comprobar ahora, si algo

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

Voy a tratar de arreglarlo - mt4 da 6 errores


Puedes mirar mi código, es más fácil para mí entenderlo. No soy programador.
 
MakarFX:
Puedes echar un vistazo a mi código, es más fácil para mí entenderlo. No soy programador.

He intentado averiguar tu código, pero aún no he descubierto cómo hacer un indicador de señal para mt4 y mt5 usando dos MAs.

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

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

Ayuda para encontrar un error

He añadido dos topes al indicador, pero no se muestran en el gráfico

#property indicator_color3 Black
#property indicator_color4 Black

Cambia el color: el negro sobre negro no es muy agradable.

 
MakarFX:
Puedes mirar mi código, es más fácil para mí entenderlo. No soy programador.

Esta es una versión que funciona, pero tal vez tengas algo más en mente.

//+------------------------------------------------------------------+
//|                                                   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);
  }
//+------------------------------------------------------------------+

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

Y las señales del indicador están llegando

rabotaet

 
cómo convertir un indicador Estocástico-3 de mt 4 a mt 5
 

¡Mis saludos a la estimada comunidad!

Puede alguien escribir un indicador que muestre en el gráfico la información sobre el número de barra actual en un determinado período, que se especifica en la configuración. Por ejemplo, el indicador se ejecuta en días, el período de información es un mes especificado en la configuración. Esto significa que el indicador muestra en el gráfico el número que, según la cuenta, es la barra cero desde el inicio del mes natural. En MT4, por favor)

Felices fiestas a todos)

Feliz caza)