![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi
I'm really quite stuck and not sure how to proceed, so I'm hoping for some inspiration really.
I've written a function that uses a Bollinger band with deviation of 2 and another with a deviation 1 which I use to look for a 'zone' and a 'squeeze'. The squeeze is found using the calculation (upperBB value - lower BB value)/mid band value. I was then dividing that by the ATR value to give me the bandwidth as a ratio to ATR. After a 'squeese' the the EA I'm developing uses a combination of RSI, ADX and OBV values and where price is in relation to the BB bands, to look for valid trade.
Initially it all seemed to work, then I noticed my EA would generate unexpected trades in strange places. I used the MetaEditor's debuger to step through my code and found logical conditions not following the rules of logic! So basically although the individual indicator functions were returning false for say a long trade. The condition was being set to true. For example, the code below would end up with newSignalsGoLong holding true, when currBBzone had the string "upperZone" or "middleZone".
I even made made newSignalsGoLong=false and commented out the other conditions and still newSignalsGoLong gets miraculously set to true and a trade is actioned.This reminded me of similar problems way back in my programming history with Borland C, where I had done something that caused my code to corrupt memory, because say I had messed up using arrays. I've spent two days double checking array definitions and such and and they seem ok and look like those used in others people's tutorials. It seems that the problem comes down to the function to calculate the squeeze. This is the function:
I back tested this for 6 months. with those two lines of division commented out and the other conditions commented out no trades are opened. However, I've copied this function into the TruthfullTrading BB Tutorial code and it seems to run without weird behaviour, but I guess that could just be luck and how the compiler has compiled the code.
Now I'm at a loss on how to proceed, I've spent over 24 hours on this 'weirdness' and I'm out of ideas. I'm wondering if anyone else has experience such problems and what else may cause the problems?
Thank you for reading and even more thanks if you can you point me in the direction of the problem.