preview
Learn how to design a trading system by Accelerator Oscillator

Learn how to design a trading system by Accelerator Oscillator

MetaTrader 5Trading | 28 September 2022, 14:48
6 557 1
Mohamed Abdelmaaboud
Mohamed Abdelmaaboud

Introduction

Here is a new article from our series about how to design a trading system based on the most popular technical indicators. We will learn in this article a new technical tool that can be used in our favor in trading. We will learn about the Accelerator Oscillator indicator (AC) in detail as we learn what it is, what it measures, how it can be calculated, how to read it and use it also through simple trading strategies then how we can create a trading system based on them.

The following topics will be our path to learn more about this indicator:

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

We will use the MQL5 (MetaQuotes Language 5) to write our codes by it which is built-in in the MetaTrader 5 trading terminal which will be used to execute our trading system. If you do not know how to download the MetaTrader 5 and how to use MQL5, you can read the topic of Writing MQL5 code in MetaEditor from a previous article to learn more about that. All mentioned strategies here are designed for educational purposes only and you must test them before using them in your real account to make sure that they are profitable and suitable for you and I advise you to try to apply what you learn if you want to improve your trading and coding skills as this step is an important step as it will be helpful to get the full benefit from this article.

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.


Accelerator Oscillator definition

The Accelerator Oscillator (AC) is a momentum indicator which is developed by Bill Williams. It measures if there is a change in momentum. If the momentum of an uptrend is decreased, this may mean that there is less interest to buy the instrument and, in this case, we may see a different movement in the opposite direction of selling and vice versa, if the momentum of a downtrend is decreased, this may mean that there is a less interest to sell the instrument and we may see a buying power. It is a leading indicator also as it may move before price.

So, the main objective of this indicator is to measure the acceleration and deceleration of the market power in both directions up or down to get insights into how long the current price movement will continue and be ready for any change.

Now, we will learn how we can calculate this indicator manually through the following steps:

AC = AO - SMA (AO, 5)

Where:

Ac = Accelerator Oscillator.

AO = Awesome Oscillator, by the way you can read my previous article about the Awesome Oscillator to know more about it.

SMA = Simple Moving Average.

5 = the period of SMA.

To calculate the AO following the following steps:

MEDIAN PRICE = (HIGH + LOW) / 2 

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

Fortunately, we do not need to calculate this indicator manually as we have it in the MetaTrader 5 trading platform, and all that we need to do is choose it from the available indicators. While opening the trading terminal we will press Insert --> Indicators --> Bill Williams --> Accelerator Oscillator

 AC insert

Then we will find the window of the indicator parameters to set our preferences the same as the following:

 AC param

1- to determine the color up values.

2- to determine the thickness of the histogram.

3- to determine the color of down values.

After determining the previous parameters as per our preferences and pressing "OK" we will find the indicator is inserted to the chart the same as the following:

 AC attached

As we can see in the previous chart, we have the indicator inserted in the lower part of the chart and we have the AC values are oscillating around zero based on the acceleration of the momentum.

The zero-level means that there is a balance between the two market parties bulls and bears. If the AC is greater than the zero level, it means that we may find a continuation of moving upward and vice versa, if the AC is lower than the zero level, it means that we may find a continuation of moving downward.


Accelerator Oscillator strategy

In this topic, we will learn simple trading strategies to be used based on the basic concept of the AC indicator, but you must test them before using them on your real account as the main objective here is educational only. So, you must make sure that it is suitable and profitable for your trading.

  • Strategy one: AC Zero Crossover:

Based on this strategy, we need to use the AC to know when there is a bullish or bearish signal by comparing two values to determine their positions the current AC value and the zero level of the AC indicator. If the current AC value is greater than the zero level, it will be a signal of bullishness. In the other scenario, if the current AC value is lower than the zero level, it will be a signal of bearishness.

Simply,

AC > Zero level --> Bullish

AC < Zero level --> Bearish

  • Strategy two: AC Strength:

Based on this strategy, we need to get signals with the strength of the AC movement based on comparing the current AC value with the maximum AC and the minimum AC values of the last ten AC values to determine the position of every value to get the suitable signal. If the current AC value is greater than the maximum AC value, it will be a signal of strength. In the other scenario, if the current AC value is lower than the minimum AC value, it will be a signal of weakness.

Simply,

AC > Max AC value --> AC is strong

AC < Min AC value --> AC is weak

  • Strategy three: AC & MA Strategy:

