Discussing the article: "OpenAI's ChatGPT features within the framework of MQL4 and MQL5 development"

 

Check out the new article: OpenAI's ChatGPT features within the framework of MQL4 and MQL5 development.

In this article, we will fiddle around ChatGPT from OpenAI in order to understand its capabilities in terms of reducing the time and labor intensity of developing Expert Advisors, indicators and scripts. I will quickly navigate you through this technology and try to show you how to use it correctly for programming in MQL4 and MQL5.

I think that when people learn about this kind of technology, they all start to fall into roughly three subgroups:

  1. "Now we will make a super algorithm"
  2. Those who are wary of AI and questioning its usefulness
  3. Machine cannot be better than a human. It's all just another hype

I began to get acquainted with this technology a long time ago and at the beginning I belonged to the third category. In the first two days of dealing with this AI, I abruptly moved from the third to the first category, after which a more interesting and rather unpleasant process of adjusting my own beliefs began, which is more like a rollback to the "1.5" category, which is already a more realistic assessment of this technology.
This technology is useful, but not as much as you might initially think. In this regard, it is worth paying tribute to the developers and marketers of this technology, if only for the fact that it creates an incredible "wow" effect from use in the first couple of days, which is enough for a chain reaction of self-promotion.

To understand this, you need a lot of practice in dealing with this AI. Personally, I had about a hundred different dialogues with it on various topics. I can say that I have gained enough practice in using this technology to start using it for MQL5. Before moving on to practical applications, I just need to tell you some very important information, and for this we will need to look deeper under the hood of this technology.

Author: Evgeniy Ilin

 


Thank you very much Evgeniy Ilin

This article perfectly outlines how to effectively use the AI technology in programming while also pointing out what to avoid.

 

"apply a technology for its intended purpose reduces both the cost of any development and labor costs"

This is also my objective

 

I need a MT5 Expert Advisor based on Bollinger Bands

Certainly! Here's an example of a MetaTrader 5 Expert Advisor (EA) based on Bollinger Bands. This EA buys when the price crosses below the lower Bollinger Band and sells when the price crosses above the upper Bollinger Band:


//+------------------------------------------------------------------+
//|                         BBExpertAdvisor.mq5                     |
//|                        Generated by Bing AI                       |
//+------------------------------------------------------------------+
#property copyright "Your Name"
#property version   "1.00"
#property script_show_inputs

// Bollinger Bands settings
input int      bbPeriod    = 20;
input double   bbDeviation = 2.0;
input double   lotSize     = 0.1;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
    Print("BBExpertAdvisor initialized.");
    return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
    // Declare variables for Bollinger Bands
    double upperBB, middleBB, lowerBB;

    // Calculate Bollinger Bands
    if (iBands(_Symbol, _Period, bbPeriod, bbDeviation, 0, 0, upperBB, middleBB, lowerBB) > 0)
    {
        // Get the current price
        double currentPrice = SymbolInfoDouble(_Symbol, SYMBOL_BID);

        // Buy condition: If the price crosses below the lower Bollinger Band
        if (currentPrice < lowerBB)
        {
            // Check if there are no open orders
            if (OrdersHistoryTotal() == 0 && OrdersTotal() == 0)
            {
                // Open a buy order
                OrderSend(_Symbol, OP_BUY, lotSize, currentPrice, 3, 0, 0, "Buy Order", 0, 0, Green);
            }
        }

        // Sell condition: If the price crosses above the upper Bollinger Band
        if (currentPrice > upperBB)
        {
            // Check if there are no open orders
            if (OrdersHistoryTotal() == 0 && OrdersTotal() == 0)
            {
                // Open a sell order
                OrderSend(_Symbol, OP_SELL, lotSize, currentPrice, 3, 0, 0, "Sell Order", 0, 0, Red);
            }
        }
    }
}
//+------------------------------------------------------------------+


This EA uses the `iBands` function to calculate the Bollinger Bands. Customize the Bollinger Bands settings (`bbPeriod` and `bbDeviation`) and risk management parameters (`lotSize`) according to your trading strategy.

Before deploying any EA in a live trading environment, it is essential to test it thoroughly on historical data and in a demo account to ensure its reliability and effectiveness.
 
I tried to get MT5 code but failed. It seems ChatGPT can only provide MT4 code