indicatormql5mqlmetatrader5

iCustom function problem MQL5 not returning values


I'm not able to get the values ​​of the vwap indicator, does anyone know why?

h_vwap = iCustom(Symbol(), Period(), "VWAP_Simple 2.00","Close price", "Daily", "Tick volume");

enter image description here


Solution

  • h_vwap is the handle of your custom indicator, it is not the value(s) that the indicator computes. You need to add some code to extract the values computed by the indicator. Specifically you need to declare an array that will receive the values.

    double         Label1Buffer[];
    

    then in the OnCalculate / OnTick function you need to copy the values to that buffer.

    int copy=CopyBuffer(h_vwap,0,0,rates_total,Label1Buffer);
    

    Read the doc of iCustom and of CopyBuffer and you can find nice step by step articles on mql5.com such as this one