Learn how to design a trading system by Awesome Oscillator

Mohamed Abdelmaaboud | 21 September, 2022

Introduction

Here is a new article in our series about learning how to design a trading system based on the most popular technical indicators for beginners through learning the root of things. We will learn a new technical tool in this article and it will be the Awesome Oscillator indicator as we will identify it in more detail to learn what it is, what it measures, and how to use it based on the main concept behind it through simple strategies, and how to create a trading system based on these mentioned strategies.

We will cover this indicator in detail the same as we mentioned through the following topics:

  1. Awesome Oscillator definition
  2. Awesome Oscillator strategy
  3. Awesome Oscillator strategy blueprint
  4. Awesome Oscillator trading system
  5. Conclusion

We will use the MQL 5 (MetaQuotes Language 5) to write our codes and the MetaTrader 5 trading terminal to execute our designed trading system. The MQL5 is built-in in the MetaTrader 5. If you want to learn how to get and use them, you can read the Writing MQL5 code in MetaEditor topic from a previous article. I advise you to download and try to apply what you learn by yourself to practice and improve your coding skills.

Disclaimer: All information provided 'as is' only for educational purposes and is not prepared for trading purposes or advice. The information does not guarantee any kind of result. If you choose to use these materials on any of your trading accounts, you will do that at your own risk and you will be the only responsible.


Awesome Oscillator definition

In this topic, we will learn about the Awesome Oscillator (AO) indicator in more detail. AO was developed by Bill Williams to measure momentum, it can be used to clarify the power or the control with which party buyers or sellers. It measures this momentum by comparing the momentum of the last five bars or candles with the last 34 bars or candles' momentum at a bigger time frame, in other words, it compares the recent momentum with the momentum of a larger time frame. When we get a confirmation of the AO signal by another technical indicator or tool, it will be significant and more important. So, it will be better to use it accompanied by another technical tool. How we can calculate this indicator manually to understand and deepen our understanding of this indicator, if we want to learn to do that, we can do that through the following steps:

The AO is the difference between the 5- period simple moving average and the 34- period simple moving average. We will use the median price in the calculation of the AO.

MEDIAN PRICE = (HIGH + LOW) / 2 

AO = SMA (MEDIAN PRICE, 5) - SMA (MEDIAN PRICE, 34)

Where:

MEDIAN PRICE = the median price of the instrument

HIGH = the highest price

LOW = the lowest price

AO = the Awesome Oscillator value

SMA = simple moving average

Nowadays, we do not need to calculate it manually as it is available in the MetaTrader 5 as a built-in among different technical indicators and all that we need is to choose it from the trading terminal to appear on the chart.

The following is how to insert it into the chart. While opening the MetaTrader 5 trading terminal, Press Insert tab --> Indicators --> Bill Williams --> Awesome Oscillator

AO insert

After that, we can find the parameters of the AO indicator the same as the following:

AO param

Where:

1 - the color of up values

2 - the thickness of the histogram

3 - the color of down values

After determining these parameters, we will find the indicator inserted into the chart as the follows:

 AO indicator inserted

As we can see in the previous chart that in the lower part of the chart we have the indicator with histogram bars oscillating around zero — this is the measurement of the momentum.


Awesome Oscillator strategy

In this topic, we will learn how to use the AO indicator through some simple strategies for the purpose of education only based on the main concept behind the indicator. You must test any strategy of them before using them on your real account to make sure that it is useful, profitable, and suitable for your trading. Depending on that, you may find that mentioned strategies need optimization as these strategies are the same as we mentioned the main purpose of them is only for education and it is normal to find that. It will be better to use this indicator with another technical indicator to get more effective results especially if we use another technical indicator or tool that can be used to give us more insights more many different perspectives. By the way, this is one of the most important and effective features of the technical analysis as we can use many tools to look at and evaluate the underlining instrument from different perspectives and this will help us to take suitable investment or trading decisions to get good results. In this article, we will combine another technical indicator the moving average the same as we will see in this topic to get more effective buy or sell signals.

Strategy one: AO Zero Crossover

