Integrate one indicator into another and use its value

MQL5 Indicators

Job finished

Execution time 47 days
Feedback from employee
Thank You Sir

Specification

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];


Responded

1
Developer 1
Rating
(336)
Projects
623
38%
Arbitration
39
23% / 64%
Overdue
93
15%
Working
Published: 4 articles, 19 codes
2
Developer 2
Rating
(75)
Projects
123
43%
Arbitration
12
33% / 50%
Overdue
17
14%
Free
3
Developer 3
Rating
(64)
Projects
144
46%
Arbitration
19
42% / 16%
Overdue
32
22%
Free
Similar orders
Hi guys got 70$ left in my account and looking for an indicator that is profitable. I'm not stupid so you won't be able to convince me if it's not actually profitable. Please send screenshots and explain how it's meant to be used. ( I want an all in one indicator which means it can be used alone to place trades and I won't to need to use other tools with it) Waiting to hear from you guys
I require a professional MT4 developer to decipher an existing expert advisor that I have and to include Simple Moving Average strategy inside (50, 100, 200, 400). I don't have the source code so the developer would have to be proficient enough . Thanks
i have an ea that works as a pair with an indicator i created. i want to add an adaptive moving average as a higher timeframe filter. i want the AMA/DEMA to function as the free indicator on mt5 does and works where when price is above the AMA on the higher timeframe only buy trades would be taken on the timeframe selected for trading and vice versa. if both filters can be implemented then i would need it to function
ATTENTION : 20 usdt like gift at the end of the job. Dear developper, I need a developper will be able to write an indicator based on many strategies. The indicators will use following indicators : zigzag 65,5,3 ma 200 MA1 SUPPLY DEMAND 1.7 SUPER TREND 1.01 PERIOD ATR 80 ATR MULTIPLIER 3.0 SUPPORT AND RESISTANCE INDICATOR The indicator will use trendline and support and resistance retest and breakout if a
Hello , I'm searching for someone able to analyze a XAUUSD scalping strategy which is having a return of 100% a year. I have full access to the mt4 and mr5 account where this strategy is being used, with investor credentials. Thanks
I'm seeking a skilled developer familiar with ICT (Inner Circle Trader) concepts or Smart Money Concepts (SMC) to help build a custom MT4 Indicator or Expert Advisor (EA) . 🔧 You can use my existing source code or start from scratch — whatever suits your workflow best. 📈 Project involves: SMC/ICT-based market structure logic FVG, BOS, CHoCH, Liquidity Zones MTF Dashboard User-friendly interface (toggle buttons
Hello, I hope my message finds you well. I have an indicator which works perfectly, that i would like you to modify . It normally display daily area from a specific period of time . What i want is to add a fibonnaci retracement from yesterday zone to display today. the fibonnaci is starting from the lowest point of the zone to the the highest point. It should be upgrade itself depending of the zone , each day at
Hello loooking for a I’m looking for a skilled NT8 developer to help me build a custom tool based on specific trading concepts. The features I want to include are: Candle Timer – Real-time countdown showing how much time is left in the current candle. Bid and Ask Levels – Live display, possibly plotted on the chart. Harmonic Pattern Detection – Automatic identification and drawing of patterns like Gartley, Bat
New or old Ea. 30 - 200 USD
Hello Dev Team, am have looking for an experienced Ea programmer who can build any type of EA with his/her expertise or who already have any type of Ea,bot,indicator or HFT, with winning rate of 85% to 95%. Please DO NOT contact or respond if you don’t have or can’t provide any Ea of such request, because I will give you a bad review on lack of understanding of your roles
it might be a quick job there is already fibo but need to make it appear/ not appear with next inside fibo wave with 'bool allow_fibo_inside_previousfibo = false/ true;' add buffers for 3 different fibo levels clean and fast mq4 code is required

Project information

Budget
40+ USD
VAT (19%): 7.6 USD
Total: 47.6 USD
For the developer
36 USD
Deadline
to 3 day(s)