Trouble pulling indi data via iCustom...

 

Hey gang. I've been struggling for a couple hours to figure out why iCustom in my EA isn't pulling data from an indicator I just coded up.

The indi is working properly on my charts, but within the EA it's only outputting a value of 0 no matter which buffer I try to access.

I've tried different Shift values in iCustom, no difference.

No errors reported from within the EA.

I've double checked iCustom by inserting parameters for another indicator, and those values print fine. For the sake of troubleshooting here's how I'm trying to access the indicator from within the EA:

Print("fvg " + iCustom(Symbol(), PERIOD_CURRENT, "FVG", 100, 1));

Here's the code for the indicator, any insight would be much appreciated!

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 clrLime
#property indicator_color2 clrLime
#property indicator_color3 clrRed
#property indicator_color4 clrRed

input int lineCount = 100;

double fvgHighBull[];
double fvgLowBull[];
double fvgLowBear[];
double fvgHighBear[];
double fvgBuySell[];

double testText[];

int OnInit()
{
    IndicatorShortName("FVG");
    SetIndexBuffer(0, fvgHighBull);
    SetIndexBuffer(1, fvgLowBull);
    SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID,1);
    SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID,1);
    SetIndexLabel(0, "fvgHighBull");
    SetIndexLabel(1, "fvgLowBull");
    
    SetIndexBuffer(2, fvgLowBear);
    SetIndexBuffer(3, fvgHighBear);
    SetIndexStyle(2, DRAW_ARROW, STYLE_SOLID,2);
    SetIndexStyle(3, DRAW_ARROW, STYLE_SOLID,2);
    SetIndexLabel(2, "fvgLowBear");
    SetIndexLabel(3, "fvgHighBear");
    
    SetIndexBuffer(4, fvgBuySell);
    SetIndexLabel(4, "fvgBuySell");
    
    SetIndexBuffer(5, testText);
    SetIndexLabel(5, "testText");
    return(INIT_SUCCEEDED);
}

int deinit()
  {
//----
   return(0);
  }

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[])
{
    for (int i = 0; i < lineCount; i++)
    {
        bool isUpCandle = (open[i] <= close[i]);
        bool isGapClosed = isUpCandle ? (high[i + 2] >= low[i]) : (low[i + 2] <= high[i]);
        bool bearCondition = (close[i + 3] <= high[i + 2]) && (close[i + 1] <= close[i + 2]) && (high[i] < low[i + 2]);
        bool bullCondition = (close[i + 3] >= low[i + 2]) && (close[i + 1] >= close[i + 2]) && (low[i] > high[i + 2]);

        if (bullCondition && !isGapClosed)
        {
            double top = isUpCandle ? low[i] : low[i + 2];
            double bottom = isUpCandle ? high[i + 2] : high[i];

            fvgHighBull[i] = top;
            fvgLowBull[i] = bottom;
            fvgBuySell[i] = 1;
        }

        
        if (bearCondition && !isGapClosed)
        {
            top = isUpCandle ? low[i] : low[i + 2];
            bottom = isUpCandle ? high[i + 2] : high[i];

            fvgLowBear[i] = bottom;
            fvgHighBear[i] = top;
            fvgBuySell[i] = -1;
        }
        
        testText[i] = 69;
    }

    return(rates_total);
}
Documentation on MQL5: Python Integration / order_calc_margin
Documentation on MQL5: Python Integration / order_calc_margin
  • www.mql5.com
order_calc_margin - Python Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Print("fvg " + iCustom(Symbol(), PERIOD_CURRENT, "FVG", 100, 1));

There is no buffer number 100.

0-3 for arrow buffers and 4 for buysell buffer.
 

try :

Print("fvg " + iCustom(Symbol(), PERIOD_CURRENT, "FVG", lineCount, buffer_index ,shift));

Check iCustom documentation.

https://docs.mql4.com/indicators/icustom

iCustom - Technical Indicators - MQL4 Reference
iCustom - Technical Indicators - MQL4 Reference
  • docs.mql4.com
iCustom - Technical Indicators - MQL4 Reference
 
"linecount" can be omitted.