指定
//+------------------------------------------------------------------+
//| 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);
}
//+------------------------------------------------------------------+
反馈
1
等级
项目
1
0%
仲裁
0
逾期
0
空闲
2
等级
项目
21
43%
仲裁
6
33%
/
17%
逾期
2
10%
已载入
发布者: 7 文章, 35 代码
3
等级
项目
4
0%
仲裁
1
100%
/
0%
逾期
1
25%
空闲
4
等级
项目
1
0%
仲裁
0
逾期
0
空闲
5
等级
项目
8
38%
仲裁
0
逾期
1
13%
工作中
发布者: 1 代码
6
等级
项目
0
0%
仲裁
0
逾期
0
空闲
7
等级
项目
0
0%
仲裁
0
逾期
0
空闲
8
等级
项目
45
16%
仲裁
2
0%
/
100%
逾期
4
9%
空闲
9
等级
项目
1
0%
仲裁
1
0%
/
100%
逾期
0
工作中
10
等级
项目
0
0%
仲裁
0
逾期
0
空闲
11
等级
项目
8
0%
仲裁
2
50%
/
0%
逾期
1
13%
工作中
12
等级
项目
7
29%
仲裁
0
逾期
1
14%
工作中
13
等级
项目
1
0%
仲裁
0
逾期
0
空闲
发布者: 1 代码
14
等级
项目
2
0%
仲裁
0
逾期
0
工作中
15
等级
项目
0
0%
仲裁
0
逾期
0
空闲
16
等级
项目
0
0%
仲裁
0
逾期
0
空闲
相似订单
MT5 EA
150+ USD
I am looking for a professional MQL5 developer to create a custom trading robot for MetaTrader 5. The Expert Advisor must operate strictly on H4 and D1 timeframes with a Moving Average crossover entry signal. It should open a total position of 0.02 lots split into two orders of 0.01 lots. It must include an initial ATR-based stop loss, an automatic break-even function, a custom pairs filter input (Symbols), a news
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
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
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
RECHERCHE DÉVELOPPEUR MQL5 — PARTENARIAT 50/50 Objectif : développer un EA de trading automatisé en 11 jours maximum pour participer à plusieurs concours de trading démo. Je recherche un développeur MQL5 expérimenté, capable de développer, tester et optimiser un EA proprement, avec une vraie maîtrise de la gestion du risque. CONCOURS VISÉS 🥇 XM — Weekly Demo Contest - Concours récurrent - Prize pool annoncé : 25 000
GoldTrade EA
89+ USD
//+------------------------------------------------------------------+ //| XAUUSD Wolfe + SMC Quick Profit EA | //| MT5 / MQL5 | //+------------------------------------------------------------------+ #property strict #include <Trade/Trade.mqh> CTrade trade; //================================================================== // INPUTS //================================================================== //--- General
Trading view indicator fixing
30+ USD
can you help me with I have an indicator that I built and I work with PickMyTrade. The entries come through the alerts I get from Trading View . Trading View needs to send an alert and PickMyTrade executes a trade at that exact same second. Now, I have a problem in Trading View with the synchronization between the alert and the signal. I have a box that I built for a trade. It needs to output the box and get an
项目信息
预算
30 - 100000 USD
截止日期
从 1 到 50 天
客户
所下订单1
仲裁计数0