【This Week’s Results & ChatGPT】 Try to Managing a Free EA Portfolio 2 (15-19 May 2023)

mini review ChatGPT,Portfolio 2,Portfolio management

Mini-review – We asked ChatGPT!                                                                                                                                                                                                                                          

This time, I would like to introduce the MT5 program written by ChatGPT. If it is a simple program, it seems that MT5 can be used.

Q: With MT5EA, please write a program that “closes all positions when the total profit reaches a certain level". In addition, all currency pairs are used for settlement.

Add instructions
· Please make it possible to specify “when the total profit reaches 1000 units or more" with an external variable.
・ Set the EA name to “ProfitClose".

Failed to compile with some errors. ⇔ In each case, convey the content of the error as it is.

Normally, I would give up because of an error, but this time it went well!

A: ChatGPT response: https://chat.openai.com/auth/login

MT5 (MetaTrader 5) allows creating Expert Advisors (EAs) using the MQL5 language. EA is a program for automating trading.

An EA that meets your requirements would look like this: However, this code will be used to close all positions. It works only when the profit reaches a certain value or more.

In the example below, we will close all positions when the total profit of all positions is 1000 units or more. This unit depends on the currency you are using MT5 for.

//+------------------------------------------------------------------+
//|                                                  ProfitClose.mq5 |
//|                        Copyright 2023, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2023, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

// Set default profit threshold to 1000
input double ProfitThreshold = 1000; 

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   double total_profit = 0;
   for(int i=PositionsTotal()-1; i>=0; i--)
     {
      ulong ticket = PositionGetTicket(i);
      if(ticket > 0)
        {
         total_profit += PositionGetDouble(POSITION_PROFIT);
        }
     }
   
   if(total_profit >= ProfitThreshold) // Use the external variable here
     {
      for(int i=PositionsTotal()-1; i>=0; i--)
        {
         ulong ticket = PositionGetTicket(i);
         if(ticket > 0)
           {
            MqlTradeRequest request;
            MqlTradeResult result;
            
            ZeroMemory(request);

            request.action = TRADE_ACTION_DEAL; 
            request.symbol = PositionGetString(POSITION_SYMBOL); 
            request.volume = PositionGetDouble(POSITION_VOLUME); 
            request.type = PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY ? ORDER_TYPE_SELL : ORDER_TYPE_BUY;
            request.price = request.type == ORDER_TYPE_BUY ? SymbolInfoDouble(request.symbol, SYMBOL_ASK) : SymbolInfoDouble(request.symbol, SYMBOL_BID);
            request.deviation = 20; 
            request.magic = 123456; 
            request.comment = "Close position"; 
            request.position = PositionGetInteger(POSITION_TICKET); 

            if(!OrderSend(request, result))
            {
              Print("OrderSend failed with error ",GetLastError());
            }
            else
            {
              Print("OrderSend succeeded, deal performed with ticket #", result.deal);
            }
           }
        }
     }
  }
//+------------------------------------------------------------------+

You can change the profit threshold by adjusting the ProfitThreshold variable when launching the EA or changing the EA settings. The default value is set to 1000, but you can change it to any value.

Always test this code in a demo environment before using it.

It’s convenient, but if you rely on it, you won’t be able to train your programming skills.

MQL5 Free EA – NOZAX Portfolio No.2

NOZAX Portfolio NO.2
  • Account: NZX Zero (ECN) (NOZAX)
  • Initial balance: 100,000 yen
  • Working EA:
  • TraderMind EA MT5: Currency Pair: USDCAD#, Timeframe: 1 Hour, Lot quantity: 0.04 Lot
  • White Bear DT for NOZAX v1.13: Currency pair: USDJPY#, Timeframe: 5-minute, Lot quantity: 0.02 lot
  • Gold Multiply Funds EA: Currency Pair: XAUUSD#, Timeframe: 30-minute, Lot quantity: 0.01 lot
  • Catastrofix EA MT5: Currency Pair: EURGBP#, EURAUD#, EURNZD#, EURUSD#, GBPCAD#, AUDJPY#, Timeframe: 1 Hour, Lot quantity: 0.01 lot

Results from 15 to 19 May (NOZAX Portfolio No.2)

  • TraderMind EA MT5: 1 win and 1 loss, total profit and loss was -1737 yen (-41.0pips).
  • White Bear DT USDJPY: 8 wins and 2 losse, total profit and loss was -575 yen (-22.7 pips).
  • Gold Multiply Funds EA: 1 win and 4 losses, total profit and loss was -3064 yen (-2194pips).
  • Catastrofix EA MT5: 7 wins and 6 losses, total profit and loss was 3861 yen (401.7pips).

Past Results (NOZAX Portfolio No.2)

The individual results of each EA in the portfolio No. 2 are as follows.

  • 10 April-19 May 2023
    (Trades with a profit of even 1 yen are counted as “winning", while the reverse is counted as “negative")
  • Balance: 100,000 yen → 100,487 yen

Current status and schedule of the portfolio

The Gold Multiply Funds EA is an EA that trades XAUUSD, and I had high hopes for it, but the results haven’t been good since the test started. This EA also seems to use AI to find the entry point, but I feel that the accuracy of AI predictions is declining.

It’s just that it didn’t match the market, and there’s no possibility that it will improve in the future, so I’m going to remove it from this portfolio for the time being and see how it goes with a demo account.

Neither TraderMind EA MT5 nor White Bear DT is in good condition, so it’s a bit annoying, but next week I’ll try to turn my portfolio with these two and Catastrofix EA.

NOZAX

Up-and-coming MT5 FX broker [NOZAX] → → → Click here for details!

Posted by GOMA