int nlCOUNTED_BARS = IndicatorCounted(); igINDEX = Bars - nlCOUNTED_BARS - 1; while(igINDEX >= 0) { rgAVGTRUERANGE = iATR(NULL, 0, niLENGTH, igINDEX);Initially the indicator starts computing with igINDEX = Bars-1, but iATR needs to have at least niLENGTH bars to work, so iATR returns zero and all your variables become bogus.
int nlCOUNTED_BARS = IndicatorCounted(); if (nlCOUNTED_BARS < niLENGTH) nlCOUNTED_BARS = niLENGTH; igINDEX = Bars - nlCOUNTED_BARS - 1; :
WHRoeder:
Initially the indicator starts computing with igINDEX = Bars-1, but iATR needs to have at least niLENGTH bars to work, so iATR returns zero and all your variables become bogus.
Initially the indicator starts computing with igINDEX = Bars-1, but iATR needs to have at least niLENGTH bars to work, so iATR returns zero and all your variables become bogus.
That is the point.
Thank you very much for your analysis and support.
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
Dears All,
I'm using a simple ATR trailng stop indicator:
When I call it ont the EA by means of the function "iCustom" I have some unexplainable problems. When I start the EA and, for example (on a 5 minutes time-frame of EURUSD, with 14 and 1 as input values), I monitor the feedback value by an alert each minute, I discover that first values are wrong. After a while, that could be 1-2 ticks or 2-3-4 bars, values become righteous and so remain forever. If I restart the EA (or recompile it modifing a simple comment) also the problem restart. The strange is:
1) The problem
2) The fact that the problem has an unpreditcable duration (few seconds or some minutes, and after that all work ok up to next stop / recompile).
I'm testing the situation just with this simple code:
and I'm not able to understand the problem.
Thanks in advance for any suggestion.