Can't seem to be able to fetch indicator data from external chart running the same indicator (Using iCustom)

 

Been trying multiple solutions, my current one seems like the one that was going to work but no.

The idea is that the indicator will be running on multiple charts (in the same mt4 terminal), the solution I am trying to work should fetch the indicator value 

[in this case I attempted to use iCustom to fetch the value then will check that value against an array to use later in order to display a signal the indicator found in another chart]

I am certain the code to select the chart is not the issue and the arrays I am passing have values assigned so I have no idea where the issue is. 

Note: when I run the LoadStates() function, MT4 crashes.

double FetchIndicatorBufferValue(long chartID, string indicatorName, int bufferIndex, int shift, bool print_){
    
    double value = iCustom(liveSymbols[shift],livePeriods[shift],indicatorName, 
                           comm,TimeFrame,MaType,PriceH,PriceL,FMaLength,cm,FVidyaSmoothPeriod,FPct,FHLPeriod,FBandUpClr,FBandDnClr,
                           co,MMaLength,MVidyaSmoothPeriod,MPct,MHLPeriod,MBandUpClr,MBandDnClr,
                           cx,SMaLength,SVidyaSmoothPeriod,SPct,SHLPeriod,SBandUpClr,SBandDnClr,
                           UnmetCon,c,ShowState,fontSz,bufferIndex,/*shift*/1);
      
    if(print_ == true && value > 0) Print(indicatorName," -> ","Chart :", chartID, " State = ", value, " buff: ", bufferIndex);
    if(print_ == true && (value == 0 || value == -1)) Print("iCustom() failed");//Print(indicatorName," -> ","Chart :", chartID, " State = ", value, " buff: ", bufferIndex);   
      
    // Check if the value is valid (not EMPTY_VALUE)
    if (value == EMPTY_VALUE)
    {
        Print("Error: Could not fetch value from buffer ", bufferIndex, " of ", indicatorName, " on chart ID ", chartID);
        return -2;// cant use -1 for bad result, as its == "Short" int && 0 is == "No signal" int
    }

    return value;
}

string LoadStates( int i){
  string res; 
     if(FetchIndicatorBufferValue(liveIDs[i],"HTLT Alerts V5",0,i,true) == 1)  res = "Long";
else if(FetchIndicatorBufferValue(liveIDs[i],"HTLT Alerts V5",0,i,true) == -1) res = "Short";
else if(FetchIndicatorBufferValue(liveIDs[i],"HTLT Alerts V5",0,i,true) == 0)  res = "No Signal";
   else res="ERROR";
   if(res != "ERROR") liveStates[i] = res;
  return res; 
}
Documentation on MQL5: Technical Indicators / iCustom
Documentation on MQL5: Technical Indicators / iCustom
  • www.mql5.com
The function returns the handle of a specified custom indicator. Parameters symbol [in] The symbol name of the security, the data of which should...
 

note that there's a different section of the forum for MT4 related questions

will MT4 iCustom ever be equal to EMPTY_VALUE

 
Monwabisi Balani:
    double value = iCustom(liveSymbols[shift],livePeriods[shift],indicatorName, 
                           comm,TimeFrame,MaType,PriceH,PriceL,FMaLength,cm,FVidyaSmoothPeriod,FPct,FHLPeriod,FBandUpClr,FBandDnClr,
                           co,MMaLength,MVidyaSmoothPeriod,MPct,MHLPeriod,MBandUpClr,MBandDnClr,
                           cx,SMaLength,SVidyaSmoothPeriod,SPct,SHLPeriod,SBandUpClr,SBandDnClr,
                           UnmetCon,c,ShowState,fontSz,bufferIndex,/*shift*/1);
  1. On MT5, iCustom retuns a handle, not a double. Moved to MT4 forum. Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893

  2.      if(FetchIndicatorBufferValue(liveIDs[i],"HTLT Alerts V5",0,i,true) == 1)  res = "Long";
    else if(FetchIndicatorBufferValue(liveIDs[i],"HTLT Alerts V5",0,i,true) == -1) res = "Short";
    else if(FetchIndicatorBufferValue(liveIDs[i],"HTLT Alerts V5",0,i,true) == 0)  res = "No Signal";
    

    Don't use strings when you mean an enumeration

  3. On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)

 
William Roeder #:
  1. On MT5, iCustom retuns a handle, not a double. Moved to MT4 forum. Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893

  2. Don't use strings when you mean an enumeration

  3. On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)

Seems there is quite a lot wrong with these particular functions. Will rewrite and ask for help on mt4 forum if problem persists. Thank you