Integrate one indicator into another and use the value

MQL5 Indicadores

Trabajo finalizado

Plazo de ejecución 44 segundos
Comentario del Cliente
Very good job, thanks a lot, until next time!

Tarea técnica

Hi there,

I'm using two indicators:

1. Envelopes

2. ATR2

//+------------------------------------------------------------------+
//|                                                    Envelopes.mq5 |
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   2
#property indicator_type1   DRAW_LINE
#property indicator_type2   DRAW_LINE
#property indicator_color1  Black
#property indicator_color2  Black
#property indicator_label1  "Upper band"
#property indicator_label2  "Lower band"
//--- input parameters
input int                InpMAPeriod=7;              // Period
input int                InpMAShift=0;                // Shift
input ENUM_MA_METHOD     InpMAMethod=MODE_SMMA;        // Method
input ENUM_APPLIED_PRICE InpAppliedPrice=PRICE_CLOSE; // Applied price
input double             InpDeviation=1.2;            // Deviation
//--- indicator buffers
double                   ExtUpBuffer[];
double                   ExtDownBuffer[];
double                   ExtMABuffer[];
//--- MA handle
int                      ExtMAHandle;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtUpBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtDownBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,ExtMABuffer,INDICATOR_CALCULATIONS);
//---
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits+1);
//--- sets first bar from what index will be drawn
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpMAPeriod-1);
//--- name for DataWindow
   IndicatorSetString(INDICATOR_SHORTNAME,"Env("+string(InpMAPeriod)+")");
   PlotIndexSetString(0,PLOT_LABEL,"Env("+string(InpMAPeriod)+")Upper");
   PlotIndexSetString(1,PLOT_LABEL,"Env("+string(InpMAPeriod)+")Lower");
//---- line shifts when drawing
   PlotIndexSetInteger(0,PLOT_SHIFT,InpMAShift);
   PlotIndexSetInteger(1,PLOT_SHIFT,InpMAShift);
//---
   ExtMAHandle=iMA(NULL,0,InpMAPeriod,0,InpMAMethod,InpAppliedPrice);
//--- initialization done
  }
//+------------------------------------------------------------------+
//| Envelopes                                                        |
//+------------------------------------------------------------------+
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 &TickVolume[],
                const long &Volume[],
                const int &Spread[])
  {
   int    i,limit;
//--- check for bars count
   if(rates_total<InpMAPeriod)
      return(0);
   int calculated=BarsCalculated(ExtMAHandle);
   if(calculated<rates_total)
     {
      Print("Not all data of ExtMAHandle is calculated (",calculated,"bars ). Error",GetLastError());
      return(0);
     }
//--- we can copy not all data
   int to_copy;
   if(prev_calculated>rates_total || prev_calculated<0) to_copy=rates_total;
   else
     {
      to_copy=rates_total-prev_calculated;
      if(prev_calculated>0) to_copy++;
     }
//---- get ma buffer
   if(IsStopped()) return(0); //Checking for stop flag
   if(CopyBuffer(ExtMAHandle,0,0,to_copy,ExtMABuffer)<=0)
     {
      Print("Getting MA data is failed! Error",GetLastError());
      return(0);
     }
//--- preliminary calculations
   limit=prev_calculated-1;
   if(limit<InpMAPeriod)
      limit=InpMAPeriod;
//--- the main loop of calculations
   for(i=limit;i<rates_total && !IsStopped();i++)
     {
      ExtUpBuffer[i]=(1+InpDeviation/100.0)*ExtMABuffer[i];
      ExtDownBuffer[i]=(1-InpDeviation/100.0)*ExtMABuffer[i];
     }
//--- done
   return(rates_total);
  }
//+------------------------------------------------------------------+

In this indicator the value for "InpDeviation" should be set to

InpDeviation = 1 + ( (ATR2[0] / 2000)); // accuracy of inpDeviation should be 2 digits, for example "1.34".

by using the value of ATR2[0] genereated by the following code, which should be integrated into the "Envelopes" Indicator:


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


