Get an integer from a custom indicator

 
I am trying to use a custom indicator to take the trading decision. So I am expecting a "1" for buy and "2" for Sell. How can I implement that?. I tried to add another buffer, but unsuccessful. Also tried to return the integer using return(x). My iCustom calling is working fine and inside the custom indicator, buy and sell decisions are taking correctly, but I am not able to send that result to the EA to process the trade. Thanks in advance for the help.
 
the correct way is to use indicator buffers. If the indicator can give signals and draw arrows into the chart then these arrows can be found in indicator buffers. The iCustom() call can give you any value in any buffer for any bar. You just have to check the buffers for the appearance of these arrows.

Use the data window to explore the contents of the buffers when it is attached to a chart and you move the mouse around the chart to get a first impression what buffers are available with this indicator and what data they contain.

If there is NO arrow then the corresponding buffer cell is usually EMPTY_VALUE, so you just check for EMPTY_VALUE and if it is NOT EMPTY_VALUE then there is an arrow. Sometimes it is 0 instead of EMPTY_VALUE, so make sure you study the indicator first (and Print() the values) to see what exactly it does with its buffers.

// the two last arguments for iCustom() are buffer number and bar number.
// sometimes the arrow will appear not on bar 0 but on bar 1 instead (after the close).

if (iCustom(...) != EMPTY_VALUE){   // check the buffer with the long signals
   // ...long arrow detected...
   // ...lets buy
}

if (iCustom(...) != EMPTY_VALUE){   // check the buffer with the short signals
   // ...short arrow detected...
   // ...lets sell
}


If this is not working for you then you made some mistake. Buffers and reading them through iCustom() is the way to go.
Reason: