EA not trading in live MT5 account. Help me please

 

Hello, can someone help me with my code please. It is not taking trades on live account. Please can you tell me what is wrong with it. Thanks in advance

//+------------------------------------------------------------------+
//|                     Trading Bot Configuration                    |
//|              For Live Trading on MT5 Platform                   |
//+------------------------------------------------------------------+
input double   Target_Profit = 100.0;       // Set profit target
input double   Stop_Loss = -50.0;           // Set stop loss limit
input double   First_Stake = 1.0;           // Initial stake value
input double   Martingale_Factor = 2.0;     // Martingale multiplier
input int      Martingale_Level = 5;        // Max martingale levels
input int      Martingale_Start_After = 2;  // Start martingale after X losses
// Internal Variables
double current_stake;
int loss_count = 0;
int win_count = 0;
double profit = 0.0;
//+------------------------------------------------------------------+
//| Function: OnInit                                                 |
//+------------------------------------------------------------------+
int OnInit()
{
    current_stake = First_Stake;
    Print("Trading bot initialized. Target Profit: ", Target_Profit,
          ", Stop Loss: ", Stop_Loss, ", First Stake: ", First_Stake);
    return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Function: OnTick                                                 |
//+------------------------------------------------------------------+
void OnTick()
{
    if(profit >= Target_Profit)
    {
        Print("[Result is Win]: Profit target reached! Total Profit: ", profit);
        ExpertRemove();
        return;
    }
    else if(profit <= Stop_Loss)
    {
        Print("[Result is Loss]: Stop loss reached. Exiting... Total Loss: ", profit);
        ExpertRemove();
        return;
    }
    // Simulate Trade Execution
    bool trade_result = ExecuteTrade();
    if(trade_result) // Win scenario
    {
        profit += current_stake;
        win_count++;
        loss_count = 0;
        current_stake = First_Stake; // Reset stake after win
        Print("[Contract Detail: Win] Profit: ", profit);
    }
    else // Loss scenario
    {
        profit -= current_stake;
        loss_count++;
        Print("[Contract Detail: Loss] Profit: ", profit);
        if(loss_count >= Martingale_Start_After && loss_count <= Martingale_Level)
        {
            current_stake *= Martingale_Factor; // Apply martingale
            Print("Martingale Applied. New Stake: ", current_stake);
        }
        else if(loss_count > Martingale_Level)
        {
            Print("Maximum martingale levels reached. Resetting stake.");
            current_stake = First_Stake;
        }
    }
}
//+------------------------------------------------------------------+
//| Function: ExecuteTrade                                           |
//| Simulates trade logic, replace with actual API trade calls       |
//+------------------------------------------------------------------+
bool ExecuteTrade()
{
    // Simulate random trade outcome
    return (MathRand() % 2 == 0); // 50-50 win/loss chance
}
//+------------------------------------------------------------------+
 
Nicolette Sewell: Hello, can someone help me with my code please. It is not taking trades on live account. Please can you tell me what is wrong with it. Thanks in advance

I don't see any trade functions on the code. Please see https://www.mql5.com/en/docs/trading/ordersend

Documentation on MQL5: Trade Functions / OrderSend
Documentation on MQL5: Trade Functions / OrderSend
  • www.mql5.com
The OrderSend() function is used for executing trade operations by sending requests to a trade server. Parameters request [in]  Pointer to a...
 
This looks like a trading simulator - even if you do add buy/sell to this, please don't trade it live before testing on a demo account.
 
you did not write this, so you will not get any help. Moderators may delete this entire thread.