Based on this strategy, we need to get signals of buying or selling depending on checking the five values and they are the closing price, the 50- period exponential moving average, the current AC, the maximum AC value, and the minimum AC value of the last ten AC values to determine the position of them to get the suitable signal. If the current AC is greater than the maximum AC value and the closing price is greater than the 50- period EMA, it will be a buy signal. In the other scenario, if the current AC is lower than the minimum AC value and the closing price is lower than the 50- period EMA, it will be a sell signal.

Simply,

AC > Max AC value and Close > 50- EMA --> Buy

AC < Min AC value and Close < 50- EMA --> Sell 

Accelerator Oscillator strategy blueprint

In this topic, we will design a step-by-step blueprint for every mentioned strategy to help us to create a trading system smoothly.

  • Strategy one: AC Zero Crossover:

According to this strategy we need to create a trading system that can be used to generate automatically signals of bullish or bearish as a comment on the chart based on continuously checking for the current AC value and the zero level of the AC indicator to determine the position of them to return the suitable signal. If the current AC value is greater than the zero level, we need the trading system to return comment on the chart with the following values:

  • Bullish
  • AC Value

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

  • Bearish
  • AC Value

The following is the blueprint of this trading system:

 AC Zero Crossover blueprint

  • Strategy two: AC Strength:

According to this strategy, we need to create a trading system that can be used to generate a signal with the strength of AC movement if it is strong or weak based on continuously checking for three values and they are the current AC value, the maximum value, the minimum value of the last ten values of the AC indicator. If the current AC value is greater than the maximum value, we need the trading system to return comment on the chart with the following values:

  • AC is strong
  • AC value
  • AC maximum value
  • AC minimum value

In the other case, if the current AC value is lower than the minimum value we need the trading system to return a comment on the chart with the following values:

  • AC is weak
  • AC value
  • AC maximum value
  • AC minimum value

The following is the blueprint of this trading system:

 AC strength blueprint

  • Strategy three: AC & MA Strategy:

According to this strategy we need to create a trading system that can be used to generate signals of buy and sell as a comment on the chart based on continuously checking the following five values, the current AC, the maximum AC, the minimum AC, the closing price, and the moving average value to determine the position of them to generate the suitable signal. If the current AC is greater than the maximum AC value and the closing price is greater than the moving average, we need the trading system to generate a comment on the chart as a signal with the following values:

  • Buy
  • Closing price
  • AC value
  • AC Max
  • AC Min
  • MA value

In the other case, if the current AC is lower than the minimum AC value and the closing price is lower than the moving average, we need the trading system to return comment on the chart with the following values:

  • Sell
  • Closing price
  • AC value
  • AC Max
  • AC Min
  • MA value

The following is the blueprint of this trading system:

 AC _ MA Strategy blueprint

Accelerator Oscillator trading system

In this interesting topic, we will create our trading system based on the mentioned strategies, but we will create a base for them by creating a simple trading system that will be able to return a comment on the chart with the current AC value and the following is for steps to do that:

Creating an array for the acArray by using the "double" function:

double acArray[];

Using the "ArraySetAsSeries" function to the acArray to return a true or false as a Boolean value. Its parameters are:

  • array[]: we will use acArray.
  • flag: We will use "true" as an array indexing direction.
ArraySetAsSeries(acArray,true);

Defining the AC indicator by using the "iAC" function to return the handle of the Accelerator Oscillator indicator. Its parameters are:

  • symbol: we will use the (_Symbol) to be applied to the current symbol.
  • period: we will use the (_period) to be applied to the current period.
int acDef = iAC(_Symbol,_Period);

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

  • indicator_handle: we will use the (acDef) of the predefined AC indicator handle.
  • buffer_num: to determine the indicator buffer number, we will use (0).
  • start_pos: to determine the starting position, we will use (0).
  • count: to determine the amount to copy, we will use (3).
  • buffer[]: to determine the target array to copy, we will use (acArray).
CopyBuffer(acDef,0,0,3,acArray);

Define the AC value after creating a double variable for the acVal and Normalizing it by using the "NormalizeDouble". Parameters of the "NormalizeDouble" are:

  • value: Normalized number. We will use (acArray[0]).
  • digits: to determine the number of digits after the decimal. We will use (7).
double acVal = NormalizeDouble(acArray[0],7);

Return the comment of the current AC value on the chart by using the "Comment" function.

Comment("AC Value is ",acVal);

The following is the full code of this trading system:

//+------------------------------------------------------------------+
//|                                                    Simple AC.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 acArray[];
   ArraySetAsSeries(acArray,true);
   int acDef = iAC(_Symbol,_Period);
   CopyBuffer(acDef,0,0,3,acArray);
   double acVal = NormalizeDouble(acArray[0],7);
   Comment("AC Value is ",acVal);
  }
//+------------------------------------------------------------------+

After compiling this code, we will find it in the navigator in the Expert Advisors folder the same as the following:

 Simple AC nav

To execute this file, we will drag and drop it on the desired chart then we will find the window of it the same as the following:

 Simple AC win

 Simple AC attached

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

 Simple AC signal

As we can see in the top left corner, we have a comment on the current AC value.

  • Strategy one: AC Zero Crossover:

The following is for the full code to create the trading system of this strategy:

//+------------------------------------------------------------------+
//|                                            AC 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 acArray[];
   ArraySetAsSeries(acArray,true);
   int acDef = iAC(_Symbol,_Period);
   CopyBuffer(acDef,0,0,3,acArray);
   double acVal = NormalizeDouble(acArray[0],7);
   if(acVal > 0)
     {
      Comment("Bullish","\n"
              "AC Value is ",acVal);
     }
   if(acVal < 0)
     {
      Comment("Bearish","\n"
              "AC Value is ",acVal);
     }
  }
//+------------------------------------------------------------------+

Differences in this code:

Conditions of the strategy.

In case of bullish signal:

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

In case of bearish signal

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

After compiling this code, making sure that there are no errors, and executing it by dragging and dropping on the chart the same as what we learned before we will find it is attached to the chart the same as the following:

 AC Zero Crossover attached

In the top right corner, we can see the expert of this strategy is attached to the chart. We're ready now to receive our signals.

In case of a bullish signal:

 AC Zero Crossover - bullish signal

We can see in the top left corner that we have the comment as a signal of this strategy with the following values:

  • Bullish
  • AC Value

In case of a bearish signal:

 AC Zero Crossover - bearish signal

We can see in the top left corner that we have the following values:

  • Bearish
  • AC Value
  • Strategy two: AC Strength:

The following is for the full code to create the trading system of this strategy:

//+------------------------------------------------------------------+
//|                                                  AC 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 acArray[];
   ArraySetAsSeries(acArray,true);
   int acDef = iAC(_Symbol,_Period);
   CopyBuffer(acDef,0,0,11,acArray);
   double acCurrVal = NormalizeDouble(acArray[0],7);
   int acMaxArray = ArrayMaximum(acArray,1,WHOLE_ARRAY);
   int acMinArray = ArrayMinimum(acArray,1,WHOLE_ARRAY);
   double acMaxVal = NormalizeDouble(acArray[acMaxArray],7);
   double acMinVal = NormalizeDouble(acArray[acMinArray],7);
   if(acCurrVal>acMaxVal)
     {
      Comment("AC is strong ","\n",
              "AC Value is ",acCurrVal,"\n",
              "AC Max is ",acMaxVal,"\n",
              "AC Min is ",acMinVal);
     }
   if(acCurrVal<acMinVal)
     {
      Comment("AC is weak ","\n",
              "AC Value is ",acCurrVal,"\n",
              "AC Max is ",acMaxVal,"\n",
              "AC Min is ",acMinVal);
     }
  }
//+------------------------------------------------------------------+

Differences in this code.

Defining the current value of AC:

double acCurrVal = NormalizeDouble(acArray[0],7);

Defining the maximum value in the whole array of AC by using the "ArrayMaximum" function to return the maximum value. Its parameters:

  • array[]: we will use acArray.
  • start: the starting point to check from. We will use (1).
  • count: total elements from array to check. We will use (WHOLE_ARRAY) to check the whole of this array.
int acMaxArray = ArrayMaximum(acArray,1,WHOLE_ARRAY);

Defining the minimum value in the whole array of AC by using the "ArrayMinimum" function to return the minimum value. Its parameters:

  • array[]: we will use (acArray).
  • start: the starting point to check from. We will use (1).
  • count: total elements from array to check. We will use (WHOLE_ARRAY) to check the whole of this array.
int acMinArray = ArrayMinimum(acArray,1,WHOLE_ARRAY);

Normalizing values of maximum and minimum by using the "NormalizeDouble" function.

   double acMaxVal = NormalizeDouble(acArray[acMaxArray],7);
   double acMinVal = NormalizeDouble(acArray[acMinArray],7);

Conditions of the strategy:

In case of a strong signal,

   if(acCurrVal>acMaxVal)
     {
      Comment("AC is strong ","\n",
              "AC Value is ",acCurrVal,"\n",
              "AC Max is ",acMaxVal,"\n",
              "AC Min is ",acMinVal);
     }

