2 indicator in 1 subwindow

 

Hi, every one

when i apply the RSi and then drag the Momentum indicator to RSI subwindow the bottom subwindow will be happen

but when i make an custom indicator like this code:

//+------------------------------------------------------------------+
//|                                                  RSI_Moument.mq4 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_separate_window;
#property indicator_buffers 2;
#property indicator_type1 DRAW_LINE,STYLE_SOLID,1;
#property indicator_color1 clrCyan;
#property indicator_color2 DodgerBlue;
double R[];
double M[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
  SetIndexBuffer(0, R);
   SetIndexLabel(0, "RSI");
     SetIndexStyle(0,DRAW_LINE);
       SetIndexBuffer(1, M);
   SetIndexLabel(1, "Momentum");
     SetIndexStyle(1,DRAW_LINE);

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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 Counted_bars=prev_calculated;
 for (int i= rates_total-Counted_bars-1; i>=0; i--)
 {
   R[i]= iRSI(NULL,0,14,PRICE_CLOSE,i);
   M[i]=iMomentum(NULL,0,14,PRICE_CLOSE,i);
   
 }
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

the comes at second window and be sape of when i make them manually

i want to know ther is a way to make it correct. like have to set of different scale in 1 custom indicator ?

 
Seyedmasoud Hashemi:

Hi, every one

when i apply the RSi and then drag the Momentum indicator to RSI subwindow the bottom subwindow will be happen

but when i make an custom indicator like this code:

the comes at second window and be sape of when i make them manually

i want to know ther is a way to make it correct. like have to set of different scale in 1 custom indicator ?


 ArraySetAsSeries(R,false);
 ArraySetAsSeries(M,false);
for (int i= rates_total-Counted_bars-1; i>=0; i--)
 {
   
   R[i]= iRSI(NULL,0,14,PRICE_CLOSE,i);
   M[i]=iMomentum(NULL,0,14,PRICE_CLOSE,i);
   
   
 }
 

thanks for response 

i add it but still dosen'tsame of the manual way