How to change chart period on code base in oncalculate function for custom indicator?

To add comments, please log in or register
zeno
277
zeno  

Hello,

By trying to switch chart period within oncalculate function in a custom indicator, we use following code below. But the chart automatically closes after the return. How can this be solved? Thank you.

ENUM_TIMEFRAMES periods[] = {PERIOD_M30, PERIOD_H1};
int period_ind;

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[])
{
...
...
...
long currChart=ChartFirst();
ENUM_TIMEFRAMES period = periods[period_ind % (ArraySize(periods))];
ChartSetSymbolPeriod(currChart, ChartSymbol(currChart), period) ; 

return(rates_total);
}
Artem Temnikov
1025
Artem Temnikov  
zeno:

Hello,

By trying to switch chart period within oncalculate function in a custom indicator, we use following code below. But the chart automatically closes after the return. How can this be solved? Thank you.

Programmatically change the current chart timeframe impossible.

But you can create a new chart using ChartOpen .

Alain Verleyen
39017
Alain Verleyen  
zeno:

Hello,

By trying to switch chart period within oncalculate function in a custom indicator, we use following code below. But the chart automatically closes after the return. How can this be solved? Thank you.

Do you really want to change the chart period on each tick ?
Alain Verleyen
39017
Alain Verleyen  
Fleder:

Programmatically change the current chart timeframe impossible.

But you can create a new chart using ChartOpen .

Yes it's possible to change the current chart timeframe.
To add comments, please log in or register