[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 632
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
For example, you need to calculate a simple moving average with PeriodSMA. To calculate the SMA, add the values of the last PeriodSMA bars and divide by the PeriodSMA. It is obvious that for the bars with numbers Bars-1, Bars-2, ..., Bars-PeriodSMA+1 it will not work, because we simply do not have the necessary amount of bars for the calculation (the leftmost bar has Bars-1 index). Therefore, we have to start calculation of the indicator not with the last bar in the chart, but with the bar with the Bars-PeriodSMA index.
Why do they write this value, and not an arbitrary one? It is because this shift of the calculation start allows us to calculate the maximal amount of bars without prejudice to correctness of the calculation.
But keep in mind that this is the simplest case. Sometimes it may not be immediately clear from the code how many past bars the program needs for calculation and where exactly this shift comes from. Well, you should probably ask the developer who wrote the code. But in general, there is a universal way - just look at the code, what in principle the maximum index of the bar can be obtained using price data and index buffers data during the program operation, usually already at this stage it becomes clear...
Thanks for the clarification!
And just to clarify, if I mechanically add 0, will TP and SL work in this type of terminal?
They will, of course they will.
That's what they are for, external variables, to set any values.
But it is easier to place in the initialisation module what you have been advised.
Or in this form:
Variables will be adjusted automatically, and for other needs use multiplier "decimal".
Спасибо за разъяснения!
И просто чтобы уточнить, если я механическим путем добавлю 0, то TP и SL будут работать в данном типе терминалов?
prorab:
They will, of course.That's what they are for, external variables, to set any values.
But it's easier still to put what you've been advised to do in the initialization module.
Or in this form:
Variables will be automatically adjusted, and for other needs use multiplier "decimal"
This task needs clarification:
Good afternoon...
SOS!!! GOOD PEOPLE, HELP!!! I am a beginner in programming in general (I am self-taught), and in MQL in particular. I wrote a simple indicator: RSI + Bollinger Bands in one person. But here is the trouble: if I do not expressly specify the quantity of elements in the array Buf_std_dev (i.e. the array declaration line looks like this: double Buf_std_dev[]), then when displaying this indicator in the client terminal window(CT) I get the following picture:
Explanation of the picture:
a) at the top is RSI, which is available in the set of indicators supplied with CT, and the Bollinger Bands have been dragged to the window of this RSI by drag and drop);
b) at the bottom is the RSI, which is programmed by me;
The compiler does not detect any errors or warnings.
If, on the other hand, when declaring array Buf_std_dev, I explicitly specify number of elements in it (i.e., the array declaration line looks like this: double Buf_std_dev[5502], where 5502 is number of bars, which is obtained using variable Bars), then everything goes back to normal (for as seen from comparison of two indicators: all values are the same):
Can you tell me what to do to save the image, as on the second picture, but explicitly NOT to set the number of elements in the array Buf_std_dev.
P.S. Thank you in advance for the answer.
Code attached (without some parts - can't fit in 4 MB!!!):
Show all code
Please advise if there are ways to dump code over 4Mb here (or dump it here in parts?) ?
If your Buf_std_dev is not an indicator buffer (one of the eight), you need to specify its size, or any size (if you intend to change it (size) in the future) when declaring it.
Right, it isn't... If I may, then two more questions at once:
1. If I assign a buffer to it (the array Buf_std_dev) , it means that it will be displayed in the indicator window, as well?
If I don't assign a buffer to it, then (if I understand correctly) the following situation will occur: assume that I have specified the size of 100 bars. Then when new bars appear (i.e. if for example Bars=101), we will perform calculations only for the last 100 bars we specified (i.e. the oldest bar - 101 - will be discarded). So, when loading history, the array size will always be equal to 100 bars only (or some other value, which I will specify when declaring)?