MQL5 code for attaching two indicator to make one indicator

 

Please help mql5 code for attaching two indicator to one indicator 

i have opened RSI indicator in mt5 and then i drag maving average  indicator on it

any one can help the Code of indicator window 1

 
Just save the desired combination of indicators as TEMPLATE ; so you can use that template for each chart ! Don't wait to create someone who will create the 2 indi as 1 .. 
 
nail sertoglu:
Just save the desired combination of indicators as TEMPLATE ; so you can use that template for each chart ! Don't wait to create someone who will create the 2 indi as 1 .. 

 I want to use that indicator in my EA thus why i need such  combination of indicators to one indicator

any one can help mql5 code that will allow this  combination of indicators

 
ENEZA PETER MKIRAMWENI:

 I want to use that indicator in my EA thus why i need such  combination of indicators to one indicator

any one can help mql5 code that will allow this  combination of indicators

#property version   "1.00"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots   2
//--- plot RSI
#property indicator_label1  "RSI"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDodgerBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot MA
#property indicator_label2  "MA"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrFireBrick
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//---
#property indicator_maximum 100
#property indicator_level2  70
#property indicator_level1  30
#property indicator_minimum 0
//--- input parameters
input int      RSIPeriod=14;
input ENUM_APPLIED_PRICE RSIPrice=PRICE_CLOSE;
input int      MAPeriod=9;
input ENUM_MA_METHOD MAMethod=MODE_SMA;
input int      MAShift=0;
//--- indicator buffers
double         RSIBuffer[];
double         MABuffer[];
//---
int handleRSI=INVALID_HANDLE,handleMA=INVALID_HANDLE;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   if((handleRSI=iRSI(_Symbol,_Period,RSIPeriod,RSIPrice))==INVALID_HANDLE ||
      (handleMA=iMA(_Symbol,_Period,MAPeriod,MAShift,MAMethod,handleRSI))==INVALID_HANDLE)
     return(INIT_FAILED);
//---
   IndicatorSetString(INDICATOR_SHORTNAME,StringFormat("RSI(%d) %s(%d)",RSIPeriod,StringSubstr(EnumToString(MAMethod),5),MAPeriod));
   IndicatorSetInteger(INDICATOR_DIGITS,1);
//--- indicator buffers mapping
   SetIndexBuffer(0,RSIBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,MABuffer,INDICATOR_DATA);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
//---
   int toCopy=(rates_total!=prev_calculated)?rates_total-prev_calculated:1;
//---
   if(CopyBuffer(handleRSI,0,0,toCopy,RSIBuffer)!=toCopy ||
      CopyBuffer(handleMA ,0,0,toCopy,MABuffer )!=toCopy)
      return(0);
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
Files:
RSIMA.mq5  3 kb
 
Ernst Van Der Merwe:

Thank you very much what i need is RSI indicator added with moving average

the indicator in between is the one you pasted here what i need is like the last indicator help me please

The Formation of last indicator (i open RSI indicator and then i drag moving average into RSI indicator)

RSI read from min 0 to max 100 but MA read from the price chart

 
ENEZA PETER MKIRAMWENI:

RSI read from min 0 to max 100 but MA read from the price chart

You do this, and what good does it do?

The position of MA and RSI is always in flux and I think it is pointless to show them on the same chart.


If you insist on doing so:

1. find out the maximum and minimum of the MA. (ChartGetDouble) 

2. convert to a percentage where the maximum is 100 and the minimum is 0.


Maybe there is no other way.

 
.
Files:
 
Nagisa Unada:

You do this, and what good does it do?

The position of MA and RSI is always in flux and I think it is pointless to show them on the same chart.


If you insist on doing so:

1. find out the maximum and minimum of the MA. (ChartGetDouble) 

2. convert to a percentage where the maximum is 100 and the minimum is 0.


Maybe there is no other way.

i use this indicator to catch spike in boom and crush  and want to use in My EA thus why i need it so if you now how to make it help me

 
Ernst Van Der Merwe:
.

Thank you very Much for answering my question  i tested but doesn't work the way i was expecting 

when i open RSI indicator and then i drag moving average into RSI indicator

RSI read from min 0 to max 100 but MA read the number from the price chart


 

Have you looked at this code? RSIOnMAOnRSI'

RSIOnMAOnRSI

 
ENEZA PETER MKIRAMWENI:

i use this indicator to catch spike in boom and crush  and want to use in My EA thus why i need it so if you now how to make it help me

You can display that chart by dragging the indicator to a sub-window.

But you can't display it programmatically, because both values have different digits. This is because the digits of both values are different.

To display both on the same screen, you need to adjust the digits of one value to the other, as I explained.

It's not that difficult to program, so you can do it yourself.

Vladimir Karputov:

Have you looked at this code? RSIOnMAOnRSI'

Drag SMA(5) on the RSI(10), select "Preveous Indicator's Data" as the applied price, and click "OK" to close the panel.

Then, open the panel again and change "Preveous Indicator's Data" to "Close".

In this way, the MA will be displayed with its original value. This is probably what he is doing.

Reason: