Error using function ChartSetSymbolPeriod()

 

Hey,
I have an issue using the function ChartSetSymbolPeriod()

Before my EA starts I want the chart to have a certain period (value of ENUM_TIMEFRAMES).

So I use the ChartSetSymbolPeriod() in the OnInit() function of the EA.

When applying the EA to a chart in a MetaTrader account that is in demo mode it works like expected.
But when I klick on the debug button in the editor the chart Period is not modified.
The function returns false but the error code is 0, which does not make sense to me.

My code is:

int OnInit()
  {

   if(!ChartSetSymbolPeriod(ChartID(), ChartSymbol(), PERIOD_M5))
     {
      Print("Error:" + GetLastError());
// Error: 0
     }

   return(INIT_SUCCEEDED);
  }


Thank you for your help!

 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. Check that the TF isn't already M5.
  3. Perhaps, don't call it in OnInit.
  4. Why are you preventing the Human from seeing/trading other TFs?
Reason: