Custom Indicator - draws fine on historical data, not on real-time data

 

Hi

Playing with swing highs and lows - LL,LL,LL,HL,HL for Swing Low and HH,HH,HH,LH,LH for Swing High.

If I drop it on a chart... does what I expected it to do. However, doesn't paint entries in real-time and if I test it through an EA, opens trades at wrong entry points. I suspect the indicator is repainting or perhaps there's some other flaw.

How do I change this code so that I get the correct results from an EA reading the indicator values?

Code in EA:

   // Indicators
   string indicatorName = "Swing";
   double swingHigh3 = iCustom(symbol, timeframe, indicatorName, SwingHighSymbol, SwingLowSymbol, 0, 1);
   double swingLow3 = iCustom(symbol, timeframe, indicatorName, SwingHighSymbol, SwingLowSymbol, 1, 1);
   
   // Trade setup
   bool buy = (swingHigh3 != EMPTY_VALUE);
   bool sell = (swingLow3 != EMPTY_VALUE);

Any help would be appreciated.


<*.ex* file has been removed>

 
Sameer Shariff: Playing with swing highs and lows - LL,LL,LL,HL,HL for Swing Low and HH,HH,HH,LH,LH for Swing High. If I drop it on a chart... does what I expected it to do. However, doesn't paint entries in real-time and if I test it through an EA, opens trades at wrong entry points. I suspect the indicator is repainting or perhaps there's some other flaw. How do I change this code so that I get the correct results from an EA reading the indicator values? Code in EA: Any help would be appreciated.
If you need help fixing it, then provide the source code file ".mq4". There is nothing that can be done with an executable ".ex4".