Forum trading, automatic trading systems and testing trading strategies
iTC , 2014.04.22 13:38
Having ordinary AO indicator, even without seeing the graph, you can know what to do to buy or sell, look at the histogram display. That markup.
I found the Awsome Oscillator referenced in documentation for how-to-code indicators in several locations, but didn't think the code example provided as easily identifiable functions for creating an indicator as might be optimal. I made this re-write to provide a more structured coding example - perhaps it will help others who are new to coding in MLQ5 and -- maybe readers will comment and provide their own ideas to make it into a really good example. Optimally, the examples distributed with the terminal would be the best-of-the-best examples of code style and function.
I haven't seen an actual style guide for mql5 programs, like the one here: https://google.github.io/styleguide/cppguide.html. I notice a number of preferences in the coding styles of some of the best developers on the site that are different from that guide, and some that are different from my personal preferences, like
- The curly braces follow the more compressed style resulting in fewer coding lines, and with the brace directly below the first character - such as directly below the f in a for loop. This is good if that is the style, but personally I think it increases the time it takes for the human eye to find the beginning and end of the code blocks.
- member variable names are preceded with m_ where the above guide has them with a trailing underscore. I like the m_ better.
- enumerations are named in the macro naming style versus with a leading k - visually, I prefer the macro naming style, but think technically, the leading k as in the github doc is better.
I added a variable last_prev_calculated to the AO example to keep track of the last fully successful run, and used that as the return value instead of the zero which I think will result in an unnecessary a full start-over - is that a good code practice?
Is there a forum discussion for style that I just haven't found yet?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Awesome Oscillator (AO):
Bill Williams's Awesome Oscillator (AO) is a 34-period simple moving average, plotted through the middle points of the bars (H+L)/2, which is subtracted from the 5-period simple moving average, built across the central points of the bars (H+L)/2.
It shows us quite clearly what’s happening to the market driving force at the present moment. (B. Williams: "New Trading Dimensions: How to Profit from Chaos in Stocks, Bonds and Commodities").
Author: MetaQuotes Software Corp.