Summary: EURUSD Steady Capital EA is a low-risk MQL4 expert advisor for EURUSD. It uses Bollinger Bands mean reversion with RSI confirmation and fixed stop loss. Suitable for H1 timeframe.




EURUSD Steady Capital EA is designed for stable, low-risk operation on the EURUSD pair. The strategy is based on mean reversion using Bollinger Bands (20,2) with RSI(14) confirmation to avoid catching falling knives. The EA only trades when price touches the outer band and RSI confirms oversold/overbought conditions, ensuring entries are made during statistical extremes. Each trade has a fixed stop loss and take profit with a 1:2 risk-reward ratio. Daily loss limits and Friday close protect equity.

Recommended Timeframe: H1
Trading Logic:
  • Bollinger Bands (20,2) identify overextended price levels.

  • Entry Long: Price touches lower band AND RSI(14) < 35 (oversold).

  • Entry Short: Price touches upper band AND RSI(14) > 65 (overbought).

  • Filter: Do not trade if current spread > MaxSpread points.

  • Risk: Fixed StopLoss (200 points), TakeProfit (400 points), max 1 trade at a time.


  • ``mql4
    //+------------------------------------------------------------------+
    //| EURUSDSteadyCapitalEA.mq4 |
    //+------------------------------------------------------------------+
    #property copyright ""
    #property link ""
    #property version "1.00"
    #property strict

    //--- input parameters with comments
    input double LotSize = 0.01; // Fixed lot size (0.01 for EURUSD)
    input int StopLossPoints = 200; // Stop loss in points (200 points = 20 pips)
    input int TakeProfitPoints = 400; // Take profit in points (2:1 risk-reward)
    input int BBPERIOD = 20; // Bollinger Bands period
    input double BBDEVIATION = 2.0; // Bollinger Bands deviation multiplier
    input int RSIPERIOD = 14; // RSI period
    input int RSI_OVERSOLD = 35; // RSI oversold level (buy trigger)
    input int RSI_OVERBOUGHT = 65; // RSI overbought level (sell trigger)
    input int MagicNumber = 202416; // Unique EA identifier
    input int MaxSpread = 25; // Maximum allowed spread in points
    input double DailyLossLimit = 5.0; // Daily loss limit as percentage of balance
    input bool UseFridayClose = true; // Close all trades before Friday 21:00

    //--- global variables
    double dailyStartBalance = 0;
    datetime lastBarTime = 0;
    bool fridayCloseExecuted = false;

    //+------------------------------------------------------------------+
    //| Expert initialization function |
    //+------------------------------------------------------------------+
    int OnInit()
    {
    dailyStartBalance = AccountBalance();
    lastBarTime = 0;
    fridayCloseExecuted = false;
    return(INIT_SUCCEEDED);
    }

    //+------------------------------------------------------------------+
    //| Expert deinitialization function |
    //+------------------------------------------------------------------+
    void OnDeinit(const int reason)
    {
    Comment("");
    }

    //+------------------------------------------------------------------+
    //| Expert tick function |
    //+------------------------------------------------------------------+
    void OnTick()
    {
    // Daily equity protection
    double currentEquity = AccountEquity();
    double lossPercent = (dailyStartBalance - currentEquity) / dailyStartBalance 100;
    if(lossPercent >= DailyLossLimit)
    {
    Comment("Daily loss limit reached. No new trades.");
    return;
    }

    // Friday close before weekend
    if(UseFridayClose && !fridayCloseExecuted)
    {
    datetime currentTime = TimeCurrent();
    if(TimeDayOfWeek(currentTime) == 5 && TimeHour(currentTime) >= 21)
    {
    CloseAllOrders();
    fridayCloseExecuted = true;
    return;
    }
    if(TimeDayOfWeek(currentTime) != 5)
    fridayCloseExecuted = false;
    }

    // Spread filter
    if(MarketInfo(Symbol(), MODE_SPREAD) > MaxSpread)
    {
    Comment("Spread too high: ", MarketInfo(Symbol(), MODE_SPREAD));
    return;
    }

    // New bar logic (H1)
    if(Time[0] == lastBarTime)
    return;
    lastBarTime = Time[0];

    // Check for existing position
    if(CountPositions() > 0)
    return;

    // Get Bollinger Bands values on previous closed bar
    double lowerBand = iBands(Symbol(), PERIOD_H1, BBPERIOD, BBDEVIATION, 0, PRICE_CLOSE, MODE_LOWER, 1);
    double upperBand = iBands(Symbol(), PERIOD_H1, BBPERIOD, BBDEVIATION, 0, PRICE_CLOSE, MODE_UPPER, 1);
    double close1 = iClose(Symbol(), PERIOD_H1, 1);

    // Get RSI value
    double rsi = iRSI(Symbol(), PERIOD_H1, RSIPERIOD, PRICE_CLOSE, 1);

    int cmd = -1;
    double sl = 0, tp = 0;
    double ask = Ask;
    double bid = Bid;

    // Long signal: price touches lower band and RSI oversold
    if(close1 <= lowerBand && rsi < RSI_OVERSOLD)
    {
    cmd = OP_BUY;
    sl = bid - StopLossPoints
    Point;
    tp = bid + TakeProfitPoints Point;
    }
    // Short signal: price touches upper band and RSI overbought
    else if(close1 >= upperBand && rsi > RSI_OVERBOUGHT)
    {
    cmd = OP_SELL;
    sl = ask + StopLossPoints
    Point;
    tp = ask - TakeProfitPoints * Point;
    }

    if(cmd != -1)
    {
    int ticket = OrderSend(Symbol(), cmd, LotSize, (cmd==OP_BUY?ask:bid), 3, sl, tp, "EURUSD Steady Capital", MagicNumber, 0, clrNONE);
    if(ticket < 0)
    Print("OrderSend failed: ", GetLastError());
    }
    }

    //+------------------------------------------------------------------+
    //| Count open positions with this MagicNumber |
    //+------------------------------------------------------------------+
    int CountPositions()
    {
    int count = 0;
    for(int i = OrdersTotal()-1; i >= 0; i--)
    {
    if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
    if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
    count++;
    }
    }
    return count;
    }

    //+------------------------------------------------------------------+
    //| Close all orders for this symbol and magic |
    //+------------------------------------------------------------------+
    void CloseAllOrders()
    {
    for(int i = OrdersTotal()-1; i >= 0; i--)
    {
    if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
    if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
    {
    if(OrderType() == OP_BUY)
    OrderClose(OrderTicket(), OrderLots(), Bid, 3, clrNONE);
    else if(OrderType() == OP_SELL)
    OrderClose(OrderTicket(), OrderLots(), Ask, 3, clrNONE);
    }
    }
    }
    }
    //+------------------------------------------------------------------+
    ``
    Reference: Original MQL4 code for educational purposes.
    Disclaimer: Trading Forex involves risk of loss. This EA is provided as-is without any guarantee of profitability. Always test on a demo account before live trading. Past performance does not guarantee future results.