Plot two oscillators on the same chart with Expert Advisor

 

Hello

I want to plot RSI and CCI on the same chart.

I tried to use "ChartIndicatorAdd" as described here https://www.mql5.com/en/docs/chart_operations/chartindicatoradd

but it seems not working: RSI and CCI still appear on two separate windows.


Here is the code I run:

int OnInit()
{
   RSIdefinition = iRSI(_Symbol, _Period, PeriodRSI, PRICE_CLOSE);
   if(RSIdefinition == INVALID_HANDLE)
   {
      printf("Error creating RSI indicator");
      return(INIT_FAILED);
   }
   ChartIndicatorAdd(ChartID(), 0, RSIdefinition);

   CCIdefinition = iCCI(_Symbol, _Period, PeriodCCI, PRICE_CLOSE);
   if(CCIdefinition == INVALID_HANDLE)
   {
      printf("Error creating CCI indicator");
      return(INIT_FAILED);
   }
   ChartIndicatorAdd(ChartID(), 0, CCIdefinition);

   return(INIT_SUCCEEDED);
}


I tried modifying the chart_id number and the subwindow number but nothing changes.

Do you have any idea why it doesn't work? Where is my mistake?


Thank you in advance!

Documentation on MQL5: Chart Operations / ChartIndicatorAdd
Documentation on MQL5: Chart Operations / ChartIndicatorAdd
  • www.mql5.com
"the Expert Advisor's properties and specify correct  and  parameters." //| Expert initialization function                                   |                                                                                       ); "Attention! %s: Trying to add MACD(%s/%s) indicator on %s/%s chart. Receiving error 4114" //
Reason: