Specification
//+------------------------------------------------------------------+
//| XAUUSD Wolfe + SMC Quick Profit EA |
//| MT5 / MQL5 |
//+------------------------------------------------------------------+
#property strict
#include <Trade/Trade.mqh>
CTrade trade;
//==================================================================
// INPUTS
//==================================================================
//--- General
input string InpSymbol = ""; // Blank = chart symbol
input ulong MagicNumber = 26082301;
input double InitialLot = 0.01;
input double AddLot = 0.01;
input int MaxPositions = 3;
input double MaxTotalLots = 0.03;
//--- Commission / profit
input double CommissionPer001 = 0.45; // USD per 0.01 lot
input double MinimumNetProfit = 0.10; // Desired net profit
input double ProfitBuffer = 0.05; // Safety buffer
//--- Entry
input ENUM_TIMEFRAMES BiasTF = PERIOD_M5;
input ENUM_TIMEFRAMES EntryTF = PERIOD_M1;
input int FastEMA = 20;
input int SlowEMA = 50;
input int SwingLookback = 80;
input int SwingStrength = 2;
input double WolfeTolerancePoints = 150;
input double EntryZonePoints = 250;
//--- Risk
input double StopLossPoints = 1200;
input double MaxBasketLossUSD = 25.0;
input double MaxDailyLossUSD = 50.0;
//--- Spread
input double MaxSpreadPoints = 120;
//--- Scaling
input double AddAfterProfitUSD = 0.30;
input int MinimumSecondsBetweenAdds = 60;
//--- Trading hours
input bool UseTradingHours = true;
input int StartHour = 7;
input int EndHour = 22;
//--- Execution
input int DeviationPoints = 30;
//==================================================================
// GLOBALS
//==================================================================
string TradeSymbol;
datetime LastBarM1 = 0;
datetime LastAddTime = 0;
datetime DayStart = 0;
double DailyStartEquity = 0;
//==================================================================
// INITIALIZATION
//==================================================================
int OnInit()
{
TradeSymbol = InpSymbol;
if(TradeSymbol == "")
TradeSymbol = _Symbol;
trade.SetExpertMagicNumber(MagicNumber);
trade.SetDeviationInPoints(DeviationPoints);
DailyStartEquity = AccountInfoDouble(ACCOUNT_EQUITY);
MqlDateTime dt;
TimeToStruct(TimeCurrent(),dt);
dt.hour = 0;
dt.min = 0;
dt.sec = 0;
DayStart = StructToTime(dt);
Print("EA initialized on ", TradeSymbol);
return(INIT_SUCCEEDED);
}
//==================================================================
// MAIN
//==================================================================
void OnTick()
{
if(_Symbol != TradeSymbol)
return;
UpdateDailyReference();
// Manage existing basket first
ManageBasket();
// Protect account
if(DailyLossExceeded())
return;
if(!TradingTime())
return;
if(!SpreadOK())
return;
// Only make a new decision on a new M1 candle
datetime currentBar = iTime(TradeSymbol,EntryTF,0);
if(currentBar == LastBarM1)
return;
LastBarM1 = currentBar;
// Existing basket?
int positions = CountPositions();
if(positions > 0)
{
ManageScaling();
return;
}
// No open basket: search for new trade
int signal = GetTradeSignal();
if(signal == 1)
{
OpenBuy(InitialLot);
}
else if(signal == -1)
{
OpenSell(InitialLot);
}
}
//==================================================================
// SIGNAL ENGINE
//==================================================================
int GetTradeSignal()
{
int bias = GetMarketBias();
if(bias == 0)
return 0;
bool wolfe = DetectWolfeStyleSetup(bias);
if(!wolfe)
return 0;
bool confirmation = M1Confirmation(bias);
if(!confirmation)
return 0;
return bias;
}
//==================================================================
// MARKET BIAS
//==================================================================
int GetMarketBias()
{
double fast = iMAValue(TradeSymbol,BiasTF,FastEMA,1);
double slow = iMAValue(TradeSymbol,BiasTF,SlowEMA,1);
if(fast == 0 || slow == 0)
return 0;
double close = iClose(TradeSymbol,BiasTF,1);
// Bearish
if(fast < slow && close < fast)
return -1;
// Bullish
if(fast > slow && close > fast)
return 1;
return 0;
}
//==================================================================
// WOLFE STYLE SETUP
//==================================================================
bool DetectWolfeStyleSetup(int direction)
{
double highs[10];
double lows[10];
int highCount = GetSwingHighs(highs,10);
int lowCount = GetSwingLows(lows,10);
if(highCount < 3 || lowCount < 3)
return false;
double price = iClose(TradeSymbol,BiasTF,1);
//==============================================================
// BEARISH WOLFE-STYLE SETUP
//==============================================================
if(direction == -1)
{
double h1 = highs[2];
double h3 = highs[1];
double h5 = highs[0];
double l2 = lows[2];
double l4 = lows[1];
// Successive higher highs
bool higherHighs = (h3 > h1 && h5 > h3);
// Higher lows
bool higherLows = (l4 > l2);
if(!higherHighs || !higherLows)
return false;
// Estimate upper wedge boundary
double upperSlope = (h5 - h1) / 4.0;
double projectedResistance = h5 + upperSlope;
// Price should be near final high / rejection zone
double distance =
MathAbs(price - h5) / SymbolInfoDouble(TradeSymbol,SYMBOL_POINT);
if(distance <= EntryZonePoints)
return true;
}
//==============================================================
// BULLISH WOLFE-STYLE SETUP
//==============================================================
if(direction == 1)
{
double l1 = lows[2];
double l3 = lows[1];
double l5 = lows[0];
double h2 = highs[2];
double h4 = highs[1];
bool lowerLows = (l3 < l1 && l5 < l3);
bool lowerHighs = (h4 < h2);
if(!lowerLows || !lowerHighs)
return false;
double lowerSlope = (l5 - l1) / 4.0;
double projectedSupport = l5 + lowerSlope;
double distance =
MathAbs(price - l5) / SymbolInfoDouble(TradeSymbol,SYMBOL_POINT);
if(distance <= EntryZonePoints)
return true;
}
return false;
}
//==================================================================
// M1 CONFIRMATION
//==================================================================
bool M1Confirmation(int direction)
{
double open1 = iOpen(TradeSymbol,EntryTF,1);
double close1 = iClose(TradeSymbol,EntryTF,1);
double high1 = iHigh(TradeSymbol,EntryTF,1);
double low1 = iLow(TradeSymbol,EntryTF,1);
double open2 = iOpen(TradeSymbol,EntryTF,2);
double close2 = iClose(TradeSymbol,EntryTF,2);
//==============================================================
// BEARISH
//==============================================================
if(direction == -1)
{
bool bearishCandle = close1 < open1;
bool bearishShift = close1 < low2();
bool rejection =
(high1 - MathMax(open1,close1)) >
(MathMin(open1,close1) - low1);
if(bearishCandle && (bearishShift || rejection))
return true;
}
//==============================================================
// BULLISH
//==============================================================
if(direction == 1)
{
bool bullishCandle = close1 > open1;
bool bullishShift = close1 > high2();
bool rejection =
(MathMin(open1,close1) - low1) >
(high1 - MathMax(open1,close1));
if(bullishCandle && (bullishShift || rejection))
return true;
}
return false;
}
//==================================================================
// SWING DETECTION
//==================================================================
int GetSwingHighs(double &values[],int maxValues)
{
int found = 0;
for(int i=SwingStrength+1;
i<SwingLookback && found<maxValues;
i++)
{
bool swing = true;
double h = iHigh(TradeSymbol,BiasTF,i);
for(int j=1;j<=SwingStrength;j++)
{
if(h <= iHigh(TradeSymbol,BiasTF,i-j) ||
h <= iHigh(TradeSymbol,BiasTF,i+j))
{
swing = false;
break;
}
}
if(swing)
{
values[found] = h;
found++;
}
}
return found;
}
//------------------------------------------------------------------
int GetSwingLows(double &values[],int maxValues)
{
int found = 0;
for(int i=SwingStrength+1;
i<SwingLookback && found<maxValues;
i++)
{
bool swing = true;
double l = iLow(TradeSymbol,BiasTF,i);
for(int j=1;j<=SwingStrength;j++)
{
if(l >= iLow(TradeSymbol,BiasTF,i-j) ||
l >= iLow(TradeSymbol,BiasTF,i+j))
{
swing = false;
break;
}
}
if(swing)
{
values[found] = l;
found++;
}
}
return found;
}
//==================================================================
// POSITION MANAGEMENT
//==================================================================
void ManageBasket()
{
int count = CountPositions();
if(count <= 0)
return;
double basketProfit = BasketProfit();
double requiredProfit =
BasketCommission() +
MinimumNetProfit +
ProfitBuffer;
// Fast profit exit
if(basketProfit >= requiredProfit)
{
CloseBasket();
Print("Basket closed. Gross P/L: ",
basketProfit,
" Required: ",
requiredProfit);
return;
}
// Emergency basket stop
if(basketProfit <= -MaxBasketLossUSD)
{
CloseBasket();
Print("Emergency basket loss reached.");
return;
}
}
//==================================================================
// SCALING
//==================================================================
void ManageScaling()
{
int count = CountPositions();
if(count >= MaxPositions)
return;
double lots = TotalLots();
if(lots + AddLot > MaxTotalLots)
return;
if(TimeCurrent() - LastAddTime <
MinimumSecondsBetweenAdds)
return;
double profit = BasketProfit();
// NEVER add to a losing basket
if(profit < AddAfterProfitUSD)
return;
int direction = BasketDirection();
if(direction == 1)
{
if(OpenBuy(AddLot))
LastAddTime = TimeCurrent();
}
else if(direction == -1)
{
if(OpenSell(AddLot))
LastAddTime = TimeCurrent();
}
}
//==================================================================
// BUY
//==================================================================
bool OpenBuy(double lot)
{
lot = NormalizeLot(lot);
double ask = SymbolInfoDouble(TradeSymbol,SYMBOL_ASK);
if(ask <= 0)
return false;
double sl = 0;
if(StopLossPoints > 0)
{
sl = ask -
StopLossPoints *
SymbolInfoDouble(TradeSymbol,SYMBOL_POINT);
sl = NormalizeDouble(
sl,
(int)SymbolInfoInteger(TradeSymbol,SYMBOL_DIGITS)
);
}
return trade.Buy(
lot,
TradeSymbol,
ask,
sl,
0,
"Wolfe-SMC BUY"
);
}
//==================================================================
// SELL
//==================================================================
bool OpenSell(double lot)
{
lot = NormalizeLot(lot);
double bid = SymbolInfoDouble(TradeSymbol,SYMBOL_BID);
if(bid <= 0)
return false;
double sl = 0;
if(StopLossPoints > 0)
{
sl = bid +
StopLossPoints *
SymbolInfoDouble(TradeSymbol,SYMBOL_POINT);
sl = NormalizeDouble(
sl,
(int)SymbolInfoInteger(TradeSymbol,SYMBOL_DIGITS)
);
}
return trade.Sell(
lot,
TradeSymbol,
bid,
sl,
0,
"Wolfe-SMC SELL"
);
}
//==================================================================
// BASKET PROFIT
//==================================================================
double BasketProfit()
{
double total = 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) != TradeSymbol)
continue;
if((ulong)PositionGetInteger(POSITION_MAGIC)
!= MagicNumber)
continue;
total += PositionGetDouble(POSITION_PROFIT);
total += PositionGetDouble(POSITION_SWAP);
}
return total;
}
//==================================================================
// COMMISSION ESTIMATE
//==================================================================
double BasketCommission()
{
double lots = TotalLots();
return (lots / 0.01) * CommissionPer001;
}
//==================================================================
// TOTAL LOTS
//==================================================================
double TotalLots()
{
double lots = 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) != TradeSymbol)
continue;
if((ulong)PositionGetInteger(POSITION_MAGIC)
!= MagicNumber)
continue;
lots += PositionGetDouble(POSITION_VOLUME);
}
return lots;
}
//==================================================================
// COUNT POSITIONS
//==================================================================
int CountPositions()
{
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) != TradeSymbol)
continue;
if((ulong)PositionGetInteger(POSITION_MAGIC)
!= MagicNumber)
continue;
count++;
}
return count;
}
//==================================================================
// BASKET DIRECTION
//==================================================================
int BasketDirection()
{
double buyLots = 0;
double sellLots = 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) != TradeSymbol)
continue;
if((ulong)PositionGetInteger(POSITION_MAGIC)
!= MagicNumber)
continue;
ENUM_POSITION_TYPE type =
(ENUM_POSITION_TYPE)
PositionGetInteger(POSITION_TYPE);
double lots =
PositionGetDouble(POSITION_VOLUME);
if(type == POSITION_TYPE_BUY)
buyLots += lots;
if(type == POSITION_TYPE_SELL)
sellLots += lots;
}
if(buyLots > sellLots)
return 1;
if(sellLots > buyLots)
return -1;
return 0;
}
//==================================================================
// CLOSE BASKET
//==================================================================
void CloseBasket()
{
for(int i=PositionsTotal()-1;i>=0;i--)
{
ulong ticket = PositionGetTicket(i);
if(ticket == 0)
continue;
if(!PositionSelectByTicket(ticket))
continue;
if(PositionGetString(POSITION_SYMBOL) != TradeSymbol)
continue;
if((ulong)PositionGetInteger(POSITION_MAGIC)
!= MagicNumber)
continue;
trade.PositionClose(ticket);
}
}
//==================================================================
// SPREAD FILTER
//==================================================================
bool SpreadOK()
{
double ask =
SymbolInfoDouble(TradeSymbol,SYMBOL_ASK);
double bid =
SymbolInfoDouble(TradeSymbol,SYMBOL_BID);
double point =
SymbolInfoDouble(TradeSymbol,SYMBOL_POINT);
if(point <= 0)
return false;
double spread =
(ask-bid)/point;
return spread <= MaxSpreadPoints;
}
//==================================================================
// TRADING HOURS
//==================================================================
bool TradingTime()
{
if(!UseTradingHours)
return true;
MqlDateTime dt;
TimeToStruct(TimeCurrent(),dt);
if(StartHour < EndHour)
{
if(dt.hour >= StartHour &&
dt.hour < EndHour)
return true;
}
else
{
if(dt.hour >= StartHour ||
dt.hour < EndHour)
return true;
}
return false;
}
//==================================================================
// DAILY LOSS
//==================================================================
bool DailyLossExceeded()
{
double equity =
AccountInfoDouble(ACCOUNT_EQUITY);
double loss =
DailyStartEquity - equity;
return loss >= MaxDailyLossUSD;
}
//==================================================================
// RESET DAILY EQUITY
//==================================================================
void UpdateDailyReference()
{
MqlDateTime dt;
TimeToStruct(TimeCurrent(),dt);
dt.hour = 0;
dt.min = 0;
dt.sec = 0;
datetime today = StructToTime(dt);
if(today != DayStart)
{
DayStart = today;
DailyStartEquity =
AccountInfoDouble(ACCOUNT_EQUITY);
}
}
//==================================================================
// EMA VALUE
//==================================================================
double iMAValue(
string symbol,
ENUM_TIMEFRAMES timeframe,
int period,
int shift
)
{
int handle =
iMA(
symbol,
timeframe,
period,
0,
MODE_EMA,
PRICE_CLOSE
);
if(handle == INVALID_HANDLE)
return 0;
double buffer[];
ArraySetAsSeries(buffer,true);
if(CopyBuffer(handle,0,shift,1,buffer) <= 0)
{
IndicatorRelease(handle);
return 0;
}
double value = buffer[0];
IndicatorRelease(handle);
return value;
}
//==================================================================
// BAR HELPERS
//==================================================================
double low2()
{
return iLow(TradeSymbol,EntryTF,2);
}
double high2()
{
return iHigh(TradeSymbol,EntryTF,2);
}
//==================================================================
// LOT NORMALIZATION
//==================================================================
double NormalizeLot(double lot)
{
double minLot =
SymbolInfoDouble(TradeSymbol,SYMBOL_VOLUME_MIN);
double maxLot =
SymbolInfoDouble(TradeSymbol,SYMBOL_VOLUME_MAX);
double step =
SymbolInfoDouble(TradeSymbol,SYMBOL_VOLUME_STEP);
if(lot < minLot)
lot = minLot;
if(lot > maxLot)
lot = maxLot;
lot =
MathFloor(lot/step)*step;
return NormalizeDouble(lot,2);
}
//+------------------------------------------------------------------+
Responded
1
Rating
Projects
520
24%
Arbitration
61
57%
/
25%
Overdue
60
12%
Loaded
2
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
3
Rating
Projects
1
0%
Arbitration
0
Overdue
0
Free
Published: 3 codes
4
Rating
Projects
1
0%
Arbitration
0
Overdue
1
100%
Free
5
Rating
Projects
2
0%
Arbitration
1
0%
/
100%
Overdue
0
Free
6
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
7
Rating
Projects
21
38%
Arbitration
0
Overdue
1
5%
Working
8
Rating
Projects
32
41%
Arbitration
9
22%
/
33%
Overdue
4
13%
Loaded
Published: 8 articles, 35 codes
9
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
10
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
11
Rating
Projects
2
50%
Arbitration
0
Overdue
0
Free
12
Rating
Projects
1
0%
Arbitration
0
Overdue
0
Free
13
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
14
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
Published: 1 code
15
Rating
Projects
12
33%
Arbitration
0
Overdue
2
17%
Working
Published: 1 code
16
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
17
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
18
Rating
Projects
3
0%
Arbitration
0
Overdue
0
Free
Published: 2 codes
19
Rating
Projects
4
0%
Arbitration
1
100%
/
0%
Overdue
1
25%
Free
20
Rating
Projects
269
29%
Arbitration
2
50%
/
0%
Overdue
3
1%
Working
Published: 2 codes
21
Rating
Projects
478
40%
Arbitration
105
40%
/
24%
Overdue
82
17%
Loaded
Published: 2 codes
22
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
23
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
Published: 1 code
24
Rating
Projects
2
50%
Arbitration
0
Overdue
1
50%
Working
25
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
26
Rating
Projects
1
0%
Arbitration
0
Overdue
0
Free
27
Rating
Projects
7
71%
Arbitration
0
Overdue
0
Free
Published: 1 article, 2 codes
28
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
29
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
30
Rating
Projects
102
23%
Arbitration
12
25%
/
17%
Overdue
13
13%
Free
31
Rating
Projects
1
0%
Arbitration
1
100%
/
0%
Overdue
0
Free
32
Rating
Projects
280
21%
Arbitration
26
58%
/
15%
Overdue
0
Working
33
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
34
Rating
Projects
1
0%
Arbitration
0
Overdue
1
100%
Free
35
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
36
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
Similar orders
I’m looking for an experienced MQL5 developer to build a custom MT5 Expert Advisor for gold scalping, based on clearly defined support/resistance levels and false breakouts. Before development, I would welcome your technical feedback on the proposed rules, their feasibility, and any improvements you recommend. Please explain the reasoning behind your suggestions rather than promising returns. Proposed strategy: 1
Here is a professional, detailed requirements specification draft for your MQL5 freelance order based on your prompt: Strategy Objective: Develop an automated Expert Advisor (EA) featuring a 1:3 Risk-to-Reward ratio optimized for a small starting budget. Core Trading Logic: Execute automatic Buy and Sell trades using high-probability entry signals. Target a strict 90% theoretical win-rate structure through
i want to fix my gold martingale bot MT5. RSI 14 ENTRY 30 BUY 70 SELL Lot 0.02 0.04 0.07 TP 150 for all SL 90 30 30 once total daily profit is 200$ stop trading stop trading once 2 consecutives total losses stop trading if spread exceeded 30 and between hour 15 & 17 PM Move SL to breakeven point once the profit exceeded 50 from from breakeven thanks
MarketMind Breakout Pro XAUUSD H1 — Donchian Breakout EA Project type: Personal EA development and backtesting Platform: MetaTrader 5 Instrument: XAUUSD Timeframe: H1 Strategy: Donchian Channel breakout with EMA 200 Project overview This project evaluates a Donchian breakout trading strategy for XAUUSD on the H1 timeframe. The system uses channel-based breakout conditions and an EMA 200 trend filter. Historical
The purpose of this order is ONLY to test and implement my H1 POI (Point of Interest) identification logic correctly. I am not requesting the complete EA at this stage. I will provide the exact rules for identifying the H1 POI after selecting the developer. The developer must convert those rules into clear, deterministic MQL5 logic. Requirements: Analyze H1 candles according to the rules I provide. Identify and mark
Title: Fully Automatic MT5 Trading Bot (Expert Advisor) with Risk Management I want a fully automated trading robot (Expert Advisor) for MetaTrader 5, written in MQL5. The bot must automatically analyse market data, identify trading opportunities, execute BUY and SELL orders, manage open positions, and close trades according to predefined rules without requiring manual confirmation for each trade. Requirements
Hello, I’m looking for an experienced developer to research, build, test, and install a fully automated MetaTrader 5 trading bot for gold, XAUUSD. My total development and installation budget is $300, including all agreed work and fees. My goal is to pass a $100,000 FTMO US Two-Step Standard evaluation and sustainably maintain the funded account. I need a day-trading strategy that can buy in bullish markets and sell
MT4 expert advisor
500+ USD
I have three indicators that operate independently. I want to combine them into one indicator with custom expert programming that automatically enters trades when a signal is generated by one of the indicators. I will pay for this service Thanks you
Existing EA: NEW_CORE_ORB_M5_v021 | MT5 | XAUUSD M5 Early-stage research prototype, not a new EA from scratch. Need an experienced MQL5 developer to audit, complete, repair, improve and test BOTH independent strategies equally: Opening Range Breakout (ORB) and Scalp. Keep code lightweight and preserve an untouched baseline. No unnecessary rewrite or complex filters. 1. ORB Strategy Verify opening-range construction
Hello International Developer, I need LIFETIME MT5 EA for XAUUSD Gold. REQUIREMENTS: 1. Lifetime bot - No expiry date, unlimited accounts, unlimited installations 2. Must include source code .mq5 file - This makes it lifetime 3. Every trade MUST have Stop Loss 300 points and Take Profit 600 points 4. No martingale, No grid, No averaging - Clean safe strategy 5. Auto lot size = 1% risk per trade for good margin growth
Project information
Budget
89+ USD
Deadline
from 1 to 30 day(s)