MODIFICAR INDICADOR

MQL5 지표

명시

Do indicador Vidya preciso um calculo adicional .




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

#property copyright   "2010, MetaQuotes Software Corp."

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

#property description "Variable Index Dynamic Average"

//--- indicator settings

#property indicator_chart_window

#property indicator_buffers         1

#property indicator_plots           2

#property indicator_type1           DRAW_LINE

#property indicator_color1          Blue

#property indicator_width1          3

#property indicator_label1          "VIDYA"

#property indicator_applied_price   PRICE_CLOSE



//--- input parameters

input int                InpPeriodCMO=9;              // Period CMO

input int                InpPeriodEMA=12;             // Period EMA

input int                InpShift=0;                  // Indicator's shift

//--- indicator buffers

double                  VIDYA_Buffer[];

//---

double                  ExtF;

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

//| Custom indicator initialization function                         |

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

void OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,VIDYA_Buffer,INDICATOR_DATA);

//--- sets first bar from what index will be drawn

   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpPeriodEMA+InpPeriodCMO-1);

//--- sets indicator shift

   PlotIndexSetInteger(0,PLOT_SHIFT,InpShift);

//--- name for indicator label

   IndicatorSetString(INDICATOR_SHORTNAME,"VIDYA("+string(InpPeriodCMO)+","+string(InpPeriodEMA)+")");

//--- name for index label

   PlotIndexSetString(0,PLOT_LABEL,"VIDYA("+string(InpPeriodCMO)+","+string(InpPeriodEMA)+")");

//--- calculate smooth factor

   ExtF=2.0/(1.0+InpPeriodEMA);

//--- initialization done

  }


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

//| Variable Index Dynamic Average                                   |

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

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const int begin,

                const long &volume                

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const double &price[])

  {

//--- check for data

   if(rates_total<InpPeriodEMA+InpPeriodCMO-1)

      return(0);

//---

   int limit;

   if(prev_calculated<InpPeriodEMA+InpPeriodCMO-1)

     {

      limit=InpPeriodEMA+InpPeriodCMO-1;

      for(int i=0;i<limit;i++)

         VIDYA_Buffer[i]=price[i];

     }

   else limit=prev_calculated-1;

//--- main cycle

   for(int i=limit;i<rates_total && !IsStopped();i++)

     {

      //--- calculate CMO and get absolute value

      double mulCMO=fabs(CalculateCMO(i,InpPeriodCMO,price));

      //--- calculate VIDYA

      VIDYA_Buffer[i]=price[i]*ExtF*mulCMO+VIDYA_Buffer[i-1]*(1-ExtF*mulCMO);

     }

//--- OnCalculate done. Return new prev_calculated.

   return(rates_total);

  }

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

//| Chande Momentum Oscillator                                       |

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

double CalculateCMO(int Position,const int PeriodCMO,const double &price[])

  {

   double resCMO=0.0;

   double UpSum=0.0,DownSum=0.0;

   if(Position>=PeriodCMO && ArrayRange(price,0)>Position)

     {

      for(int i=0;i<PeriodCMO;i++)

        {

         double diff=price[Position-i]-price[Position-i-1];

         if(diff>0.0)

            UpSum+=diff;

         else

            DownSum+=(-diff);

        }

      if(UpSum+DownSum!=0.0)

         resCMO=(UpSum-DownSum)/(UpSum+DownSum);

     }

   return(resCMO);

  }

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


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


파일:

MQ5
Vidya3.mq5
4.2 Kb

응답함

1
개발자 1
등급
(496)
프로젝트
567
33%
중재
27
44% / 44%
기한 초과
9
2%
로드됨
2
개발자 2
등급
(7)
프로젝트
18
44%
중재
3
0% / 100%
기한 초과
6
33%
무료
3
개발자 3
등급
(564)
프로젝트
933
47%
중재
303
59% / 25%
기한 초과
125
13%
작업중
비슷한 주문
PRECISO QUE COLOCA MAIS ALGUM INDICADOR DE TENDENCIA JUNTO COM ESSE SUPER TREND PARA DAR CONFRUENCIA COM SINAL POSSIVEL COM UMA SETA DE ENTRADA. POSSIVEL 2 INDICADOR DE TENDENCIA PRA CONFIRMA ENTRADA COM SUPER TREND

프로젝트 정보

예산
30 - 200 USD
개발자에게
27 - 180 USD