Integrate one indicator into another and use its value

MQL5 指标

工作已完成

执行时间47 天
员工反馈
Thank You Sir

指定

Hi there,

I'm using two indicators:

1. Hull

2. ATR2


Hull:

//------------------------------------------------------------------
#property copyright "© mladen, 2019"
#property link      "mladenfx@gmail.com"
//------------------------------------------------------------------
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   1
#property indicator_label1  "Hull"
#property indicator_type1   DRAW_COLOR_LINE
#property indicator_color1  clrGray,clrMediumSeaGreen,clrOrangeRed
#property indicator_width1  2

//
//
//
//
//

input int                inpPeriod  = 105;          // Period
input double             inpDivisor = 2.0;         // Divisor ("speed")
input ENUM_APPLIED_PRICE inpPrice   = PRICE_CLOSE; // Price

double val[],valc[];

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//

int OnInit()
{
   SetIndexBuffer(0,val,INDICATOR_DATA);
   SetIndexBuffer(1,valc,INDICATOR_COLOR_INDEX);
      iHull.init(inpPeriod,inpDivisor);
         IndicatorSetString(INDICATOR_SHORTNAME,"Hull ("+(string)inpPeriod+")");
   return (INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//

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[])
{
   int i= prev_calculated-1; if (i<0) i=0; for (; i<rates_total && !_StopFlag; i++)
   {
      val[i]  = iHull.calculate(getPrice(inpPrice,open,high,low,close,i),i,rates_total);
      valc[i] = (i>0) ? (val[i]>val[i-1]) ? 1 : (val[i]<val[i-1]) ? 2 : valc[i-1] : 0;
   }
   return(i);
}

//------------------------------------------------------------------
// Custom function(s)
//------------------------------------------------------------------
//
//---
//

class CHull
{
   private :
      int    m_fullPeriod;
      int    m_halfPeriod;
      int    m_sqrtPeriod;
      int    m_arraySize;
      double m_weight1;
      double m_weight2;
      double m_weight3;
      struct sHullArrayStruct
         {
            double value;
            double value3;
            double wsum1;
            double wsum2;
            double wsum3;
            double lsum1;
            double lsum2;
            double lsum3;
         };
      sHullArrayStruct m_array[];
   
   public :
      CHull() : m_fullPeriod(1), m_halfPeriod(1), m_sqrtPeriod(1), m_arraySize(-1) {                     }
     ~CHull()                                                                      { ArrayFree(m_array); }
     
      ///
      ///
      ///
     
      bool init(int period, double divisor)
      {
            m_fullPeriod = (int)(period>1 ? period : 1);   
            m_halfPeriod = (int)(m_fullPeriod>1 ? m_fullPeriod/(divisor>1 ? divisor : 1) : 1);
            m_sqrtPeriod = (int) MathSqrt(m_fullPeriod);
            m_arraySize  = -1; m_weight1 = m_weight2 = m_weight3 = 1;
               return(true);
      }
      
      //
      //
      //
      
      double calculate( double value, int i, int bars)
      {
         if (m_arraySize<bars) { m_arraySize = ArrayResize(m_array,bars+500); if (m_arraySize<bars) return(0); }
            
            //
            //
            //
             
            m_array[i].value=value;
            if (i>m_fullPeriod)
            {
               m_array[i].wsum1 = m_array[i-1].wsum1+value*m_halfPeriod-m_array[i-1].lsum1;
               m_array[i].lsum1 = m_array[i-1].lsum1+value-m_array[i-m_halfPeriod].value;
               m_array[i].wsum2 = m_array[i-1].wsum2+value*m_fullPeriod-m_array[i-1].lsum2;
               m_array[i].lsum2 = m_array[i-1].lsum2+value-m_array[i-m_fullPeriod].value;
            }
            else
            {
               m_array[i].wsum1 = m_array[i].wsum2 =
               m_array[i].lsum1 = m_array[i].lsum2 = m_weight1 = m_weight2 = 0;
               for(int k=0, w1=m_halfPeriod, w2=m_fullPeriod; w2>0 && i>=k; k++, w1--, w2--)
               {
                  if (w1>0)
                  {
                     m_array[i].wsum1 += m_array[i-k].value*w1;
                     m_array[i].lsum1 += m_array[i-k].value;
                     m_weight1        += w1;
                  }                  
                  m_array[i].wsum2 += m_array[i-k].value*w2;
                  m_array[i].lsum2 += m_array[i-k].value;
                  m_weight2        += w2;
               }
            }
            m_array[i].value3=2.0*m_array[i].wsum1/m_weight1-m_array[i].wsum2/m_weight2;
         
            // 
            //---
            //
         
            if (i>m_sqrtPeriod)
            {
               m_array[i].wsum3 = m_array[i-1].wsum3+m_array[i].value3*m_sqrtPeriod-m_array[i-1].lsum3;
               m_array[i].lsum3 = m_array[i-1].lsum3+m_array[i].value3-m_array[i-m_sqrtPeriod].value3;
            }
            else
            {  
               m_array[i].wsum3 =
               m_array[i].lsum3 = m_weight3 = 0;
               for(int k=0, w3=m_sqrtPeriod; w3>0 && i>=k; k++, w3--)
               {
                  m_array[i].wsum3 += m_array[i-k].value3*w3;
                  m_array[i].lsum3 += m_array[i-k].value3;
                  m_weight3        += w3;
               }
            }         
         return(m_array[i].wsum3/m_weight3);
      }
};
CHull iHull;

//
//---
//

template <typename T>
double getPrice(ENUM_APPLIED_PRICE tprice, T& open[], T& high[], T& low[], T& close[], int i)
{
   switch(tprice)
   {
      case PRICE_CLOSE:     return(close[i]);
      case PRICE_OPEN:      return(open[i]);
      case PRICE_HIGH:      return(high[i]);
      case PRICE_LOW:       return(low[i]);
      case PRICE_MEDIAN:    return((high[i]+low[i])/2.0);
      case PRICE_TYPICAL:   return((high[i]+low[i]+close[i])/3.0);
      case PRICE_WEIGHTED:  return((high[i]+low[i]+close[i]+close[i])/4.0);
   }
   return(0);
}
//------------------------------------------------------------------

In this indicator the value for "inpPeriod" of each candle should be set to

inpPeriod = (1 / ATR2[0]) * 15000). In case of the "dow jones" 15000 is a good number.

