Integrate one indicator into another and use the value

MQL5 指标

工作已完成

执行时间44 秒
客户反馈
Very good job, thanks a lot, until next time!

指定

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


反馈

1
开发者 1
等级
(277)
项目
334
55%
仲裁
14
36% / 29%
逾期
1
0%
空闲
2
开发者 2
等级
(337)
项目
624
38%
仲裁
40
23% / 65%
逾期
93
15%
空闲
发布者: 4 文章, 19 代码
3
开发者 3
等级
(252)
项目
462
26%
仲裁
139
20% / 60%
逾期
100
22%
空闲
相似订单
Create a bot that can trade and read indicators easy to read for first time users. Bot that can be used on a phone and connect to MT5. It should be easy to install or use on any device especially phone and laptop, preferably the bot that can run over night and controllable when needed
These are orderflow footprint indicator I would like to know if you can algorithmisie and build a stacked imbalance bot from them .. Kindlt let me know if you can do it and check the file before replying me
I have 2 trading view indicators by GainzAlgo that I want code to mt5 , could u advise? I need you to give me response if you can convert This
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
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

项目信息

预算
30+ USD
截止日期
 1 天