
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
...
Doc
The answers to the last post :
10. I like the int form better. It does not take too much processing time more (OnInit() is called just once) and allows me to have some return code if necessary. So I use the int for of OnInit() always regardless of do I check for error on initialization or not
11. I do not use the reserve size since the array is going to be re sized only once per new bar (even on a 1 minute chart it is going to be a rare occasion when the array is re sized, and, if they made it as I would, than it just a simple malloc(), memcopy() and free() low level functions to do the work when the array is re sized) . The reserve size is in my opinion good only when you know the maximal size of an array that will be used, and working with chart you never know the final size.
and also...
10. in your t3 indy you wrote:
int OnInit()
{
SetIndexBuffer(0,t3,INDICATOR_DATA);
SetIndexBuffer(1,colorBuffer,INDICATOR_COLOR_INDEX);
return(0);
}
but why not:
void OnInit()
{
SetIndexBuffer(0,t3,INDICATOR_DATA);
SetIndexBuffer(1,colorBuffer,INDICATOR_COLOR_INDEX);
}
11.
when you wrote:
ArrayResize(workSma,bars)
where is the third value? workSma is our array passed by reference, bars is new array size, and reserve size value (excess) where is?...
and another doubt...
double averageRsi = iSma(rsi,AveragePeriod,i,rates_total);
why didn't use the buffer?
averageRsi = iSma(rsi,AveragePeriod,i,rates_total);
I thought was needed for the indicator's data
Doc
That was just an example
You can assign the return value from a function to anything you wish : a buffer element, an array element, variable - anything
and another doubt...
double averageRsi = iSma(rsi,AveragePeriod,i,rates_total);
why didn't use the buffer?
averageRsi = iSma(rsi,AveragePeriod,i,rates_total);
I thought was needed for the indicator's dataMladen
I did talk referred to the creation of rsi sma indy...
Doc That was just an example
...
Doc
In that case use the form you used in your example (this one :
It will work OK the way you wrote it too ...
Mladen I did talk referred to the creation of rsi sma indy...
...
Mladen
Could you please reply me to those 3 questions:
1. about this part of code : iSma(rsi ...
it's like say: iSma(ExtRSIBuffer[]?
2. workSMA it's our sma buffer and you wrote:
double workSma[][2];
First square bracket is for x axis and the second for...I thought Y axis? you wrote "of which second dimension is of size 2" ...but why?
3. You wrote :
for(k=0; k=0; k++)
so for k=0, until k=0 than increase k of 1... but why r-k??? Is there any article for newbie where I can learn much better cycles?
...
Doc
1. Yes
2. Doc, it seems that you are thinking in space and I am thinking in abstract. I am usually bad at explaining things like these but, lets try :
3. the (r-k) is there since the array I use are not set as series but are the usual C/C++ like arrays (that is even the default for buffers in metatrader 5 now if you do not specify that a buffer should be "series like") What doe that mean? In an "regular" array first (oldest) element is having index 0 and the newest (current bar) would be (Bars-1). If it was set as series then the first (oldest would have the (Bars-1) and newest - current would be 0
I use that way for a number of reasons, but the main one is that metatrader (4 and 5) is very, but very slow when you re size an array that is set as series, so I decided to use the C/C++ natural way of using arrays (if they - metatrader - already claim that they are aiming towards C/C++ like language, then I decided to use C/C++ ways instead of metatrader ways)
Mladen
Could you please reply me to those 3 questions:
1. about this part of code : iSma(rsi ...
it's like say: iSma(ExtRSIBuffer[]?
2. workSMA it's our sma buffer and you wrote:
double workSma[][2];
First square bracket is for x axis and the second for...I thought Y axis? you wrote "of which second dimension is of size 2" ...but why?
3. You wrote :
for(k=0; k=0; k++)
so for k=0, until k=0 than increase k of 1... but why r-k??? Is there any article for newbie where I can learn much better cycles?...
PS: attaching an indicator that uses the arrays as explained in the previous post for both rsi and sma calculation and it calculates a smoothed rsi indicator. I hope that this way it will be much simpler to see what and how it is done and that, by making both the rsi and sma as function it allows us "perversions" of simply inverting the order of calculation a in a single line and we can have a completely different indicator. So if you set the Invert to true you are going to get rsi of a sma instead a smoothed rsi (here is a comparison of the 2 : upper is smoothed rsi, lower is an rsi of a sma)...
thanks Mladen,
you are an excellent tutor
but why the cycle of this is incorrect?
...
Doc
If you are referring to the "possible loss of data" warning it is because you declared SmAperiod as double and iSma expects the SmaPeriod to be integer. Change the type of SmaPeriod to int and there will be no warning
As of the rest - you are calculating 2 things : a simple moving average and an rsi. You are not calculating neither smoother rsi nor rsi of an average. If you want a sma of an rsi then the code should be like this :
sma = iSma(rsi ,SmaPeriod,i,rates_total);
All this provided that I do understand what are you trying to achieve
thanks Mladen, you are an excellent tutor