Discussing the article: "Reimagining Classic Strategies (Part II): Bollinger Bands Breakouts"

 

Check out the new article: Reimagining Classic Strategies (Part II): Bollinger Bands Breakouts.

This article explores a trading strategy that integrates Linear Discriminant Analysis (LDA) with Bollinger Bands, leveraging categorical zone predictions for strategic market entry signals.

The term "Artificial Intelligence" (AI) is arguably one of the most misleading naming conventions in history. After reading this article, you may agree that AI is a misnomer. As the writer, my issue lies in the word "intelligence." AI models are not intelligent in the human sense. Instead, they are intelligent applications of optimization algorithms.

AI models primarily aim to minimize errors or maximize rewards within a system. However, solutions derived from these models may not always be practical. For example, an AI system designed to minimize losses in a trading account might conclude that placing no trades is the best solution, as it guarantees no losses. While mathematically satisfying the problem at hand, this solution is impractical for trading.

As intelligent AI practitioners, we must guide our models with carefully planned constraints. In this article, we will direct our AI models using Bollinger Bands. We will identify four possible zones where the price might be at any moment. Note that the price can only be in one of these four zones at any given time:

  • Zone 1: Price is completely above the Bollinger Bands
  • Zone 2: Price is above the mid-band but below the high-band
  • Zone 3: Price is above the low-band but below the mid-band
  • Zone 4: Price is below the low-band

We will train a model to understand how the price transitions between these four zones and predict the next zone the price will move to. Trading signals are generated whenever the price shifts from one zone to another. For instance, if our model predicts that the price will move from Zone 2 to Zone 1, we interpret this as an upward movement and initiate a buy order. Our model and Expert Advisor will be fully implemented in native MQL5.

Bollinger Bands can be utilized in a range of trading strategies, from trend following to identifying turning or reversal points. Technically, this indicator consists of an exponential moving average (EMA) that typically smooths out the close price of a security. It is flanked by two additional bands: one positioned above and one below the EMA, each normally set at 2 standard deviations.

Author: Gamuchirai Zororo Ndawana

 

Hi Ndawana

First of all thanks for the article and simplifying the AI myth :) I am trying to use the signal generated from this into my code with some modifications.

Can you please explain the reason(s) why you have used vectors, instead of simple arrays in your code?

 
Anil Varma #:

Hi Ndawana

First of all thanks for the article and simplifying the AI myth :) I am trying to use the signal generated from this into my code with some modifications.

Can you please explain the reason(s) why you have used vectors, instead of simple arrays in your code?

Hi Anil, let me start by saying nothing will break if we used arrays instead of vectors, so yes we could've used simple arrays instead.

My preference for vectors comes from the specialized functions that are available only to vectors, on top of those special functions vectors also allow us to perform calculations on all elements at once. Here's a simple example.
//+------------------------------------------------------------------+
//|                                                         Anil.mq5 |
//|                                        Gamuchirai Zororo Ndawana |
//|                          https://www.mql5.com/en/gamuchiraindawa |
//+------------------------------------------------------------------+
#property copyright "Gamuchirai Zororo Ndawana"
#property link      "https://www.mql5.com/en/gamuchiraindawa"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- Here is my problem with arrays
double anil_array[3];
ArrayFill(anil_array,0,3,0);
ArrayPrint(anil_array);
//--- We have to iterate over all the elements to perform calculations
for(int i = 0; i < 3; i++)
   {
      anil_array[i] += 1;
   }
ArrayPrint(anil_array);
//--- And the same operation with vector
vector anil_vector = vector::Zeros(3); //Simillar to an array full of Zeros   
Print(anil_vector);   
//--- Vectors allow us to perform calculations on all the elements at once
anil_vector = anil_vector + 1;
Print(anil_vector);
  }
//+------------------------------------------------------------------+

Vectors VS Arrays.

So imagine if in future we thought of a calculation that may be helpful, it'll be a lot easier to modify the code base since we're using vectors.