That means: inpPeriod should be calculated new for each candle by this formula. As a consequence inpPeriod will be different for each candle.

The value of ATR2[0] should be generated like in the following code:


// ATR2

double      ATR2[];                // array for the indicator ATR2

int         ATR2_handle;           // handle of the indicator ATR2



   // ATR2

      ATR2_handle=iATR(_Symbol,_Period,2);

      if(ATR2_handle < 0) {

         Print("The creation of ATR2_handle has failed: Runtime error =",GetLastError());

         return(-1);

      }



   //ATR2

   if(CopyBuffer(ATR2_handle,0,0,2,ATR2) <= 0){

      Print("CopyBuffer(ATR2_handle,0,0,2,ATR2) <= 0)");

      Message[1] = "CopyBuffer(ATR2_handle,0,0,2,ATR2) <= 0)";

      return(0);

   }

   ArraySetAsSeries(ATR2,true);

   //Set Value

   TTAtr_2[TradeType] = ATR2[0];


反馈

1
开发者 1
等级
(336)
项目
620
38%
仲裁
39
23% / 64%
逾期
93
15%
空闲
2
开发者 2
等级
(74)
项目
121
43%
仲裁
12
33% / 50%
逾期
17
14%
空闲
3
开发者 3
等级
(62)
项目
140
46%
仲裁
19
42% / 16%
逾期
32
23%
空闲
相似订单
Connect from Mt5 via binary deriv account api I have mt5 indicator, need to connect with binary deriv account through api. If anyone can setup via API then contact me. everything control mt5
Hello I am looking for a developer to create an 50% retracement Indicator of the previous candle . So once a candle close the Indicator is supposed to take the full candle size from high to low and make a 61% and 50% level on that candle and I would like the candle to show until the next previous candle is done creating. After this I would look to create an ea with it possibly
Hi, I have 2 indicators which are based on the super trend , the alerts on indicator (1) does not work at all , and on the other indicator the alerts do not come on time on time, which is kind of delayed. see attached file below
Looking for an experienced developer to modify my existing TDI strategy , want to add filter for Buy and Sell Signals, Arrows are displayed on chart and what only to leave high accurate arrows Source code to be provided
I have the mq5 file, I need a buffer adding to the indicator, so it appears in the data window so I can reference it later in an EA. As the below screenshot shows, there is a median ray line from yesterday (the dashed horizontal line) - I want this value in the data window called Median Ray. I want this to be a single value per day, so todays Median Ray would be 17868, and so on each day. So I want all the Developing
I would like to develop my own indicator on metatrader 4 and tradingview. We would start with a basic version that we would improve later. It is an indicator based on several analyses and which would provide several indications. I am looking for someone who can develop on MT4 and Mt5, initially I would like to do it on mt4 and then on mt5. If you have expertise in pinescript it is a plus because I would like to
I urgently require swift assistance to convert a complex indicator into a fully functional scanner, capable of automatically sending real-time data, alerts, and notifications via email, ensuring seamless integration and prompt delivery of critical information to facilitate informed decision-making and timely action
I need to improve the code of an indicator that is too heavy and slow when running and when used with iCustom in an EA. No other changes to the indicator are requested: the original features of the indicator should remain as theay are. I'll provide the indicator after job acceptance. I request final source code mq5 file. Thank you Regards
I have a mt5 indicator that is working perfectly but I will like to make it an expert advisor to have an automated trade. I will be glad if I can get a well experienced developer to execute this project. Thanks
O TRABALHO CONSISTE NA MUDANÇA DO HISTOGRAMA DO INDICADOR TREDN DIRECTION AND FORCE DSEMA SMOOTHED PARA O HISTOGRAMA DA FOTO ANEXA, OBEDECENDO AS TRES CORES VERDE (UP, VERMELHOR(DOWN) E CINZA(TREND). O MESMO TEM QUE ODECER O MESMO CALCULO E COLORIR DA MESMA FORMA POREM COM HISTOGRAMA DDE FORMATO DIFERENTE

项目信息

预算
40+ USD
VAT (19%): 7.6 USD
总计: 47.6 USD
开发人员
36 USD
截止日期
 3 天