1) Examples I've seen check the # of bars and if they're less then required in this case 200 then it Prints something like "Not Enough Bars" and returns/exits. If you don't check, then my guess is that its going to give you a moving average for 100 bars... 101 on the next ... 102 etc until it reaches 200 where it caps off and performs as expected.
2) You are correct.
1) Examples I've seen check the # of bars and if they're less then required in this case 200 then it Prints something like "Not Enough Bars" and returns/exits. If you don't check, then my guess is that its going to give you a moving average for 100 bars... 101 on the next ... 102 etc until it reaches 200 where it caps off and performs as expected.
2) You are correct.
thank you ubzen. But then, if you zoom in any chart to its maximum, on my screen it is just 50 bars, you still can plot ema200 for example. So, I am assuming, MT4 is not using visible bars for calculation of MA but takes them from historic data or array somewhere in the memory. No?
my guess is that its going to give you a moving average for 100 bars... 101 on the next ... 102 etc until it reaches 200
Bad guess. Only if they are specifically programmed to so that.
Most indicators call SetIndexDrawBegin() so the line won't start until 200 (in your example) and they don't check - access beyond Bars returns zeros so the indicator is bogus.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I am new to programming but not new to trading.
I have 2, probably, basic questions for now, please:
1. In many indicators using MAs I see lines checking for how many bars are on the chart. So, if I need MA200 and the chart only has, say, 100 bars, would iMA200 work then? I think yes - I checked it out and any MA is drawn without any problems on any chart, so I think this is an old problem that Metaquotes fixed now. So, is there a point of checking how many bars are there on the chart for drawing MA or using iMA function?
2. What is a difference between Close[i] and iClose[i]? My understanding is that Close[i] can return a close of the bars on the current chart only, and iClose can return any close of any currency pair and any timeframe. And in both cases, in order to get a last closed bar I have to use index [1]. Am I seeing it correct?
Thank you.