EA that uses a Custom Indicator built from 3 other indicators to generate trade signal - help needed with implementing

 

I have a trade system that I want to backtest in MT4 however I cannot get the EA to correctly implement the indicator that generates the buy/sell signals.  I have built many EA for testing, including some that use custom indicators, but have never come across this particular issue.  

The Trade Signal indicator uses three custom indicators I built and runs through some logic to generate a trade signal. The custom indicators utilize standard included MT4 indicators with some logic around the outcomes to create a the values for the custom indicator buffers. The flow is: Trade_Allowed = Trade Signal Indicator (uses three custom indicators with each custom indicator using standard indicators)

This indicator works as intended when attached to a chart.  It gives a Value of 1 for a buy signal and -1 for a sell signal as expected.  It updates in a tick by tick basis so that if at any point in the Zero candle the conditions are met it displays the trade signal. The indicator is in a separate window on the chart and it adjusts as expected to all timeframes. 

The problem occurs when I put this in an EA and call the Trade Signal indicator using the iCustom function to call the indicator and set a Trade Allowed flag that I then use to enter buy or sell orders. It does not work for initiating trades and when I look at the journal from the back testing it is obviously doing something very different than what I expect it to based on the indicator alone. 


Question: Can I pass the appropriate variables into the Trade Signal custom indicator using the iCustom function in MT4 and do they propagate into the 3 custom indicators that are used in the Trade Signal indicator?


Thank you




Reason: