bug: ChartOpen

 

This one work fine as EA:

void OnInit()
{
   
   long chart_2=ChartOpen("AUDUSD",0);
   long chart_3=ChartOpen("EURUSD",0);  
   
   Print(chart_2," ",chart_3);
   ChartClose(chart_2);
   ChartClose(chart_3);

}

but below dont fine as an Indi:

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_plots   3

void OnInit()
{
   
   long chart_2=ChartOpen("AUDUSD",0);
   long chart_3=ChartOpen("EURUSD",0);  
   
   Print(chart_2," ",chart_3);
   ChartClose(chart_2);
   ChartClose(chart_3);

}

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[]
                 )
{ 
   return(rates_total);
}
 
song_song:

This one work fine as EA:

but below dont fine as an Indi:

Hi song_song,

ChartOpen() and ChartClose() function is part of chart operation. Please click this online doc https://www.mql5.com/en/docs/chart_operations. According to that, "All chart operations are allowed in Expert Advisors and scripts only.". So it's not a bug.

 

Documentation on MQL5: Chart Operations
Documentation on MQL5: Chart Operations
  • www.mql5.com
Chart Operations - Documentation on MQL5
 
onewithzachy:

Hi song_song,

ChartOpen() and ChartClose() function is part of chart operation. Please click this online doc https://www.mql5.com/en/docs/chart_operations. According to that, "All chart operations are allowed in Expert Advisors and scripts only.". So it's not a bug.

 

well, thanks onewithzachy
 

my suggestion for mql5 guide:

list of  function availability

function availability    
  EA Indi Script
ChartOpen() V X V
ChartClose() V X V
... ... ... ...
 
song_song:

my suggestion for mql5 guide:

list of  function availability

function availability    
  EA Indi Script
ChartOpen() V X V
ChartClose() V X V
... ... ... ...

Hi song_song,

Mmm ... I don't understand :(.

 

 
onewithzachy:

Hi song_song,

Mmm ... I don't understand :(.

 

function availability
EA Indicator Script
OnStart() No No Yes
OnCalculate() No Yes No
OnTick() Yes No No
ChartOpen() Yes No Yes
ChartClose() Yes No Yes
Reason: