Spezifikation
//+------------------------------------------------------------------+
//| XAUUSD_SMART_EA_V2.mq5 |
//| BOS + Liquidity Sweep + FVG + EMA + ATR |
//+------------------------------------------------------------------+
#property strict
#property version "2.00"
#include <Trade/Trade.mqh>
CTrade trade;
//==================================================================
// INPUTS
//==================================================================
input string InpSymbol = "";
input ENUM_TIMEFRAMES InpTimeframe = PERIOD_M15;
input ulong InpMagicNumber = 20260829;
//--- EMA
input int FastEMA = 20;
input int SlowEMA = 50;
//--- ATR
input int ATRPeriod = 14;
input double SL_ATR_Multiplier = 1.5;
input double RiskReward = 2.0;
//--- Risk
input bool UseRiskPercent = true;
input double RiskPercent = 1.0;
input double FixedLot = 0.01;
//--- RSI
input bool UseRSIFilter = true;
input int RSIPeriod = 14;
input double BuyRSI = 50.0;
input double SellRSI = 50.0;
//--- Structure
input int StructureLookback = 10;
//--- Liquidity
input int LiquidityLookback = 10;
//--- FVG
input bool UseFVG = true;
//--- Filters
input int MaxSpreadPoints = 500;
input int MaxPositions = 1;
//--- Session
input bool UseTradingHours = true;
input int StartHour = 7;
input int EndHour = 21;
//--- Break Even
input bool UseBreakEven = true;
input double BreakEvenRR = 1.0;
input int BreakEvenOffsetPoints = 20;
//==================================================================
// GLOBALS
//==================================================================
string SymbolName;
int fastEMAHandle = INVALID_HANDLE;
int slowEMAHandle = INVALID_HANDLE;
int atrHandle = INVALID_HANDLE;
int rsiHandle = INVALID_HANDLE;
datetime lastBar = 0;
//==================================================================
// INITIALIZATION
//==================================================================
int OnInit()
{
SymbolName = InpSymbol;
if(SymbolName == "")
SymbolName = _Symbol;
trade.SetExpertMagicNumber(InpMagicNumber);
trade.SetDeviationInPoints(30);
fastEMAHandle = iMA(
SymbolName,
InpTimeframe,
FastEMA,
0,
MODE_EMA,
PRICE_CLOSE
);
slowEMAHandle = iMA(
SymbolName,
InpTimeframe,
SlowEMA,
0,
MODE_EMA,
PRICE_CLOSE
);
atrHandle = iATR(
SymbolName,
InpTimeframe,
ATRPeriod
);
rsiHandle = iRSI(
SymbolName,
InpTimeframe,
RSIPeriod,
PRICE_CLOSE
);
if(
fastEMAHandle == INVALID_HANDLE ||
slowEMAHandle == INVALID_HANDLE ||
atrHandle == INVALID_HANDLE ||
rsiHandle == INVALID_HANDLE
)
{
Print("Indicator initialization failed.");
return INIT_FAILED;
}
Print("XAUUSD SMART EA V2 initialized.");
return INIT_SUCCEEDED;
}
//==================================================================
// DEINITIALIZATION
//==================================================================
void OnDeinit(const int reason)
{
if(fastEMAHandle != INVALID_HANDLE)
IndicatorRelease(fastEMAHandle);
if(slowEMAHandle != INVALID_HANDLE)
IndicatorRelease(slowEMAHandle);
if(atrHandle != INVALID_HANDLE)
IndicatorRelease(atrHandle);
if(rsiHandle != INVALID_HANDLE)
IndicatorRelease(rsiHandle);
}
//==================================================================
// ON TICK
//==================================================================
void OnTick()
{
ManageBreakEven();
if(!IsNewBar())
return;
if(UseTradingHours && !TradingTime())
return;
if(!SpreadOK())
return;
if(MyPositions() >= MaxPositions)
return;
//--- Indicator arrays
double fastEMA[3];
double slowEMA[3];
double atr[3];
double rsi[3];
ArraySetAsSeries(fastEMA,true);
ArraySetAsSeries(slowEMA,true);
ArraySetAsSeries(atr,true);
ArraySetAsSeries(rsi,true);
if(CopyBuffer(fastEMAHandle,0,0,3,fastEMA) < 3)
return;
if(CopyBuffer(slowEMAHandle,0,0,3,slowEMA) < 3)
return;
if(CopyBuffer(atrHandle,0,0,3,atr) < 3)
return;
if(CopyBuffer(rsiHandle,0,0,3,rsi) < 3)
return;
double fast = fastEMA[1];
double slow = slowEMA[1];
double atrValue = atr[1];
double rsiValue = rsi[1];
if(atrValue <= 0)
return;
bool bullishTrend = fast > slow;
bool bearishTrend = fast < slow;
bool bullishBOS = BullishBOS();
bool bearishBOS = BearishBOS();
bool bullishSweep = BullishLiquiditySweep();
bool bearishSweep = BearishLiquiditySweep();
bool bullishFVG = true;
bool bearishFVG = true;
if(UseFVG)
{
bullishFVG = BullishFVG();
bearishFVG = BearishFVG();
}
bool buyRSI = true;
bool sellRSI = true;
if(UseRSIFilter)
{
buyRSI = rsiValue >= BuyRSI;
sellRSI = rsiValue <= SellRSI;
}
//==============================================================
// BUY SIGNAL
//==============================================================
bool BUY =
bullishTrend &&
bullishBOS &&
bullishSweep &&
bullishFVG &&
buyRSI;
//==============================================================
// SELL SIGNAL
//==============================================================
bool SELL =
bearishTrend &&
bearishBOS &&
bearishSweep &&
bearishFVG &&
sellRSI;
if(BUY)
{
PrintJSONSignal(
"BUY",
fast,
slow,
rsiValue,
atrValue
);
OpenBuy(atrValue);
}
else if(SELL)
{
PrintJSONSignal(
"SELL",
fast,
slow,
rsiValue,
atrValue
);
OpenSell(atrValue);
}
}
//==================================================================
// NEW BAR
//==================================================================
bool IsNewBar()
{
datetime time[1];
if(CopyTime(
SymbolName,
InpTimeframe,
0,
1,
time
) != 1)
return false;
if(time[0] != lastBar)
{
lastBar = time[0];
return true;
}
return false;
}
//==================================================================
// TRADING HOURS
//==================================================================
bool TradingTime()
{
MqlDateTime dt;
TimeToStruct(
TimeCurrent(),
dt
);
int hour = dt.hour;
if(StartHour < EndHour)
return hour >= StartHour && hour < EndHour;
return hour >= StartHour || hour < EndHour;
}
//==================================================================
// SPREAD FILTER
//==================================================================
bool SpreadOK()
{
MqlTick tick;
if(!SymbolInfoTick(SymbolName,tick))
return false;
double point =
SymbolInfoDouble(
SymbolName,
SYMBOL_POINT
);
if(point <= 0)
return false;
double spread =
(tick.ask - tick.bid) / point;
if(spread > MaxSpreadPoints)
return false;
return true;
}
//==================================================================
// COUNT POSITIONS
//==================================================================
int MyPositions()
{
int count = 0;
for(int i=PositionsTotal()-1;i>=0;i--)
{
ulong ticket =
PositionGetTicket(i);
if(ticket == 0)
continue;
if(!PositionSelectByTicket(ticket))
continue;
if(
PositionGetString(POSITION_SYMBOL)
== SymbolName &&
(ulong)PositionGetInteger(POSITION_MAGIC)
== InpMagicNumber
)
{
count++;
}
}
return count;
}
//==================================================================
// SWING HIGH
//==================================================================
double HighestHigh(int lookback)
{
double highest = -DBL_MAX;
for(int i=2;i<lookback+2;i++)
{
double high =
iHigh(
SymbolName,
InpTimeframe,
i
);
if(high > highest)
highest = high;
}
return highest;
}
//==================================================================
// SWING LOW
//==================================================================
double LowestLow(int lookback)
{
double lowest = DBL_MAX;
for(int i=2;i<lookback+2;i++)
{
double low =
iLow(
SymbolName,
InpTimeframe,
i
);
if(low < lowest)
lowest = low;
}
return lowest;
}
//==================================================================
// BULLISH BOS
//==================================================================
bool BullishBOS()
{
double previousHigh =
HighestHigh(
StructureLookback
);
double close =
iClose(
SymbolName,
InpTimeframe,
1
);
return close > previousHigh;
}
//==================================================================
// BEARISH BOS
//==================================================================
bool BearishBOS()
{
double previousLow =
LowestLow(
StructureLookback
);
double close =
iClose(
SymbolName,
InpTimeframe,
1
);
return close < previousLow;
}
//==================================================================
// BULLISH LIQUIDITY SWEEP
//==================================================================
bool BullishLiquiditySweep()
{
double previousLow =
LowestLow(
LiquidityLookback
);
double candleLow =
iLow(
SymbolName,
InpTimeframe,
1
);
double candleClose =
iClose(
SymbolName,
InpTimeframe,
1
);
// Price went below liquidity
// and closed back above it.
return(
candleLow < previousLow &&
candleClose > previousLow
);
}
//==================================================================
// BEARISH LIQUIDITY SWEEP
//==================================================================
bool BearishLiquiditySweep()
{
double previousHigh =
HighestHigh(
LiquidityLookback
);
double candleHigh =
iHigh(
SymbolName,
InpTimeframe,
1
);
double candleClose =
iClose(
SymbolName,
InpTimeframe,
1
);
return(
candleHigh > previousHigh &&
candleClose < previousHigh
);
}
//==================================================================
// BULLISH FVG
//==================================================================
bool BullishFVG()
{
double high3 =
iHigh(
SymbolName,
InpTimeframe,
3
);
double low1 =
iLow(
SymbolName,
InpTimeframe,
1
);
// Bullish imbalance
return low1 > high3;
}
//==================================================================
// BEARISH FVG
//==================================================================
bool BearishFVG()
{
double low3 =
iLow(
SymbolName,
InpTimeframe,
3
);
double high1 =
iHigh(
SymbolName,
InpTimeframe,
1
);
// Bearish imbalance
return high1 < low3;
}
//==================================================================
// LOT CALCULATION
//==================================================================
double CalculateLot(
double entry,
double stopLoss
)
{
if(!UseRiskPercent)
return NormalizeLot(FixedLot);
double balance =
AccountInfoDouble(
ACCOUNT_BALANCE
);
double riskMoney =
balance *
RiskPercent /
100.0;
double tickSize =
SymbolInfoDouble(
SymbolName,
SYMBOL_TRADE_TICK_SIZE
);
double tickValue =
SymbolInfoDouble(
SymbolName,
SYMBOL_TRADE_TICK_VALUE
);
if(
tickSize <= 0 ||
tickValue <= 0
)
return NormalizeLot(FixedLot);
double distance =
MathAbs(
entry - stopLoss
);
double ticks =
distance / tickSize;
double lossPerLot =
ticks * tickValue;
if(lossPerLot <= 0)
return NormalizeLot(FixedLot);
double lot =
riskMoney / lossPerLot;
return NormalizeLot(lot);
}
//==================================================================
// NORMALIZE LOT
//==================================================================
double NormalizeLot(double lot)
{
double minLot =
SymbolInfoDouble(
SymbolName,
SYMBOL_VOLUME_MIN
);
double maxLot =
SymbolInfoDouble(
SymbolName,
SYMBOL_VOLUME_MAX
);
double step =
SymbolInfoDouble(
SymbolName,
SYMBOL_VOLUME_STEP
);
if(step <= 0)
step = 0.01;
lot =
MathMax(
lot,
minLot
);
lot =
MathMin(
lot,
maxLot
);
lot =
MathFloor(
lot / step
) * step;
return NormalizeDouble(lot,2);
}
//==================================================================
// OPEN BUY
//==================================================================
void OpenBuy(double atrValue)
{
MqlTick tick;
if(!SymbolInfoTick(
SymbolName,
tick
))
return;
int digits =
(int)SymbolInfoInteger(
SymbolName,
SYMBOL_DIGITS
);
double entry = tick.ask;
double slDistance =
atrValue *
SL_ATR_Multiplier;
double sl =
entry -
slDistance;
double tp =
entry +
slDistance *
RiskReward;
sl =
NormalizeDouble(
sl,
digits
);
tp =
NormalizeDouble(
tp,
digits
);
double lot =
CalculateLot(
entry,
sl
);
if(lot <= 0)
return;
if(
trade.Buy(
lot,
SymbolName,
0,
sl,
tp,
"SMART XAUUSD BUY"
)
)
{
Print(
"BUY opened successfully."
);
}
else
{
Print(
"BUY failed: ",
trade.ResultRetcodeDescription()
);
}
}
//==================================================================
// OPEN SELL
//==================================================================
void OpenSell(double atrValue)
{
MqlTick tick;
if(!SymbolInfoTick(
SymbolName,
tick
))
return;
int digits =
(int)SymbolInfoInteger(
SymbolName,
SYMBOL_DIGITS
);
double entry = tick.bid;
double slDistance =
atrValue *
SL_ATR_Multiplier;
double sl =
entry +
slDistance;
double tp =
entry -
slDistance *
RiskReward;
sl =
NormalizeDouble(
sl,
digits
);
tp =
NormalizeDouble(
tp,
digits
);
double lot =
CalculateLot(
entry,
sl
);
if(lot <= 0)
return;
if(
trade.Sell(
lot,
SymbolName,
0,
sl,
tp,
"SMART XAUUSD SELL"
)
)
{
Print(
"SELL opened successfully."
);
}
else
{
Print(
"SELL failed: ",
trade.ResultRetcodeDescription()
);
}
}
//==================================================================
// BREAK EVEN
//==================================================================
void ManageBreakEven()
{
if(!UseBreakEven)
return;
for(int i=PositionsTotal()-1;i>=0;i--)
{
ulong ticket =
PositionGetTicket(i);
if(ticket == 0)
continue;
if(!PositionSelectByTicket(ticket))
continue;
if(
PositionGetString(POSITION_SYMBOL)
!= SymbolName
)
continue;
if(
(ulong)PositionGetInteger(POSITION_MAGIC)
!= InpMagicNumber
)
continue;
ENUM_POSITION_TYPE type =
(ENUM_POSITION_TYPE)
PositionGetInteger(
POSITION_TYPE
);
double open =
PositionGetDouble(
POSITION_PRICE_OPEN
);
double sl =
PositionGetDouble(
POSITION_SL
);
double tp =
PositionGetDouble(
POSITION_TP
);
if(sl <= 0)
continue;
double price;
if(type == POSITION_TYPE_BUY)
price =
SymbolInfoDouble(
SymbolName,
SYMBOL_BID
);
else
price =
SymbolInfoDouble(
SymbolName,
SYMBOL_ASK
);
double risk;
if(type == POSITION_TYPE_BUY)
risk = open - sl;
else
risk = sl - open;
if(risk <= 0)
continue;
double profit;
if(type == POSITION_TYPE_BUY)
profit = price - open;
else
profit = open - price;
double rr =
profit / risk;
if(rr < BreakEvenRR)
continue;
double point =
SymbolInfoDouble(
SymbolName,
SYMBOL_POINT
);
int digits =
(int)SymbolInfoInteger(
SymbolName,
SYMBOL_DIGITS
);
double newSL;
if(type == POSITION_TYPE_BUY)
{
newSL =
open +
BreakEvenOffsetPoints *
point;
if(newSL <= sl)
continue;
}
else
{
newSL =
open -
BreakEvenOffsetPoints *
point;
if(newSL >= sl)
continue;
}
newSL =
NormalizeDouble(
newSL,
digits
);
trade.PositionModify(
ticket,
newSL,
tp
);
}
}
//==================================================================
// JSON SIGNAL OUTPUT
//==================================================================
void PrintJSONSignal(
string signal,
double fastEMA,
double slowEMA,
double rsi,
double atr
)
{
string json =
"{"
"\"symbol\":\"" +
SymbolName +
"\","
"\"timeframe\":\"M15\","
"\"signal\":\"" +
signal +
"\","
"\"fast_ema\":" +
DoubleToString(
fastEMA,
2
) +
","
"\"slow_ema\":" +
DoubleToString(
slowEMA,
2
) +
","
"\"rsi\":" +
DoubleToString(
rsi,
2
) +
","
"\"atr\":" +
DoubleToString(
atr,
2
) +
","
"\"risk_percent\":" +
DoubleToString(
RiskPercent,
2
) +
","
"\"rr\":" +
DoubleToString(
RiskReward,
2
) +
"}";
Print(json);
}
//+------------------------------------------------------------------+
Bewerbungen
1
Bewertung
Projekte
1
0%
Schlichtung
0
Frist nicht eingehalten
0
Frei
2
Bewertung
Projekte
21
43%
Schlichtung
6
33%
/
17%
Frist nicht eingehalten
2
10%
Arbeitet
Veröffentlicht: 7 Artikel, 35 Beispiele
3
Bewertung
Projekte
4
0%
Schlichtung
1
100%
/
0%
Frist nicht eingehalten
1
25%
Frei
4
Bewertung
Projekte
1
0%
Schlichtung
0
Frist nicht eingehalten
0
Frei
5
Bewertung
Projekte
8
38%
Schlichtung
0
Frist nicht eingehalten
1
13%
Arbeitet
Veröffentlicht: 1 Beispiel
6
Bewertung
Projekte
0
0%
Schlichtung
0
Frist nicht eingehalten
0
Frei
7
Bewertung
Projekte
0
0%
Schlichtung
0
Frist nicht eingehalten
0
Frei
8
Bewertung
Projekte
45
16%
Schlichtung
2
0%
/
100%
Frist nicht eingehalten
4
9%
Frei
9
Bewertung
Projekte
1
0%
Schlichtung
1
0%
/
100%
Frist nicht eingehalten
0
Arbeitet
Ähnliche Aufträge
Dfwluxea
30 - 6000 USD
MetaTrader 5 Smart Trading Robot – Description Create an advanced MetaTrader 5 (MT5) Expert Advisor designed to analyze the market, generate high-quality trading signals, identify potential trading mistakes, and manage trades using strict risk-management rules. The robot should continuously analyze price action, market structure, trend direction, volatility, support and resistance, momentum, and selected technical
1. PROJECT OVERVIEW Development of a custom automated and manual trading bot for NinjaTrader 8, primarily designed for Nasdaq Futures (NQ/MNQ). The bot will contain the original trading strategy, configurable risk management, automatic and manual operating modes, alerts, profit/loss management, partial profit taking, Break Even, backtesting functionality, and the additional configurable contract-averaging system
Hello, I have a custom indicator with a specific line. Logic I want: 1. When a candle closes and crosses the indicator line (I will tell you the buffer number of this line), start counting. 2. After the cross, wait for 3 consecutive candles with the same color / same direction. 3. If the 3 candles are bullish, open a BUY trade on the next candle open. 4. If the 3 candles are bearish, open a SELL trade on the
I need I trading robot with a dashboard for stop and start working 99%accurate profit while scalping me the user only putting password of mt5 then I run it that doesn't take a long time to process a trade and always making sure that altlest it makes 500dollars per day using 0.05 lot size
Simple RSI based EA
30+ USD
Require an EA that opens trades at preselected RSI values. The EA will then monitor the gain/loss of the open positions and close them as specified in terms of points gain/loss. Once a position closes, the action will trigger the opening of other positions as specified
Looking for liquidity indicator
50+ USD
Look at this chart. The ellipses that I have identified show reversals and liquidity was I am trying to find a good way to identify these areas an indicator that automatically detects the sweep and reversal Look at this chart. The ellipses that I have identified show reversals and liquidity was
TraderBlox AI made this RSI bot – anyone speak MQL5?
200 - 300 USD
Anyone with experience in trading bots? I'm using TraderBlox ( https://traderblox.com/ ) and the AI assistant generated a bot with RSI that's showing a 68% win rate in backtesting. However, the generated code has some parts " Important: I will only reply to those who send me a photo of their project and have read this; this way I rule out bots. "I don't fully understand (especially order management and dynamic
Ich möchte einen professionellen Expert Advisor (EA) für MetaTrader 5 entwickeln lassen, der sich funktional am ThunderGold Scalper orientiert. Instrument: XAUUSD / GOLD Zeitrahmen: M15 Plattform: MetaTrader 5 / MQL5 Der EA soll eine eigene, nachprogrammierte Strategie verwenden und keine geschützten Quellcodes oder proprietären Dateien des Originalprodukts kopieren. Gewünschte Funktionen: automatischer Handel auf
XAGUSD MT5 Automated Trading Expert Advisor
30 - 200 USD
I need a fully automated Expert Advisor (EA) written in MQL5 for MetaTrader 5. The EA must work directly inside MT5 and must NOT require TradingView, PineConnector, webhooks, or another external connector to place trades. Trading Instrument Primary symbol: XAGUSD (Silver) My broker may display the symbol as XAGUSD-ECN, so the EA should work with the broker’s available XAGUSD symbol. Main entry timeframe: 5-minute
SmartMove_EA
30+ USD
I need a EA programer to program my EA for MLQ5 to sell at the last candle before impulses to the downside(-) and buy on the last candle before the upside(+) movement. For the take profit we target the nearest high for buy and target nearest low for sell.Stop loss on the last weak of the order block
Projektdetails
Budget
30 - 100000 USD
Ausführungsfristen
von 1 bis 50 Tag(e)
Kunde
Veröffentlichte Aufträge1
Anzahl der Schlichtungen0