Indicador de dos lineas que nunca se cruzan. Ayuda

 

Hola, alguien me puede ayudar. He personalizado un indicador de dos lineas pero cuando le doy en compilar , el indicador muestra dos lineas paralelas que nunca se cruzan, como mostrate en el siguiente pantallazo. Pienso que es algun error en la inicializacion, sin embargo Escribire el codigo por si alguien me puede ayudar a descifrar qué podria estar haciendo mal 

#property copyright "Copyright 2021, MetaQuotes Ltd."

#property link      "https://www.mql5.com"

#property version   "1.00"

#property indicator_separate_window

#property indicator_buffers 8

#property indicator_plots   2

//--- plot AMOM_LB_amom

#property indicator_label1  "AMOM_LB_amom"

#property indicator_type1   DRAW_LINE

#property indicator_color1  clrLime

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1

#include <MovingAverages.mqh>

//--- plot AMOM_LB_amoms

#property indicator_label2  "AMOM_LB_amoms"

#property indicator_type2   DRAW_LINE

#property indicator_color2  clrRed

#property indicator_style2  STYLE_SOLID

#property indicator_width2  1

#include <MovingAverages.mqh>

//--- input parameters

input int      momentum=6;

input int      signal=10;

input int      smoothing=6;

//--- indicator buffers

double         AMOM_LB_amomBuffer[];

double         AMOM_LB_amomsBuffer[];

double         AMOM_LB_srcBuffer[];

double         AMOM_LB_lBuffer[];

double         AMOM_LB_slBuffer[];

double         AMOM_LB_smBuffer[];

double         AMOM_LB_smpBuffer[];

double         AMOM_LB_pBuffer[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,AMOM_LB_amomBuffer,INDICATOR_DATA);

   SetIndexBuffer(1,AMOM_LB_amomsBuffer,INDICATOR_DATA);

   SetIndexBuffer(2,AMOM_LB_srcBuffer,INDICATOR_CALCULATIONS);

   SetIndexBuffer(3,AMOM_LB_lBuffer,INDICATOR_CALCULATIONS);

   SetIndexBuffer(4,AMOM_LB_slBuffer,INDICATOR_CALCULATIONS);

   SetIndexBuffer(5,AMOM_LB_smBuffer,INDICATOR_CALCULATIONS);

   SetIndexBuffer(6,AMOM_LB_smpBuffer,INDICATOR_CALCULATIONS);

   SetIndexBuffer(7,AMOM_LB_pBuffer,INDICATOR_CALCULATIONS);

   

   //--- Barra de inicio

   PlotIndexGetInteger(0,PLOT_DRAW_BEGIN,momentum+signal+smoothing-1);

   

   //---Titulo del indicador

   string shortname;

   StringConcatenate(shortname, "AMOM_LB_amom(",momentum,",",signal,",",smoothing,")");

   PlotIndexSetString(0,PLOT_LABEL, shortname);

   IndicatorSetString(INDICATOR_SHORTNAME, shortname);

   IndicatorSetInteger(INDICATOR_DIGITS,2);

//---

   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[])

  {

//---

   //---calculate values 

   for(int i=1;i<rates_total;i++)

      AMOM_LB_srcBuffer[i] = PRICE_CLOSE;

      AMOM_LB_lBuffer[1]= momentum;

      AMOM_LB_slBuffer[1]= signal;

      AMOM_LB_smBuffer [1]=true;

      AMOM_LB_smpBuffer[1]=smoothing;

      AMOM_LB_pBuffer[1]= 2*AMOM_LB_lBuffer[1]+1;

     

    //SMA

    SimpleMAOnBuffer(rates_total,prev_calculated,1,signal,AMOM_LB_srcBuffer,AMOM_LB_smpBuffer);

    SimpleMAOnBuffer(rates_total,prev_calculated,1,signal,AMOM_LB_srcBuffer,AMOM_LB_pBuffer);

    

    //equivalencias

    

    

    //--- now calculate values of the indicator

   for(int i=momentum+signal+smoothing-1;i<rates_total;i++)

     {

      AMOM_LB_amomBuffer[i]= 100*(((SimpleMAOnBuffer(rates_total,prev_calculated,1,signal,AMOM_LB_srcBuffer,AMOM_LB_smpBuffer)/(SimpleMAOnBuffer(rates_total,prev_calculated,1,signal,AMOM_LB_srcBuffer,AMOM_LB_pBuffer)))-1));

      AMOM_LB_amomsBuffer[i]= SimpleMAOnBuffer(rates_total,prev_calculated,1,signal,AMOM_LB_amomBuffer,AMOM_LB_slBuffer);      

     }

//--- return value of prev_calculated for next call

   return(rates_total);

  }

//+------------------------------------------------------------------+


Descubra las nuevas posibilidades de MetaTrader 5 con la comunidad y los servicios MQL5
Descubra las nuevas posibilidades de MetaTrader 5 con la comunidad y los servicios MQL5
  • www.mql5.com
MQL5 es un lenguaje built-in de estrategias comerciales para el terminal MetaTrader 5. Este lenguaje permite escribir sus propios sistemas automáticos de trading, indicadores técnicos, scripts y bibliotecas de funciones.
Archivos adjuntos:
screenshot.png  97 kb