Based on this strategy we need to get a bullish or bearish signal based on the crossover between the current AO value and the zero level. If the current AO value is greater than the zero level, it will be a bullish signal. If the current AO value is lower than the zero level, it will be a bearish signal.

Simply,

The current AO > 0 --> Bullish

The current AO < 0 --> Bearish

Strategy two: AO Strength

According to this strategy, we need to get a signal of the strength of AO movement based on the position of the current AO and the average of 5- period of the last AO values. If the current AO value is greater than the AVG, it will be a signal of the strength of the AO movement. If the current AO value is lower than the AVG, it will be a signal of the weakness of the AO movement.

Simply,

The current AO > AVG 5- period of AO --> AO is strong

The current AO < AVG 5- period of AO --> AO is weak

Strategy three: AO & MA Strategy

According to this strategy, we need to get signals of buy and sell based on the position of the current AO value and the zero level in addition to the position of the closing price and 50- period exponential moving average. If the current AO value is greater than the zero level and at the same time the closing price is greater than the 50- period EMA, it will be a buy signal. If the current AO value is lower than the zero level and at the same time the closing price is lower than the EMA, it will be a sell signal.

Simply,

The current AO > the zero level and the closing price > 50- period EMA --> buy signal

The current AO < the zero level and the closing price < 50- period EMA --> sell signal

Awesome Oscillator strategy blueprint

We will design a step-by-step blueprint for each mentioned strategy to help us to create our trading system easily by organizing our ideas.

Strategy one: AO Zero Crossover

According to this strategy, we need to create a trading system that can be able to generate signals of bullish or bearish based on continuously comparing two values and they are the current AO value and the zero level of AO indicator to determine the position of each value and decide the statue of the market. If the AO value is greater than the zero level, we need the trading system to generate a comment on the chart with the following values:

In the other scenario, if the current AO value is lower than the zero level, we need the trading system to return a comment on the chart with the following values:

The following is for the step-by-step of this trading system:

Algorithmic-Trading-System-Blueprint1

Strategy two: AO Strength

According to this strategy, we need to create a trading system that can be used to generate signals of the strength of AO movement based on continuously comparing two values and which are the current AO and the average of the last five AO values before the current one to determine which one is greater. If the current AO value is greater than the AVG, we need the trading system to return a comment with the following values (Signal and values that were the reason for this signal):

In the other case, if the current AO is lower than the AVG, we need the trading system to return the following values as a comment also:

The following is a step-by-step blueprint of this trading system:

 Algorithmic-Trading-System-Blueprint11

Strategy three: AO & MA Strategy

Based on this strategy the same as we learned in the previous topic, we need to create a trading system that can be used to return a comment with suitable signals of buy and sell on the chart based on continuously comparing four values and they are:

If the current AO is greater than the zero level and the closing price is greater than the 50- period MA, we need the trading system to return the following values as comment on the chart:

In the other scenario, if the current AO value is lower than the zero level and the closing price is lower than the 50- period MA, we need the trading system to return comment on the chart with the following values:

The following is a step-by-step blueprint of this trading system:

Algorithmic-Trading-System-Blueprint111

Awesome Oscillator trading system

In this topic, we will learn the most interesting thing in this article because we will create trading systems for our mentioned trading strategies. First, we will create a simple trading system that will generate a signal as a comment on the chart with the current AO value and we will use it as a base for other trading systems.

The following is for how to create a trading system for this desired signal step-by-step:

Creating array for the aoArray by using the "double" function:

double aoArray[];

Setting the AS_SERIES flag to the aoArray to return a true or false as a boolean value by using the "ArraySetAsSeries" function. Its parameters are:

ArraySetAsSeries(aoArray,true);

Defining the AO indicator by using the "iAO" function to return the handle of the Awesome Oscillator indicator. Its parameters are:

int aoDef = iAO(_Symbol,_Period);

Getting data from the buffer of the AO indicator by using the "CopyBuffer" function. Its parameters are: 

CopyBuffer(aoDef,0,0,3,aoArray);

Defining the AO value after creating a double variable for the aoVal and Normalizing it by using the "NormalizeDouble". Parameters of the "NormalizeDouble" are:

double aoVal = NormalizeDouble(aoArray[0],7);

