My bot is not executing trades

 
My bot is not executing trades, please I need your help on this guys. See my code below:

void OnTick()
{

   // Calculate moving averages
   fastMA = iMA(Symbol(), PERIOD_CURRENT, fastLength, 0, MODE_SMA, PRICE_CLOSE);
   mediumMA = iMA(Symbol(), PERIOD_CURRENT, mediumLength, 0, MODE_SMA, PRICE_CLOSE);
   slowMA = iMA(Symbol(), PERIOD_CURRENT, slowLength, 0, MODE_SMA, PRICE_CLOSE);

   // Check long and short conditions
   bool longCondition = bid > fastMA && fastMA > mediumMA && mediumMA > slowMA;
   bool shortCondition = ask < fastMA && fastMA < mediumMA && mediumMA < slowMA;

   if (longCondition)
   {
      double openPrice = SymbolInfoDouble(Symbol(), SYMBOL_BID);
      double stopLoss = openPrice - 300 * _Point;
      double takeProfit = openPrice + 600 * _Point;  // Adjusted TP level
      
      trade.Buy(0.1, Symbol(), openPrice, stopLoss, takeProfit, "Buy trade");
   }

   if (shortCondition)
   {
      double openPrice = SymbolInfoDouble(Symbol(), SYMBOL_ASK);
      double stopLoss = openPrice + 300 * _Point;
      double takeProfit = openPrice - 600 * _Point;  // Adjusted TP level
      
      trade.Sell(0.1, Symbol(), openPrice, stopLoss, takeProfit, "Sell trade");
   }
}
 
David Udoh:
My bot is not executing trades, please I need your help on this guys. See my code below:

When reporting problems with Code, give relevant details as well.

MQL language version, journal output, expert log. Symbol used.

Have you tried Debugging? Is the error in Tester, or on Chart in MTx?

But for now, I assume MQL5:

Read about iMA, it returns a handle, create the handle in OnInit (). Use the handle in OnTick() with CopyBuffer () to get the actual values from the indicators.

Also release the handles in OnDeinit ().

 
Dominik Egert #:
When reporting problems with Code, give relevant details as well.

MQL language version, journal output, expert log. Symbol used.

Have you tried Debugging? Is the error in Tester, or on Chart in MTx?

But for now, I assume MQL5:

Read about iMA, it returns a handle, create the handle in OnInit (). Use the handle in OnTick() with CopyBuffer () to get the actual values from the indicators.

Also release the handles in OnDeinit ().

Thanks, I am using mql5