Scriverò l'indicatore gratuitamente - pagina 103

 

Aiuto per trovare un errore

Aggiunti due buffer all'indicatore, ma non appaiono sul grafico

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

Aiuto per trovare un errore

Ho aggiunto due buffer all'indicatore, ma non vengono visualizzati sul grafico

Ho provato - ma ho ottenuto questohttps://www.mql5.com/ru/code/32179

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

Ho provato - ma ho ottenuto questohttps://www.mql5.com/ru/code/32179

Ce n'è uno per MT4?
 
MakarFX:
Ne avete uno per mt4?

questo dovrebbe funzionare anche su mt4 - controllerò ora, semmai

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

Cercherò di risolverlo - mt4 dà 6 errori

Istantanea.PNG

 
SanAlex:

questo dovrebbe funzionare anche su mt4 - controllerò ora, semmai

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

Cercherò di risolverlo - mt4 dà 6 errori


Puoi guardare il mio codice, è più facile per me capirlo. Non sono un programmatore.
 
MakarFX:
Puoi dare un'occhiata al mio codice, è più facile per me capirlo. Non sono un programmatore.

Ho cercato di capire il tuo codice, ma non ho ancora capito come fare un indicatore di segnale per mt4 e mt5 usando due MA.

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

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

Aiuto per trovare un errore

Ho aggiunto due buffer all'indicatore, ma non sono mostrati sul grafico

#property indicator_color3 Black
#property indicator_color4 Black

Cambia il colore - nero su nero non è molto bello.

 
MakarFX:
Puoi guardare il mio codice, è più facile per me capirlo. Non sono un programmatore.

Ecco una versione funzionante - ma forse hai qualcos'altro in 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);
  }
//+------------------------------------------------------------------+

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

E i segnali dell'indicatore stanno arrivando

rabotaet

 
come convertire un indicatore Stocastico-3 da mt 4 a mt 5
 

I miei saluti alla stimata comunità!

Qualcuno può scrivere un indicatore che visualizzi sul grafico le informazioni sul numero della barra corrente in un certo periodo, che è specificato nelle impostazioni. Per esempio, l'indicatore viene eseguito su giorni, il periodo di segnalazione è un mese specificato nelle impostazioni. Questo significa che l'indicatore visualizza sul grafico il numero che, secondo il conto, è la barra zero dall'inizio del mese solare. Su MT4, per favore)

Buone feste a tutti)

Buona caccia)

Motivazione: