int start()
Start using the new style Event Handling Functions - Functions - Language Basics - MQL4 Reference and use strict.if(counted_bars > 0) counted_bars--; limit = Bars - counted_bars;
No need for the decrement. Contradictory information on IndicatorCounted() - MQL4 forumif (i<MoPeriod) break; iniStart = i - MoPeriod; if (i>1) { if (k == iniStart) { BearsMo = DiffBearsBuffer[k]; BullsMo = DiffBullsBuffer[k]; }
Bogus attempt. Your look back for bearsBuffer is zero, your look back for the diff buffers should be bears look back plus MoPeriod. Do your lookbacks correctly. Use two separate loops. Get your initial values once you once you calculate your starting position.if (DiffBearsBuffer[k] > DiffBearsBuffer[k-1])
Never look at future values. The difference should be [k] - [k+MoPeriod] you're not using your parameter at all.
WHRoeder:
- Start using the new style Event Handling Functions - Functions - Language Basics - MQL4 Reference and use strict.
- No need for the decrement. Contradictory information on IndicatorCounted() - MQL4 forum
- Bogus attempt. Your look back for bearsBuffer is zero, your look back for the diff buffers should be bears look back plus MoPeriod. Do your lookbacks correctly. Use two separate loops. Get your initial values once you once you calculate your starting position.
- Never look at future values. The difference should be [k] - [k+MoPeriod] you're not using your parameter at all.
Thank you so so much for your help. You were a great help.
It took a while but i think i understood what you were saying.
I'll attach the new code for review and list out the changes i carried out.
- From what i understood of your explanation, i switched to OnCalculate and used ArraySetAsSeries.
- I majorly left things as is and made tiny changes. I also removed any increments or decrements.
- Finally, i decreased the prev_calculated instead of the rates_total.
I made other minute changes later on but the indicator works now. I deeply appreciate your help and knowledge.
Files:
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
Hello all,
I've been working on a custom indicator. I've followed codes from other indicators but i can't seem to make it work. The second StrengthMo works but does not calculate the current value. The first, Strength-Momentum does not work at all. Can anyone help me to identify what the problem is?
I've attached both codes.