I have created a Strategy which should normally work fine, but theres is one major issue

 
Hi guys, i have created this strategy which is executing one trade a day, the idea here is to buy when the overall trend is bullish and sell when the overall trend is bearish. The issue is, that the bot aint buying, its only selling.... its also selling when the trend is bullish. I tried a lot but havent found the issue. please help me guys.
//+------------------------------------------------------------------+
//|                                                     SimpleBot.mq5 |
//|                        Copyright 2023, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

input int stopLoss = 50;
input int takeProfit = 150;
input int fastSMA = 5; // Fast moving average period
input int slowSMA = 10; // Slow moving average period

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   datetime currentTime = TimeCurrent();
   MqlDateTime currentTimeStruct;
   TimeToStruct(currentTime, currentTimeStruct);
   int currentHourUTC = (currentTimeStruct.hour + TimezoneGMTOffset()) % 24;


   double fastMovingAverage = iMA(_Symbol, PERIOD_CURRENT, fastSMA, 0, MODE_SMA, PRICE_CLOSE);
   double slowMovingAverage = iMA(_Symbol, PERIOD_CURRENT, slowSMA, 0, MODE_SMA, PRICE_CLOSE);

   bool isBullish = fastMovingAverage > slowMovingAverage;

   if(currentHourUTC == 7 && currentTimeStruct.min == 0 && currentTimeStruct.sec == 0)
     {
      MqlTradeRequest request;
      MqlTradeResult result;

      request.action = TRADE_ACTION_DEAL;
      request.symbol = _Symbol;
      request.volume = 3;

      if(isBullish)
        {
         request.type = ORDER_TYPE_BUY;
         request.price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
         request.sl = request.price - stopLoss * _Point;
         request.tp = request.price + takeProfit * _Point;
        }
      else
        {
         request.type = ORDER_TYPE_SELL;
         request.price = SymbolInfoDouble(_Symbol, SYMBOL_BID);
         request.sl = request.price + stopLoss * _Point;
         request.tp = request.price - takeProfit * _Point;
        }

      request.deviation = 10;
      request.magic = 123456;
      request.comment = "SimpleBot trade";

      OrderSend(request, result);

      Sleep(1000); // To avoid multiple orders within the same minute, sleep for 1 minute (1000ms * 60)
     }
  }

//+------------------------------------------------------------------+
//| Get the timezone offset for the current broker server            |
//+------------------------------------------------------------------+
int TimezoneGMTOffset()
  {
   datetime currentLocalTime = TimeLocal();
   datetime currentServerTime = TimeTradeServer();

   int gmtOffset = (int)((currentServerTime - currentLocalTime) / 3600);
   return gmtOffset;
  }
//+------------------------------------------------------------------+
 
 
An other ChatGPT code ?
 
yaser.abu-shaqra:
Hi guys, i have created this strategy which is executing one trade a day, the idea here is to buy when the overall trend is bullish and sell when the overall trend is bearish. The issue is, that the bot aint buying, it’s only selling.... it’s also selling when the trend is bullish. I tried a lot but havent found the issue. please help me guys.  
Because your isBulish is always false …
calling indicators in MT5 is a little different than MT4. Also your conditions with time should be reviewed…  what if there is no tick during second 0 ? You should not use second ==0 … 
 
  1. Alain Verleyen #: An other ChatGPT code ?

    Yes.

    Stop using ChatGPT.
              Help needed to debug and fix an AI EA - Trading Systems - MQL5 programming forum #2 (2023)

  2.    double fastMovingAverage = iMA(_Symbol, PERIOD_CURRENT, fastSMA, 0, MODE_SMA, PRICE_CLOSE);

    Mt5 code doesn't return a double.

 
William Roeder #:
  1. Yes.

I started to be trained enough to recognize it. My own internal AI is ready for production
 
Even if the code runs successfully, it still won't generate profit when using the default settings SL=50 & TP=150