Han respondido

1
Desarrollador 1
Evaluación
(277)
Proyectos
334
55%
Arbitraje
14
36% / 29%
Caducado
1
0%
Libre
2
Desarrollador 2
Evaluación
(337)
Proyectos
624
38%
Arbitraje
40
23% / 65%
Caducado
93
15%
Libre
Ha publicado: 4 artículos, 19 ejemplos
3
Desarrollador 3
Evaluación
(252)
Proyectos
462
26%
Arbitraje
139
20% / 60%
Caducado
100
22%
Libre
Solicitudes similares
Hello, I am looking to develop a commercial-grade Expert Advisor for MT5 specifically optimized for XAUUSD (Gold). The underlying logic should be an intelligent, trend-filtered cost-averaging grid system focused on capital preservation. The EA must include the following functional architecture: 1. Core Strategy Structure: - Must feature a multi-strategy logic entry module. I want to use a combination of 3-4 standard
Generate a signal and place 2 arrows on the chart when these conditions happen. Rules: Levels up:price is below the Kijunsen and Senku A value is less than Senku B value Kijun sen close = previous kijun sen close; Kijun sen close value is LESS than Senku B close value Senkou B close = previous senku B close. Levels down: price is above Kijunsen. Senku A value is above Senku B value
i need the EA same working on trading view chart with same specifications of enter in a trade and sl/tp open 2 trades and 1 trade set tp1 & second trade set to tp 3 but sl should move to breakeven when tp1 hit and go to tp2 sl on tp1
preciso de um programa paracido com o CAP channel com botao de refresh e opcaos de alterar o periodo. utilizava um muito bom, mas o vendedor acredito ter sido excluido da comunidade, sumiu. e o que tinha parou de funcionar
Требуется напи сать пользовательский форекс-индикатор на основе стандартного индикатора ZigZag для торговой платформы МТ5 с фильтрацией колен (граней) по их минимальной длине. Пояснение: используя стандартный индикатор ZigZag для МТ5, добавить в его настройки функцию\опцию задания минимальной длины граней зигзага (чтобы индикатор игнорировал мелкие грани, а рисовал \ отмечал только те грани, длина которых составляет
ZigZag based on oscillators is needed The idea of ​​the indicator Create a ZigZag indicator, which is constructed based on extreme values determined using oscillators. It can use any classical normalized oscillator, which has overbought and oversold zones. The algorithm should first be executed with the WPR indicator, then similarly add the possibility to draw a zigzag using the following indicators: CCI Chaikin RSI
TrendPulse EMA Wick EA 50 - 200 USD
EA specification for MT5 developer (coder‑ready spec) You can copy‑paste this directly into an MQL5 Freelance job. --- 1. General * Platform: MetaTrader 5 (MT5) * Type: Expert Advisor (EA) * Markets: Major FX pairs (configurable list via inputs) * Execution: Market orders only * Timeframes: EA must work on any timeframe, but I will mainly use it on M15–H1 --- 2. Indicators & definitions * EMA 20: Exponential Moving
looking for a highly experienced mql5 developer to build a professional trading ea based on multi timeframe top down analysis and market structure concepts the system should combine higher timeframe context with lower timeframe execution and provide both precise logic and clean visual representation on chart ⸻ core requirements • implementation of multi timeframe logic higher timeframe bias combined with lower
Hey I need help with the development of my ea. I am using a built in indicator and a custom indicator. It shouldn't take too long. I will tell you the conditions and then I just need some help with the coding but I have some experience. Thanks we can chat on whatsap or telegram
I am looking for an experienced MQL4/MQL5 developer to build a custom MT4 indicator from scratch or cracking my ex4 file that i provide to you. I already have an existing indicator (EX4) which produces highly accurate buy/sell signals. I want a similar indicator developed based on its observable behavior and signal structure. my existing indicator is pc id protected so you have to do PC ID security bypass and source

Información sobre el proyecto

Presupuesto
30+ USD
Plazo límite de ejecución
a 1 día(s)