Summary: This low risk EA for EURUSD uses EMA trend filter, ATR volatility guard and fixed stop loss/take profit. It trades only on H1 timeframe with strict money management.




This EA is designed specifically for EURUSD with a low-risk, stable operational approach. It uses trend filtering (EMA50), volatility-based entry (ATR), and strict money management to suit the moderate volatility of EURUSD. The EA trades only in the direction of the major trend and avoids entering during high volatility. Each trade has a fixed stop loss and take profit, with daily equity protection and spread filter.

Recommended Timeframe: H1
Trading Logic:
1. Trend Filter: Price above EMA50 → long only; below → short only.
2. Entry: After trend confirmation, wait for a pullback to EMA50 with a close beyond the previous bar.
3. Volatility Guard: ATR(14) > ATR threshold (calculated dynamically) → no new trade.
4. Risk Control: Fixed SL (150 points), TP (300 points), max 1 trade at a time, daily loss limit 5%, max spread 25 points.

```mql4
//+------------------------------------------------------------------+
//| LowRiskEURUSD.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 = 150; // Stop loss in points (150 points = 150 pips)
input int TakeProfitPoints = 300; // Take profit in points (2:1 risk-reward)
input int TrendMAPeriod = 50; // Period of EMA for trend filter
input int ATRPeriod = 14; // Period for ATR volatility indicator
input double ATRMultiplier = 1.2; // ATR threshold multiplier
input int MagicNumber = 202412; // Unique EA identifier
input int MaxSpread = 25; // Maximum allowed spread (in points)
input double DailyLossLimit = 5.0; // Daily loss limit in percentage of balance
input bool UseCloseOnFriday = true; // Close all trades before Friday 21:00

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

//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
dailyStartBalance = AccountBalance();
lastBarTime = 0;
isFridayCloseExecuted = 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(UseCloseOnFriday && !isFridayCloseExecuted)
{
datetime currentTime = TimeCurrent();
if(TimeDayOfWeek(currentTime) == 5 && TimeHour(currentTime) >= 21)
{
CloseAllOrders();
isFridayCloseExecuted = true;
return;
}
if(TimeDayOfWeek(currentTime) != 5)
isFridayCloseExecuted = false;
}

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

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

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

// Trend direction using EMA50
double ema50 = iMA(Symbol(), PERIOD_H1, TrendMAPeriod, 0, MODE_EMA, PRICE_CLOSE, 1);
double close1 = iClose(Symbol(), PERIOD_H1, 1);
double close2 = iClose(Symbol(), PERIOD_H1, 2);

// ATR volatility filter
double atr = iATR(Symbol(), PERIOD_H1, ATRPeriod, 1);
double atrThreshold = ATRMultiplier * 80; // 80 points reference for EURUSD
if(atr > atrThreshold)
{
Comment("High volatility, no trade");
return;
}

// Bullish condition: price above EMA50, previous bar close > EMA50, and close > open
bool bullish = (close1 > ema50 && close2 > ema50 && close1 > iOpen(Symbol(), PERIOD_H1, 1));
// Bearish condition: price below EMA50
bool bearish = (close1 < ema50 && close2 < ema50 && close1 < iOpen(Symbol(), PERIOD_H1, 1));

double sl = 0, tp = 0;
int cmd = -1;

if(bullish)
{
cmd = OP_BUY;
sl = SymbolInfoDouble(Symbol(), SYMBOL_BID) - StopLossPoints * Point;
tp = SymbolInfoDouble(Symbol(), SYMBOL_BID) + TakeProfitPoints * Point;
}
else if(bearish)
{
cmd = OP_SELL;
sl = SymbolInfoDouble(Symbol(), SYMBOL_ASK) + StopLossPoints * Point;
tp = SymbolInfoDouble(Symbol(), SYMBOL_ASK) - TakeProfitPoints * Point;
}

if(cmd != -1)
{
int ticket = OrderSend(Symbol(), cmd, LotSize, (cmd==OP_BUY?Ask:Bid), 3, sl, tp, "LowRiskEURUSD", 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 substantial risk. This EA is provided "as is" without any guarantee of profit. Test thoroughly on a demo account before live trading. Past performance does not guarantee future results.