Returning a comment on the chart with the current AO value by using the "Comment" function.

Comment("AO Value is ",aoVal);

So, the following is the full code to create this trading system:

//+------------------------------------------------------------------+
//|                                                    Simple AO.mq5 |
//|                                  Copyright 2022, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
  void OnTick()
  {
   double aoArray[];
   ArraySetAsSeries(aoArray,true);
   int aoDef = iAO(_Symbol,_Period);
   CopyBuffer(aoDef,0,0,3,aoArray);
   double aoVal = NormalizeDouble(aoArray[0],7);
   Comment("AO Value is ",aoVal);
  }
//+------------------------------------------------------------------+

After compiling this code and being sure that there are no errors, we will find the expert of it in the navigator window the same as the following:

Simple AO nav

By dragging and dropping this expert on the desired chart, we will see the window of this expert the same as the following:

Simple AO win

After ticking next to the "Allow Algo Trading" and pressing "OK", we will find that the expert is attached to the chart the same as the following:

Simple AO attached

As we can see on the chart in the top right corner that we have the expert is attached. Now, we're ready to receive our desired signal and it will be the same as the following:

Simple AO signal

As we can see on the previous chart that we have the desired signal of the current AO as a comment in the top left corner.

Strategy one: AO Zero Crossover

We will create a trading system based on this strategy to receive the desired signals and it will be the same as the following of the full code:

//+------------------------------------------------------------------+
//|                                            AO Zero Crossover.mq5 |
//|                                  Copyright 2022, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
void OnTick()
  {
   double aoArray[];
   ArraySetAsSeries(aoArray,true);
   int aoDef = iAO(_Symbol,_Period);
   CopyBuffer(aoDef,0,0,3,aoArray);
   double aoVal = NormalizeDouble(aoArray[0],7);
   if(aoVal > 0)
     {
      Comment("Bullish","\n"
              "AO Value is ",aoVal);
     }

   if(aoVal < 0)
     {
      Comment("Bearish","\n"
              "AO Value is ",aoVal);
     }
  }
//+------------------------------------------------------------------+

Difference in this code.

Conditions of this strategy,

In case of bullish:

   if(aoVal > 0)
     {
      Comment("Bullish","\n"
              "AO Value is ",aoVal);
     }

In case of bearish:

   if(aoVal < 0)
     {
      Comment("Bearish","\n"
              "AO Value is ",aoVal);
     }

After compiling this code and being sure that there are no errors, we will be able to use and attach it to the chart the same what we mentioned before. So, it will be attached the same as following:

AO Zero Crossover attached

As we can see on the chart that we have the expert is attached to the chart the same as it appears in the top right corner. Now, we will be ready to receive our desired signals.

In case of bullish signal:

AO Zero Crossover - bullish signal

As we can see in the previous chart that we have a comment in the top left corner with the following values:

In case of bearish signal:

AO Zero Crossover - bearish signal

As we can see on the previous chart, we have a comment as a signal with the following values:

So, we got desired signals based on this strategy, in cases of bullish and bearish.

Strategy two: AO Strength

The following is the full code of this trading system:

