I'm trying to develop a strategy and an EA based on the Dynamic Stochastic indicator. May be it already exist but it is a learning experiment. I'm not interested on how profitable it is, I'm just learning MQ4. Well, testing my EA I noticed a strange behavior that I would like to understand. Let me explain what happens.

The Dynamic Stochastic uses the BollingerBands, calculated on the Main indicator line, to get the oversold/overbougt levels (instead of usuals 20/80 - 30/70 level) and uses the median line instead of 50 level. The external parameters are K% Period, D% period, Smoothing, BB period, Deviation.

At Start(), my EA uses the iCustom function to call the DS, passing all 5 parameters, in order to get Main Stoch, Median BB, UpBB, DnBB values.

The parameters values have been defined as #external to allow optimization and have been inizialized at the default values of Dynamic Stochastic indicators.

The EA calculates the buy/sell signals only at candle close, so I tested my EA (without optimization, leaving the default parameter values, just to test the buy/sell signals) using the "Open price only" model on a short period (2 months) and I got, let say, 52 trades.

At the same time I noticed that, for each single call at iCustom call, the Journal reported "Custom indicator Dynamic Stochastic USDCHF, H1: Loaded succesfully" and immediately next "Custom indicator Dynamic Stochastic USDCHF, H1: Removed". The tester was very slooooooow.

Because some other EAs that I looked at, using the iCustom in the same way, were faster and were not showing any message, I decided to call the iCustom without the 5 parameters. This time (same Symbol, same Model, same timeframe) the Strategy tester was fast and was not showing any message in the Journal tab. Unfortunately, the number of trades was MORE THAN DOUBLE compared with the previous test.

Is it normal? How is it possible? The EA calculates the signals in the same way (starting of a new candle), and the number of candles (same starting/end date testing period, same timeframe) is exactly the same.

In theory, I should have the SAME NUMBER of trades. The first time I was PASSING the default indicator parameters, the second time I was USING the default indicator parameters. Were is the difference? I could accept that passing the parameters involves more CPU time and, for this reason, the tester is slow, but it seems that the indicator calculation produces different results and so different number of trades.

Have you ever noticed such a behavior? What I'm doing wrong? Any suggestion/tip is welcome.

Many thanks