01005379: Yes, SUM of ALL values/Number of values
|
|
|
Can you help me with the code, please? Thank you.
01005379: If you read first post you'll see I did post my attempt via SRC.
| What part of "post your attempt" was unclear? |
What part of "post your attempt" was unclear? |
How much do you want?
The source code you have shown in your first post, cannot in any way be considered a true and serious attempt, because it seems to only convey just a short description of what you want to achieve, even though it makes very little sense at that.
When asked if you knew how a Moving Average is calculated, you responded by saying "SUM of ALL values/Number of values". However, that is not a moving average, that is just a normal single average value over the entire population of data, but even that simple task you did not do in your code and that is why WHRoeder asked where you were "getting the multiple values, summing and dividing" or where you were "putting the values in a buffer and using iMAOnArray to a secondary buffer", showing you that it is much more elaborate and not as simple as just a few lines of code that you presented.
So, since it is obvious that you don't know what a Moving Average is or how it is calculated, or how to make use of the indicator buffers, it is suggested to you that you:- ... go do your research and learn some more about this subject by searching for relevant information and reading up the documentation and example code on this site or on others;
- ... or that you hire someone to code it for you or to mentor or teach you about this subject;
- ... or that you submit a serious attempt at coding this, but unfortunately, at this moment you do not have the knowledge for this, so you are left only with points 1 and 2.
for(int i=0; i<Bars; i++) { double EUR_MA=iMA("EURUSD",0,1,0,MODE_SMA,PRICE_CLOSE,i); double GBP_MA=iMA("GBPUSD",0,1,0,MODE_SMA,PRICE_CLOSE,i); double diff =(GBP_MA-EUR_MA)/places/Point; double ave_diff=(length+ave_diff)/Bars; // I know this is not ok, but don't have idea how to solve this. }
We have no idea what the above highlighted variables are, where they get their values and why you are using them in your calculations.
As WHRoeder has already said.
Place values in a buffer, then use iMAOnArray() to calculate the average.
Your code assumes that Bars has the same value for both symbols. It also assumes that i will access the same time bar for both symbols. This may not be the case if there are missing bars for either symbol.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello!
I would like to know how can I get average of moving average difference. I have this but not working.
Any idea?