//+------------------------------------------------------------------+
//|                                                  AO Strength.mq5 |
//|                                  Copyright 2022, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
void OnTick()
  {
   double aoArray[];
   ArraySetAsSeries(aoArray,true);
   int aoDef = iAO(_Symbol,_Period);
   CopyBuffer(aoDef,0,0,6,aoArray);


   double aoCurrVal = NormalizeDouble(aoArray[0],6);
   double aoFifthVal = NormalizeDouble(aoArray[1],6);
   double aoFourthVal = NormalizeDouble(aoArray[2],6);
   double aoThirdVal = NormalizeDouble(aoArray[3],6);
   double aoSecondVal = NormalizeDouble(aoArray[4],6);
   double aoFirstVal = NormalizeDouble(aoArray[5],6);

   double aoAvgVal = NormalizeDouble((aoFifthVal+aoFourthVal+aoThirdVal+aoSecondVal+aoFirstVal)/5,6);

   if(aoCurrVal > aoAvgVal)
     {
      Comment("AO Movement is strong","\n",
              "AO CurrVal : ",aoCurrVal,"\n",
              "AO FirstVal : ",aoFifthVal,"\n",
              "AO SecondVal : ",aoFourthVal,"\n",
              "AO ThirdVal : ",aoThirdVal,"\n",
              "AO FourthVal : ",aoSecondVal,"\n",
              "AO FifthVal : ",aoFirstVal,"\n",
              "AO AvgVal : ",aoAvgVal
             );
     }

   if(aoCurrVal < aoAvgVal)
     {
      Comment("AO Movement is Weak","\n",
              "AO CurrVal : ",aoCurrVal,"\n",
              "AO FirstVal : ",aoFifthVal,"\n",
              "AO SecondVal : ",aoFourthVal,"\n",
              "AO ThirdVal : ",aoThirdVal,"\n",
              "AO FourthVal : ",aoSecondVal,"\n",
              "AO FifthVal : ",aoFirstVal,"\n",
              "AO AvgVal : ",aoAvgVal
             );
     }

  }
//+------------------------------------------------------------------+

Differences in this code:

By using the "NormalizeDouble" function we will define the following values from the current value of AO back to five values:

   double aoCurrVal = NormalizeDouble(aoArray[0],6);
   double aoFifthVal = NormalizeDouble(aoArray[1],6);
   double aoFourthVal = NormalizeDouble(aoArray[2],6);
   double aoThirdVal = NormalizeDouble(aoArray[3],6);
   double aoSecondVal = NormalizeDouble(aoArray[4],6);
   double aoFirstVal = NormalizeDouble(aoArray[5],6);

Defining the AVG of 5-period of AO:

double aoAvgVal = NormalizeDouble((aoFifthVal+aoFourthVal+aoThirdVal+aoSecondVal+aoFirstVal)/5,6);

Conditions of this strategy.

In case of the strength of AO movement:

   if(aoCurrVal > aoAvgVal)
     {
      Comment("AO Movement is strong","\n",
              "AO CurrVal : ",aoCurrVal,"\n",
              "AO FirstVal : ",aoFifthVal,"\n",
              "AO SecondVal : ",aoFourthVal,"\n",
              "AO ThirdVal : ",aoThirdVal,"\n",
              "AO FourthVal : ",aoSecondVal,"\n",
              "AO FifthVal : ",aoFirstVal,"\n",
              "AO AvgVal : ",aoAvgVal
             );
     }

In case of the weakness of AO movement:

   if(aoCurrVal < aoAvgVal)
     {
      Comment("AO Movement is Weak","\n",
              "AO CurrVal : ",aoCurrVal,"\n",
              "AO FirstVal : ",aoFifthVal,"\n",
              "AO SecondVal : ",aoFourthVal,"\n",
              "AO ThirdVal : ",aoThirdVal,"\n",
              "AO FourthVal : ",aoSecondVal,"\n",
              "AO FifthVal : ",aoFirstVal,"\n",
              "AO AvgVal : ",aoAvgVal
             );
     }

After compiling, being sure that there are no errors, and attaching the expert. We will find it the same as the following:

AO Strength attached

As we can see on the chart in the top right corner that the expert is attached.

In case of strength:

AO Strength - strong signal

As we can see on the chart in the top left corner that we have a comment with the following values:

In case of weakness:

AO Strength - weak signal

As we can see on the chart in the top left corner that we have a comment with the following values:

Now, we got desired signals based on this trading system of this strategy.

Strategy three: AO & MA Strategy

The following is the full code of this trading system.