In case of a weak signal,

   if(acCurrVal<acMinVal)
     {
      Comment("AC is weak ","\n",
              "AC Value is ",acCurrVal,"\n",
              "AC Max is ",acMaxVal,"\n",
              "AC Min is ",acMinVal);
     }

After compiling and executing this code on the desired chart, we will find it attached the same as the following:

AC strength attached

As we can in the top right of the chart that the expert is attached, we are ready to receive signals of this strategy the same as the following examples from testing.

In case of a strong signal:

AC strength - strong signal

As we can see on the chart in the top left chart as we received our signal with the following values:

  • AC is strong
  • AC value
  • AC maximum value
  • AC minimum value

In case of a weakness:

AC strength - weak signal

As we can that we got the signal with the following values:

  • AC is weak
  • AC value
  • AC maximum value
  • AC minimum value
  • Strategy three: AC & MA Strategy:

The following is for the full code to create the trading system of this strategy:

//+------------------------------------------------------------------+
//|                                                  AC 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 acArray[];
   ArraySetAsSeries(acArray,true);
   int acDef = iAC(_Symbol,_Period);
   CopyBuffer(acDef,0,0,11,acArray);
   double acCurrVal = NormalizeDouble(acArray[0],7);
   int acMaxArray = ArrayMaximum(acArray,1,WHOLE_ARRAY);
   int acMinArray = ArrayMinimum(acArray,1,WHOLE_ARRAY);
   double acMaxVal = NormalizeDouble(acArray[acMaxArray],7);
   double acMinVal = NormalizeDouble(acArray[acMinArray],7);
   if(acCurrVal>acMaxVal)
     {
      Comment("AC is strong ","\n",
              "AC Value is ",acCurrVal,"\n",
              "AC Max is ",acMaxVal,"\n",
              "AC Min is ",acMinVal);
     }
   if(acCurrVal<acMinVal)
     {
      Comment("AC is weak ","\n",
              "AC Value is ",acCurrVal,"\n",
              "AC Max is ",acMaxVal,"\n",
              "AC Min is ",acMinVal);
     }
  }
//+------------------------------------------------------------------+

Differences in this code:

Creating arrays of pArray, acArray, and maArray. We will use the double function for the acArray and maArray but we will use the MqlRates function for pArray to store information about the price, volume, and spread.

   MqlRates pArray[];
   double acArray[];
   double maArray[];

Setting the AS_SERIES flag to arrays of (acArray) and (maArray) like what we mentioned before and defining Data by using the "CopyRates" function to get historical data of MqlRates structure and its parameters are:

  • symbol_name: we will use _Symbol to be applied to the current symbol.
  • timeframe: we will use _Period to be applied to the current period.
  • start_pos: to determine the starting position, we will use (0). 
  • count: to determine the data count to copy, we will use (1).
  • rates_array[]: to determine the target array to copy, we will use the pArray.
   int Data=CopyRates(_Symbol,_Period,0,1,pArray);
   ArraySetAsSeries(acArray,true);
   ArraySetAsSeries(maArray,true);

We will define the AC, MA:

AC by using the "iCA" function the same as we mentioned. But MA, we will use the "iMA" function, its parameters:

  • symbol: we will use (_Symbol)
  • period: we will use (_period)
  • ma_period: to determine the period of the moving average, we will use 50 
  • ma_shift: to determine the horizontal shift, we will use (0) 
  • ma_method: to determine the type of the moving average, we will use exponential MA 
  • applied_price: to determine the type of useable price, we will use the closing price
   int acDef = iAC(_Symbol,_Period);
   int maDef = iMA(_Symbol,_Period,50,0,MODE_EMA,PRICE_CLOSE);

We will get data from the buffer of the AC and MA indicators by using the "CopyBuffer" function.

   CopyBuffer(acDef,0,0,3,acArray);
   CopyBuffer(maDef,0,0,3,maArray);

Getting maximum and minimum values of the acArray.

   int acMaxArray = ArrayMaximum(acArray,1,WHOLE_ARRAY);
   int acMinArray = ArrayMinimum(acArray,1,WHOLE_ARRAY);

Defining values of AC, AC maximum, AC minimum, and Exponential Moving Average.

   double acVal = NormalizeDouble(acArray[0],7);
   double acMaxVal = NormalizeDouble(acArray[acMaxArray],7);
   double acMinVal = NormalizeDouble(acArray[acMinArray],7);
   double maVal = NormalizeDouble(maArray[0],7);

