Şartname
//+------------------------------------------------------------------+
//| TrendPullbackEA.mq5 |
//| Simple Trend + Pullback Strategy EA (Beginner Friendly) |
//+------------------------------------------------------------------+
#property strict
#include <Trade/Trade.mqh>
CTrade trade;
//-------------------------------------------------------------------
// INPUT PARAMETERS
//-------------------------------------------------------------------
// EMA Settings
input int FastEMA = 20; // Fast EMA period
input int SlowEMA = 50; // Slow EMA period
// Pullback Settings
input int PullbackBars = 5; // Number of bars for pullback check
// Stop Loss Settings
input int SL_Mode = 0; // 0 = Swing SL, 1 = ATR SL
input int ATR_Period = 14; // ATR period
input double ATR_Multiplier = 1.5; // ATR multiplier for ATR stop
// Risk/Reward
input double RiskReward = 2.0; // Risk-to-reward ratio
// Lot Size Management
input bool UseFixedLot = false; // Use fixed lot size or risk percentage
input double FixedLotSize = 0.10; // Fixed lot size if UseFixedLot = true
input double RiskPercentage = 1.0; // Risk percentage of account balance
// Trading Settings
input ulong MagicNumber = 2023; // Unique magic number to track trades
input int TradeStartHour = 7; // Start trading at 7 AM
input int TradeEndHour = 20; // End trading at 8 PM
// Debugging
input bool DebugMode = true; // Enable debug logs
//-------------------------------------------------------------------
// GLOBAL VARIABLES
//-------------------------------------------------------------------
int fastEMAHandle = INVALID_HANDLE;
int slowEMAHandle = INVALID_HANDLE;
int atrHandle = INVALID_HANDLE;
//+------------------------------------------------------------------+
//| Expert Initialization |
//+------------------------------------------------------------------+
int OnInit()
{
// Create Fast EMA Indicator Handle
fastEMAHandle = iMA(_Symbol, PERIOD_CURRENT, FastEMA, 0, MODE_EMA, PRICE_CLOSE);
// Create Slow EMA Indicator Handle
slowEMAHandle = iMA(_Symbol, PERIOD_CURRENT, SlowEMA, 0, MODE_EMA, PRICE_CLOSE);
// Create ATR Indicator Handle
atrHandle = iATR(_Symbol, PERIOD_CURRENT, ATR_Period);
// Check that all handles were created successfully
if (fastEMAHandle == INVALID_HANDLE || slowEMAHandle == INVALID_HANDLE || atrHandle == INVALID_HANDLE)
{
Print("ERROR: Failed to create indicator handles.");
return (INIT_FAILED);
}
// Set magic number
trade.SetExpertMagicNumber(MagicNumber);
if (DebugMode)
Print("TrendPullbackEA initialized successfully.");
return (INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert Deinitialization |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
// Release indicator handles
if (fastEMAHandle != INVALID_HANDLE)
IndicatorRelease(fastEMAHandle);
if (slowEMAHandle != INVALID_HANDLE)
IndicatorRelease(slowEMAHandle);
if (atrHandle != INVALID_HANDLE)
IndicatorRelease(atrHandle);
}
//+------------------------------------------------------------------+
//| Expert Tick Function |
//+------------------------------------------------------------------+
void OnTick()
{
// Run once per new candle
static datetime lastBarTime = 0;
datetime currentBarTime = iTime(_Symbol, PERIOD_CURRENT, 0);
if (currentBarTime == lastBarTime)
return; // Only proceed on new candle
lastBarTime = currentBarTime;
// Check trading hours
MqlDateTime timeStruct = {};
TimeToStruct(TimeCurrent(), timeStruct);
int currentHour = timeStruct.hour;
if (currentHour < TradeStartHour || currentHour >= TradeEndHour)
return; // Only trade during specified hours
// Ensure only one trade per symbol
if (PositionSelect(_Symbol))
return; // Exit if a position is already open on this symbol
// Prepare indicator buffers
double fastEMA[3];
double slowEMA[3];
double atrValue[1];
ArraySetAsSeries(fastEMA, true);
ArraySetAsSeries(slowEMA, true);
ArraySetAsSeries(atrValue, true);
// Copy EMA data
if (CopyBuffer(fastEMAHandle, 0, 0, 3, fastEMA) < 3)
return;
if (CopyBuffer(slowEMAHandle, 0, 0, 3, slowEMA) < 3)
return;
if (CopyBuffer(atrHandle, 0, 0, 1, atrValue) < 1)
return;
// Determine trend
bool uptrend = (fastEMA[1] > slowEMA[1]);
bool downtrend = (fastEMA[1] < slowEMA[1]);
// Check pullback conditions
bool buyPullback = CheckBuyPullback(fastEMA[1], slowEMA[1]);
bool sellPullback = CheckSellPullback(fastEMA[1], slowEMA[1]);
// Check candle patterns
bool bullishEngulfing = IsBullishEngulfing();
bool bearishEngulfing = IsBearishEngulfing();
// BUY conditions
if (uptrend && buyPullback && bullishEngulfing)
{
OpenBuy(atrValue[0]);
}
// SELL conditions
if (downtrend && sellPullback && bearishEngulfing)
{
OpenSell(atrValue[0]);
}
}
//+------------------------------------------------------------------+
//| Check Buy Pullback |
//+------------------------------------------------------------------+
bool CheckBuyPullback(double fastEMAValue, double slowEMAValue)
{
for (int i = 1; i <= PullbackBars; i++)
{
double lowPrice = iLow(_Symbol, PERIOD_CURRENT, i);
if (lowPrice <= fastEMAValue && lowPrice >= slowEMAValue)
return true;
}
return false;
}
//+------------------------------------------------------------------+
//| Check Sell Pullback |
//+------------------------------------------------------------------+
bool CheckSellPullback(double fastEMAValue, double slowEMAValue)
{
for (int i = 1; i <= PullbackBars; i++)
{
double highPrice = iHigh(_Symbol, PERIOD_CURRENT, i);
if (highPrice >= fastEMAValue && highPrice <= slowEMAValue)
return true;
}
return false;
}
//+------------------------------------------------------------------+
//| Bullish Engulfing Pattern |
//+------------------------------------------------------------------+
bool IsBullishEngulfing()
{
double open1 = iOpen(_Symbol, PERIOD_CURRENT, 1);
double close1 = iClose(_Symbol, PERIOD_CURRENT, 1);
double open2 = iOpen(_Symbol, PERIOD_CURRENT, 2);
double close2 = iClose(_Symbol, PERIOD_CURRENT, 2);
bool previousBearish = (close2 < open2);
bool currentBullish = (close1 > open1);
bool engulfing = (open1 <= close2) && (close1 >= open2);
return (previousBearish && currentBullish && engulfing);
}
//+------------------------------------------------------------------+
//| Bearish Engulfing Pattern |
//+------------------------------------------------------------------+
bool IsBearishEngulfing()
{
double open1 = iOpen(_Symbol, PERIOD_CURRENT, 1);
double close1 = iClose(_Symbol, PERIOD_CURRENT, 1);
double open2 = iOpen(_Symbol, PERIOD_CURRENT, 2);
double close2 = iClose(_Symbol, PERIOD_CURRENT, 2);
bool previousBullish = (close2 > open2);
bool currentBearish = (close1 < open1);
bool engulfing = (open1 >= close2) && (close1 <= open2);
return (previousBullish && currentBearish && engulfing);
}
//+------------------------------------------------------------------+
//| Open Buy Trade |
//+------------------------------------------------------------------+
void OpenBuy(double atr)
{
double askPrice = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double stopLoss = 0.0;
double takeProfit = 0.0;
// Calculate stop loss
if (SL_Mode == 0)
stopLoss = GetRecentSwingLow();
else
stopLoss = askPrice - (atr * ATR_Multiplier);
double riskDistance = askPrice - stopLoss;
if (riskDistance <= 0.0)
return; // Invalid risk, skip trade
// Calculate take profit
takeProfit = askPrice + (riskDistance * RiskReward);
// Calculate lot size
double lotSize = CalculateLotSize(riskDistance);
// Execute buy trade
bool result = trade.Buy(
lotSize,
_Symbol,
0.0,
NormalizeDouble(stopLoss, _Digits),
NormalizeDouble(takeProfit, _Digits),
"Trend Pullback Buy"
);
// Debug log
if (DebugMode)
{
if (result)
Print("BUY trade opened successfully.");
else
Print("BUY trade failed. Error: ", GetLastError());
}
}
//+------------------------------------------------------------------+
//| Open Sell Trade |
//+------------------------------------------------------------------+
void OpenSell(double atr)
{
double bidPrice = SymbolInfoDouble(_Symbol, SYMBOL_BID);
double stopLoss = 0.0;
double takeProfit = 0.0;
// Calculate stop loss
if (SL_Mode == 0)
stopLoss = GetRecentSwingHigh();
else
stopLoss = bidPrice + (atr * ATR_Multiplier);
double riskDistance = stopLoss - bidPrice;
if (riskDistance <= 0.0)
return; // Invalid risk, skip trade
// Calculate take profit
takeProfit = bidPrice - (riskDistance * RiskReward);
// Calculate lot size
double lotSize = CalculateLotSize(riskDistance);
// Execute sell trade
bool result = trade.Sell(
lotSize,
_Symbol,
0.0,
NormalizeDouble(stopLoss, _Digits),
NormalizeDouble(takeProfit, _Digits),
"Trend Pullback Sell"
);
// Debug log
if (DebugMode)
{
if (result)
Print("SELL trade opened successfully.");
else
Print("SELL trade failed. Error: ", GetLastError());
}
}
//+------------------------------------------------------------------+
//| Get Recent Swing Low |
//+------------------------------------------------------------------+
double GetRecentSwingLow()
{
double swingLow = iLow(_Symbol, PERIOD_CURRENT, 1);
for (int i = 2; i <= (PullbackBars + 5); i++)
{
double currentLow = iLow(_Symbol, PERIOD_CURRENT, i);
if (currentLow < swingLow)
swingLow = currentLow;
}
return swingLow;
}
//+------------------------------------------------------------------+
//| Get Recent Swing High |
//+------------------------------------------------------------------+
double GetRecentSwingHigh()
{
double swingHigh = iHigh(_Symbol, PERIOD_CURRENT, 1);
for (int i = 2; i <= (PullbackBars + 5); i++)
{
double currentHigh = iHigh(_Symbol, PERIOD_CURRENT, i);
if (currentHigh > swingHigh)
swingHigh = currentHigh;
}
return swingHigh;
}
//+------------------------------------------------------------------+
//| Calculate Lot Size |
//+------------------------------------------------------------------+
double CalculateLotSize(double stopDistance)
{
// Fixed lot mode
if (UseFixedLot)
return NormalizeDouble(FixedLotSize, 2);
// Account balance
double balance = AccountInfoDouble(ACCOUNT_BALANCE);
// Risk amount based on percentage
double riskMoney = balance * (RiskPercentage / 100.0);
// Tick value of instrument
double tickValue = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);
// Distance in points
double points = stopDistance / _Point;
// Safety checks
if (points <= 0.0 || tickValue <= 0.0)
return NormalizeDouble(FixedLotSize, 2); // fallback to fixed lot if invalid
// Raw lot calculation
double rawLotSize = riskMoney / (points * tickValue);
// Broker limits
double minLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
double maxLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
double lotStep = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
// Normalize to broker step size
rawLotSize = MathFloor(rawLotSize / lotStep) * lotStep;
// Clamp lot size between min and max
rawLotSize = MathMax(minLot, MathMin(maxLot, rawLotSize));
return NormalizeDouble(rawLotSize, 2);
}
//+------------------------------------------------------------------+
Yanıtlandı
1
Derecelendirme
Projeler
0
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
2
Derecelendirme
Projeler
492
23%
Arabuluculuk
59
54%
/
25%
Süresi dolmuş
57
12%
Yüklendi
3
Derecelendirme
Projeler
0
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
4
Derecelendirme
Projeler
0
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
Benzer siparişler
Junior EA
30+ USD
1. EA for MT5, hedging allowed. 2. Entry: 50 EMA crosses 200 EMA on H1. Buy on bullish cross, sell on bearish. 3. SL: 100 pips, TP: 200 pips. No trailing stop. 4. Lot size: 0.01 fixed. Max 3 trades at once. 5. Trade only 08:00-18:00 GMT. No trades if spread > 20 points. 6. Inputs: EMA periods, SL, TP, lot size, start/end time
//+------------------------------------------------------------------+ //| BORGMAN SMC EA v8.7 - INSTITUTIONAL MERGE | //| Combines v8.5 risk architecture + v8.6 SMC engine | //+------------------------------------------------------------------+ #property strict #property version "8.70" #include <Trade/Trade.mqh> CTrade Trade; //---------------------- ENUMS ----------------------// enum ENUM_RR_MODE { RR_2R, // 1:2
Semi Automated Gold Trading Signal System for MT5
300 - 800 USD
I need an experienced MQL5 developer to build a semi automated trading signal system for Gold (XAUUSD) on MT5. The system is NOT a martingale or grid EA. The goal is to build a clean rule based signal engine that detects high probability setups based on predefined strategy rules and sends trading alerts with optional pending order logic. Main Requirements: 1. Signal Generation - Buy and Sell signals - Buy Limit - Buy
Mambo
30+ USD
I need a bot that can trade weltrade synthetic indices that can be consistently making profits if you have one for deriv its also fine a bot that executes and closes trades automat Will be ideal
MT5 Expert Advisor Specification: Asian Liquidity Sweep & M5 FVG Entry Project Overview Automated Expert Advisor for EUR/USD on MT5. The strategy maps structural liquidity (Fractal Swings) for entry triggers but targets absolute session extremes for Take Profit. It enters on the first opposite M5 Fair Value Gap (FVG) and features a dynamic, user-controlled risk engine. 1. Timezone & News Filter Requirements The
I am looking for an experienced MQL4/MQL5 developer to build a custom MT4 indicator from scratch or cracking my ex4 file that i provide to you. I already have an existing indicator (EX4) which produces highly accurate buy/sell signals. I want a similar indicator developed based on its observable behavior and signal structure. my existing indicator is pc id protected so you have to do PC ID security bypass and source
I am looking for an experienced MQL5 developer to build a professional Expert Advisor with the following specs: TECHNICAL REQUIREMENTS: - Platform: MetaTrader 5 (MT5) - Pairs: GBPUSD and EURUSD - Broker suffix support (e.g. GBPUSD@, EURUSD@) - Primary timeframe: M5 -Higher timeframe bias: H1 and H4 (for trend direction only) - One chart setup — manages both pairs from one chart STRATEGY: - Price action based: BOS
OBJETIVO Criar um Expert Advisor MT5 profissional para XAUUSD focado em: Consistência Baixo drawdown Scalping profissional Proteção da conta Crescimento sustentável Compatibilidade com conta micro e prop firms NÃO utilizar: Martingale Grid Hedge agressivo Recovery system Multiplicação de lotes após perda --- ATIVO XAUUSD apenas --- TIMEFRAMES Timeframe principal M5 Confirmação tendência M15 Confirmação macro opcional
Advanced ICT + CRT Smart Money Expert Advisor for MT5
300 - 1000 USD
I need a very advanced and intelligent MT5 Expert Advisor coded in MQL5 for XAUUSD, based on ICT + CRT + Smart Money Concepts. The goal is not a simple robot, but a professional decision-making system with strong filters, risk control, and high-quality trade selection. The EA must include: 1. Multi-Timeframe Analysis - D1 / H4 / H1 bias - M15 / M5 entry confirmation - Bullish or bearish market structure - BOS, CHoCH
An EA based on my INTRADAY TRADE NINJA system
30 - 35 USD
Intraday Trade Ninja EA — Complete Logic Structure This document maps the full architecture, execution logic, signal flow, trade management, and safety structure of the Intraday Trade Ninja MT4 Expert Advisor. 1. Core Indicators · ©Price Border (TMA bands) · MA-X Arrows · MA-Y Arrows · LeManSignal · EMA 49 & 89 - Per Candle Color Switching 2. EA Entry Architecture ·
Proje bilgisi
Bütçe
39+ USD
Son teslim tarihi
from 39 to 50 gün
Müşteri
Verilmiş siparişler1
Arabuluculuk sayısı0