//+------------------------------------------------------------------+
//|                                             AO & MA Strategy.mq5 |
//|                                  Copyright 2022, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
void OnTick()
  {
   MqlRates pArray[];
   double aoArray[];
   double maArray[];

   int Data=CopyRates(_Symbol,_Period,0,1,pArray);
   ArraySetAsSeries(aoArray,true);
   ArraySetAsSeries(maArray,true);
   
   int aoDef = iAO(_Symbol,_Period);
   int maDef = iMA(_Symbol,_Period,50,0,MODE_EMA,PRICE_CLOSE);

   CopyBuffer(aoDef,0,0,3,aoArray);
   CopyBuffer(maDef,0,0,3,maArray);

   double closingPrice = pArray[0].close;
   double aoVal = NormalizeDouble(aoArray[0],7);
   double maVal = NormalizeDouble(maArray[0],7);

   if(aoVal > 0 && closingPrice > maVal)
     {
      Comment("Buy","\n"
              "Closing Price is ",closingPrice,"\n",
              "AO Value is ",aoVal,"\n",
              "MA Value is ",maVal);
     }

   if(aoVal < 0 && closingPrice < maVal)
     {
      Comment("Sell","\n"
              "Closing Price is ",closingPrice,"\n",
              "AO Value is ",aoVal,"\n",
              "MA Value is ",maVal);
     }

  }
//+------------------------------------------------------------------+

Differences in this code.

Creating three arrays of pArray, aoArray, and maArray. We will use the double function the same as what we mentioned except for the pArray, we will use the MqlRates function to store information about the price, volume, and spread.

   MqlRates pArray[];
   double aoArray[];
   double maArray[];

Setting the AS_SERIES flag to arrays of (aoArray) and (maArray) the same as what we mentioned before. Defining Data by using the "CopyRates" function to get historical data of MqlRates structure and its parameters are:

   int Data=CopyRates(_Symbol,_Period,0,1,pArray);
   ArraySetAsSeries(aoArray,true);
   ArraySetAsSeries(maArray,true);

Defining the AO, MA:

AO by using the "iOA" function the same as we mentioned.

MA by using the "iMA" function, its parameters:

   int aoDef = iAO(_Symbol,_Period);
   int maDef = iMA(_Symbol,_Period,50,0,MODE_EMA,PRICE_CLOSE);

Getting data from the buffer of the AO and MA indicators by using the "CopyBuffer" function.

   CopyBuffer(aoDef,0,0,3,aoArray);
   CopyBuffer(maDef,0,0,3,maArray);

Defining the closing price, aoArray, and maArray.

   double closingPrice = pArray[0].close;
   double aoVal = NormalizeDouble(aoArray[0],7);
   double maVal = NormalizeDouble(maArray[0],7);

Conditions of the strategy.

In case of buy signal

   if(aoVal > 0 && closingPrice > maVal)
     {
      Comment("Buy","\n"
              "Closing Price is ",closingPrice,"\n",
              "AO Value is ",aoVal,"\n",
              "MA Value is ",maVal);
     }

In case of sell signal:

   if(aoVal < 0 && closingPrice < maVal)
     {
      Comment("Sell","\n"
              "Closing Price is ",closingPrice,"\n",
              "AO Value is ",aoVal,"\n",
              "MA Value is ",maVal);
     }

After compiling this code and attaching it, we can see it attached the same as the following:

 AO & MA attached

As we can see that we have the indicator attached to the chart in the top left corner from the previous chart. We're ready to get our signals.

In case of buy signal:

 AO & MA - buy signal

As we can see that we have our signal as a comment in the top left corner with the following values:

In case of sell:

 AO & MA - sell signal

We can see the comment in this case with the following values of our signal:


Conclusion

Now, it is supposed that you understood the Awesome Oscillator indicator in detail as you learned what is the AO, what it measures, how we can calculate it manually, and how we can insert it into the chart from the built-in indicators of the MetaTrader 5. We learned also how we could use it through simple strategies based on the main concept behind it after understanding it, these strategies were:

After that, we designed a step-by-step blueprint for each mentioned strategy to create a trading system easily, smoothly, and effectively after organizing our ideas. Then we created a trading system for each mentioned strategy to get automation signals after executing them in the MetaTrader 5 trading terminal.

I hope that you tried to apply what you learned by yourself as this is a very important step in any learning process if we need to develop and improve our skills in addition that this will give you more insights about what you learn or about any related topics. I need to confirm here again that you must test any mentioned strategy before using it to make sure that it is suitable for your trading as there is nothing suitable for everyone.

I hope that you find this article useful for your trading and if you want to read similar articles, you can read my other articles in this series about learning how to design a trading system based on the most popular technical indicators.