Conditions of the strategy.

In case of a buy signal:

   if(acVal > acMaxVal && closingPrice > maVal)
     {
      Comment("Buy","\n"
              "Closing Price is ",closingPrice,"\n",
              "Ac Value is ",acVal,"\n",
              "AC Max is ",acMaxVal,"\n",
              "AC Min is ",acMinVal,"\n",
              "MA Value is ",maVal);
     }

In case of a sell signal:

   if(acVal < acMinVal && closingPrice < maVal)
     {
      Comment("Sell","\n"
              "Closing Price is ",closingPrice,"\n",
              "Ac Value is ",acVal,"\n",
              "AC Max is ",acMaxVal,"\n",
              "AC Min is ",acMinVal,"\n",
              "MA Value is ",maVal);
     }

After compiling this code and executing it to be attached to receive our signal, it will be attached the same as the following:

AC _ MA Strategy attached

As we can see in the top right corner that the expert is attached to the chart. Now, we can receive our signals.

In case of a buy signal:

AC & MA Strategy - buy signal

As we can see in the top left corner that we have the following values:

  • Buy
  • Closing price
  • AC value
  • AC Max
  • AC Min
  • MA value

In case of a sell signal:

AC & MA Strategy - sell signal

We have the comment with the following values:

  • Sell
  • Closing price
  • AC value
  • AC Max
  • AC Min
  • MA value

Conclusion

After all that we learned in this article, it is supposed that you are understanding the Accelerator Oscillator indicator well as we covered it through this article and we learned what it is, what it measures, how we can calculate it, how we can read and use it through simple trading strategies which were the same as the following:

  • AC Zero Crossover: to get bullish and bearish signals based on the crossover between the AC value and the zero level of the AC indicator.
  • AC Strength: to get a signal of the strength of the AC movement based on comparing between the current AC value with the maximum and the minimum of the last ten AC values.
  • AC & MA Strategy: to get buying and selling signals based on the positioning of the closing price, the 50- period exponential moving average, the AC current value, AC maximum value, and the AC minimum value.

Then, we designed a step-by-step blueprint for all mentioned strategies to help us to create our trading system easily, effectively, and smoothly. Then, we came to the most interesting part of the article as we wrote our codes to create a trading system based on these mentioned strategies to be executed in the MetaTrader 5 to generate automatic signals without any manually reading or monitoring of conditions to be applied.

I hope that tried to apply what you learned the same as I told you at the start of this article and got complete benefits from this article by getting more insights about the topic of this article or any related topic. I need to confirm here another time that you must test any mentioned strategy before using it on your real account to make sure that it will be profitable or suitable for your trading style as there is nothing suitable for all. In addition to that, the main objective here is education only.

I hope that you found this article useful for your trading to get better results and if you want to read more similar articles about how to design a trading system based on the most popular technical indicators like RSI, MACD, MA, Stochastic, Bollinger Bands ...etc. You can read my previous articles in this series to learn more about that.

Attached files |
Simple_AC.mq5 (0.86 KB)
AC_Strength.mq5 (1.46 KB)
Last comments | Go to discussion (1)
vorster Charles
vorster Charles | 20 Oct 2022 at 12:21
How to install the robot
Neural networks made easy (Part 20): Autoencoders Neural networks made easy (Part 20): Autoencoders
We continue to study unsupervised learning algorithms. Some readers might have questions regarding the relevance of recent publications to the topic of neural networks. In this new article, we get back to studying neural networks.
MQL5 Wizard techniques you should know (Part 03): Shannon's Entropy MQL5 Wizard techniques you should know (Part 03): Shannon's Entropy
Todays trader is a philomath who is almost always looking up new ideas, trying them out, choosing to modify them or discard them; an exploratory process that should cost a fair amount of diligence. These series of articles will proposition that the MQL5 wizard should be a mainstay for traders.
Risk and capital management using Expert Advisors Risk and capital management using Expert Advisors
This article is about what you can not see in a backtest report, what you should expect using automated trading software, how to manage your money if you are using expert advisors, and how to cover a significant loss to remain in the trading activity when you are using automated procedures.
Matrix and Vector operations in MQL5 Matrix and Vector operations in MQL5
Matrices and vectors have been introduced in MQL5 for efficient operations with mathematical solutions. The new types offer built-in methods for creating concise and understandable code that is close to mathematical notation. Arrays provide extensive capabilities, but there are many cases in which matrices are much more efficient.