ChartOpen not returning long ChartID?

To add comments, please log in or register
HarriMQL5
330
HarriMQL5  

Hello

‌In th‌e init section of an EA Im successfully opening a chart of a different timeframe. (The chart opens). However, ChartOpen is not returning the chart id, which according to this it should. Instead it returns 0, and printing GetLastError says "internal error"‌

After opening the chart I want to apply a template with an indicator ‌using ChartApplyTemplate, but this functions needs the chartid

Any ideas? Thank you.

    tpChartID = ChartOpen(Symbol(), TMPRD);

    if (tpChartID==0) {
        Print(ErrorDescription(GetLastError()));
        Print("ChartID = ",tpChartID);
        return(INIT_FAILED);
    }

    if (!ChartApplyTemplate(tpChartID, "\\indicators\\FlowTP.tpl")) {
        Print("Could not apply template");
        return(INIT_FAILED);
    }

Documentation on MQL5: Chart Operations / ChartOpen
Documentation on MQL5: Chart Operations / ChartOpen
  • www.mql5.com
Chart Operations / ChartOpen - Reference on algorithmic/automated trading language for MetaTrader 5
To add comments, please log in or register