Integrate one indicator into another and use the value

MQL5 Indicadores

Trabalho concluído

Tempo de execução 44 segundos
Comentário do cliente
Very good job, thanks a lot, until next time!

Termos de Referência

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


Respondido

1
Desenvolvedor 1
Classificação
(277)
Projetos
334
55%
Arbitragem
14
36% / 29%
Expirado
1
0%
Livre
2
Desenvolvedor 2
Classificação
(337)
Projetos
624
38%
Arbitragem
40
23% / 65%
Expirado
93
15%
Livre
Publicou: 4 artigos, 19 códigos
3
Desenvolvedor 3
Classificação
(252)
Projetos
462
26%
Arbitragem
139
20% / 60%
Expirado
100
22%
Livre
Pedidos semelhantes
I DO NOT need any programming or strategy development. I already have a working NinjaTrader 8 automated strategy based on a 3/5 EMA crossover. I need you to run my existing strategy through NinjaTrader Strategy Analyzer/Optimizer, test the existing adjustable parameters, and find robust settings with the best profit factor and lowest reasonable drawdown. I will provide the existing NinjaScript ZIP. I do not want the
Mr quetta 100+ USD
Yes, that is exactly what I need. The bot should not be restricted to a fixed list of currency pairs. It should technically scan all available Quotex pairs in real time and automatically select the pair where the market conditions are strongest. The bot should analyze each pair using multiple confirmations, such as short-term price momentum, trend direction, market structure, support/resistance, candle formation
Platform: TradingView Programming Language: Pine Script v6 Type: Custom Indicator Project Name: Scalping Reaction Zones + Valid Order Blocks MAIN GOAL I need a custom TradingView indicator for scalping. The indicator must detect: 1. Reaction / Explosion Zones 2. Valid Order Blocks 3. Combined Reaction Zone + Order Block zones The indicator should NOT generate: Buy signals Sell signals TP SL Entry signals Trading
Project Description I am looking for an experienced MQL5/MT5 Expert Advisor developer to develop an automated trading EA for XAUUSD on the M3 timeframe , running on an Exness account . The EA will automate a manual strategy based on SNR/GAP zones , using two setup types: Price Rejection Price Correction The EA should identify valid BUY/SELL setups around predefined SNR/GAP areas, apply configurable RSI, SMA, EMA and
Indicador Maximas e Minimas + Super Trend O Indicador MAX/MIN é um indicador de análise técnica para o MetaTrader 5 , desenvolvido para ajudar você a identificar regiões importantes de preço e possíveis oportunidades de compra e venda. O que ele faz MAX/MIN: identifica máximas e mínimas relevantes do mercado e mostra os preços no gráfico. HH / HL / LH / LL: ajuda a visualizar a estrutura do mercado, mostrando quando
Hello Traders, Have a trading strategy or idea you want to automate? I specialize exclusively in MQL5 development, helping traders turn their concepts into professional trading solutions. Custom Expert Advisors — automate your strategy and reduce manual execution Custom Indicators — transform your market ideas into powerful trading tools Fix & Debug — identify errors and get your existing code working properly
I DO NOT need any programming or strategy development. I already have a working NinjaTrader 8 automated strategy based on a 3/5 EMA crossover. I need you to run my existing strategy through NinjaTrader Strategy Analyzer/Optimizer, test the existing adjustable parameters, and find robust settings with the best profit factor and lowest reasonable drawdown. I will provide the existing NinjaScript ZIP. I do not want the
I'm looking for an experienced developer to create an automated gold trading bot. The bot should be compatible with MetaTrader 4/5 and TradingView. Key Requirements: - Automated trading bot - Compatible with MetaTrader 4/5 and TradingView - Implement scalping and swing trading strategies Ideal Skills and Experience: - Proficiency in trading algorithms - Experience with gold trading - Familiarity with MetaTrader and
I need a robust optimization of my MT5 EA, mainly for XAUUSD (Gold). Please optimize the existing adjustable parameters such as entry/exit settings, SL/TP, trailing/break-even settings, and any other strategy parameters that are appropriate. I want the optimization focused on stable profitability, low/moderate drawdown, and robustness rather than simply the highest possible profit. Please use out-of-sample testing
NinjaTrader 8 / NinjaScript Phase 1 build: convert an existing Auction Market Theory (AMT) strategy into objective, alert-only decision-support logic. Not a bot, no auto-execution — trades stay manual. Covers NQ/MNQ, ES, CL, MGC using 30-min TPO/Volume Profile context with 5-min confirmation: one 5-min close outside VAH/VAL = acceptance, close back inside = rejection. Dashboard shows bias, auction state, location

Informações sobre o projeto

Orçamento
30+ USD
Prazo
para 1 dias