Hello there, I've got some weird math here. Somehow substracting a double from a double, which are never equal BTW, produces zero. Could please someone explain this phenomena? Below is the code and output. double sixtySMABuffer[]; double sixtySMALowerBandBuffer[]; int init() { SetIndexBuffer(0,sixtySMABuffer); SetIndexBuffer(1,sixtySMALowerBandBuffer); ........... } int start(){ ......... double deviation = 0.0010; for(i = 0; i = limit; i++) { sixtySMABuffer[i] = iMA(NULL, 0, SMA_PERIOD, 0, MODE_SMA, PRICE_CLOSE, i); sixtySMALowerBandBuffer[i] = sixtySMABuffer[i] - deviation; Print(sixtySMABuffer[i] + " : " + sixtySMALowerBandBuffer[i]); ............ } ......... } Print Output : 16:30:09 AUDUSD,M30: 0.77431333 : 0.00000000 16:30:09 AUDUSD,M30: 0.77433500 : 0.00000000 16:30:09 AUDUSD,M30: 0.77434500 : 0.00000000
- Styler - Developing programs
- Executing Trades - Trading Operations
- Strategy Optimization - Algorithmic Trading, Trading Robots
Apparently, using a temporary "buffering" varible instead of direct assignment
to the array element allows to solve the problem i.e. double temporaryValue = sixtySMABuffer[i]
- deviation; sixtySMALowerBandBuffer[i] = temporaryValue; Go figure...
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