Şartname

-----------+ //| EMA_BB_Fib_RSI_EA.mq5 | //| 1m scalping EMA/BB/RSI + Fib | //+------------------------------------------------------------------+ #property copyright "ChatGPT" #property version "1.00" #property strict #include <Trade/Trade.mqh> CTrade trade; //-------------------- Inputs -------------------- input ulong InpMagic = 240611; input double InpRiskPercent = 0.50; // risk per trade (% of balance) input bool InpOneTradeAtATime = true; input int InpEMAFast = 3; input int InpEMAMid = 9; input int InpEMASlow = 21; input int InpRSIPeriod = 14; input double InpRSILevel = 50.0; input int InpBBPeriod = 20; input double InpBBDeviation = 2.0; input int InpFibLookbackBars = 60; // how far to search swing high/low for fib input double InpFibSupportLow = 0.382; // fib zone lower bound for longs input double InpFibSupportHigh = 0.618; // fib zone upper bound for longs input double InpFibResistanceLow = 0.382; // fib zone lower bound for shorts input double InpFibResistanceHigh = 0.618; // fib zone upper bound for shorts input int InpSL_Method = 0; // 0=structure (recent swing), 1=BB-based, 2=fixed points buffer input double InpFixedSL_Points = 80; // used if SL_Method=2 input double InpFixedTP_RR = 1.2; // TP = SL * RR input bool InpUseTrailing = true; input double InpTrailStartR = 0.6; // start trailing after profit >= R input double InpTrailStepPoints = 20; //-------------------- Globals/Handles -------------------- int hEMAfast = INVALID_HANDLE; int hEMAmid = INVALID_HANDLE; int hEMAslow = INVALID_HANDLE; int hRSI = INVALID_HANDLE; int hBB = INVALID_HANDLE; // latest market data datetime lastBarTime = 0; //-------------------- Helper: Normalize -------------------- double NormalizeLots(double lots) { double minLot=SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN); double maxLot=SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX); double step =SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP); lots = MathMax(minLot, MathMin(maxLot, lots)); // adjust to step lots = MathFloor(lots/step)*step; return lots; } //-------------------- Helper: Get tick size/value -------------------- double GetTickValue() { // value per 1 tick for 1 lot double tickVal = 0.0; SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE, tickVal); return tickVal; } double GetTickSize() { double tickSize=0.0; SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE, tickSize); return tickSize; } //-------------------- Helper: Risk-based lot sizing -------------------- double CalcLots(double sl_points) { double balance = AccountInfoDouble(ACCOUNT_BALANCE); double riskMoney = balance * (InpRiskPercent/100.0); double tickSize = GetTickSize(); double tickValue = GetTickValue(); if(tickSize <= 0 || tickValue <= 0) return 0.01; // sl_points is in points (not price) // points -> price distance: sl_points * point double priceDist = sl_points * _Point; // number of ticks double ticks = priceDist / tickSize; if(ticks <= 0) return 0.01; double lossPerLot = ticks * tickValue; if(lossPerLot <= 0) return 0.01; double lots = riskMoney / lossPerLot; return NormalizeLots(lots); } //-------------------- Helper: Check open positions -------------------- bool HasOpenPosition() { if(!InpOneTradeAtATime) return false; for(int i=PositionsTotal()-1; i>=0; i--) { if(PositionSelectByIndex(i)) { string sym = PositionGetString(POSITION_SYMBOL); long mg = PositionGetInteger(POSITION_MAGIC); if(sym == _Symbol && (ulong)mg == InpMagic) return true; } } return false; } //-------------------- Helper: find recent swing high/low -------------------- // Simple swing approximation: highest high and lowest low over lookback. bool GetSwingHighLow(double &swingHigh, double &swingLow, int &highIndex, int &lowIndex) { swingHigh = -DBL_MAX; swingLow = DBL_MAX; highIndex = -1; lowIndex = -1; int bars = MathMin(InpFibLookbackBars, (int)Bars(_Symbol, PERIOD_M1)-2); if(bars < 10) return false; for(int i=1; i<=bars; i++) { double h = iHigh(_Symbol, PERIOD_M1, i); double l = iLow(_Symbol, PERIOD_M1, i); if(h > swingHigh) { swingHigh = h; highIndex = i; } if(l < swingLow) { swingLow = l; lowIndex = i; } } return (highIndex!=-1 && lowIndex!=-1); } //-------------------- Helper: compute Fib levels -------------------- void ComputeFibLevels(double swingHigh, double swingLow, double &lvl382, double &lvl618, bool uptrendForFib) { // If we assume move is from low->high (uptrend), fib retracement levels measured from high to low: // Standard: retracement = high - (high-low)*ratio // For long: support levels often use retracement during pullback. // We'll compute both ways based on which swing occurred later using uptrendForFib. // uptrendForFib=true means we consider low->high as the impulse. // Then retracement support = high - (high-low)*ratio // If downtrendForFib=false means high->low impulse: retracement resistance = low + (high-low)*ratio double range = MathAbs(swingHigh - swingLow); if(range <= 0) { lvl382=0; lvl618=0; return; } if(uptrendForFib) { lvl382 = swingHigh - (swingHigh - swingLow) * InpFibSupportLow; // 0.382 by default lvl618 = swingHigh - (swingHigh - swingLow) * InpFibSupportHigh; // 0.618 by default } else { // measuring resistance levels during bounce in a down impulse lvl382 = swingLow + (swingHigh - swingLow) * InpFibResistanceLow; lvl618 = swingLow + (swingHigh - swingLow) * InpFibResistanceHigh; } } //-------------------- Helper: trailing -------------------- void ManageTrailing() { if(!InpUseTrailing) return; for(int i=PositionsTotal()-1; i>=0; i--) { if(!PositionSelectByIndex(i)) continue; string sym = PositionGetString(POSITION_SYMBOL); long mg = PositionGetInteger(POSITION_MAGIC); if(sym != _Symbol || (ulong)mg != InpMagic) continue; long type = PositionGetInteger(POSITION_TYPE); double openPrice = PositionGetDouble(POSITION_PRICE_OPEN); double sl = PositionGetDouble(POSITION_SL); double tp = PositionGetDouble(POSITION_TP); double volume = PositionGetDouble(POSITION_VOLUME); double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID); double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK); // current profit in price distance double pointDist = 0; if(type == POSITION_TYPE_BUY) { double profit = bid - openPrice; pointDist = profit / _Point; if(profit <= 0) continue; } else { double profit = openPrice - ask; pointDist = profit / _Point; if(profit <= 0) continue; } // Compute R using SL distance double slDist = 0; if(sl > 0) { if(type == POSITION_TYPE_BUY) slDist = (openPrice - sl)/_Point; else slDist = (sl - openPrice)/_Point; } else slDist = InpFixedSL_Points; if(slDist <= 0) continue; double R = pointDist / slDist; if(R < InpTrailStartR) continue; // trail: for buy -> move SL up near EMA9; for sell -> move SL down near EMA9 double ema9 = 0.0; double buf[1]; // EMA9 buffer request is heavy; but fine for trailing if(CopyBuffer(hEMAmid, 0, 0, 1, buf) > 0) ema9 = buf[0]; if(ema9 <= 0) continue; double newSL = sl; if(type == POSITION_TYPE_BUY) { // SL should be below EMA9 newSL = ema9 - 5*_Point; // only raise SL if(newSL > sl) { // step check if((newSL - sl)/_Point >= InpTrailStepPoints) { trade.PositionModify(_Symbol, newSL, tp); } } } else { newSL = ema9 + 5*_Point; // only lower SL if(sl <= 0 || newSL < sl) { if(sl<=0 || (sl - newSL)/_Point >= InpTrailStepPoints) { trade.PositionModify(_Symbol, newSL, tp); } } } } } //-------------------- Helper: get indicator values at shift -------------------- bool GetIndi(double &emaFast, double &emaMid, double &emaSlow, double &rsi, double &bbUpper, double &bbBasis, double &bbLower) { double buf1[3], buf2[3], buf3[3], buf4[3]; ArraySetAsSeries(buf1,true); ArraySetAsSeries(buf2,true); ArraySetAsSeries(buf3,true); ArraySetAsSeries(buf4,true); // EMA buffers (shift 1 candle close used) int shift = 1; if(CopyBuffer(hEMAfast, 0, shift, 1, buf1) <= 0) return false; emaFast = buf1[0]; if(CopyBuffer(hEMAmid, 0, shift, 1, buf2) <= 0) return false; emaMid = buf2[0]; if(CopyBuffer(hEMAslow, 0, shift, 1, buf3) <= 0) return false; emaSlow = buf3[0]; // RSI if(CopyBuffer(hRSI, 0, shift, 1, buf4) <= 0) return false; rsi = buf4[0]; // BB: buffers: 0=upper,1=middle,2=lower (depends on MT5 implementation) // For iBands in MQL5: buffer 0=upper,1=middle,2=lower double buft[1]; if(CopyBuffer(hBB, 0, shift, 1, buft) <= 0) return false; bbUpper = buft[0]; if(CopyBuffer(hBB, 1, shift, 1, buft) <= 0) return false; bbBasis = buft[0]; if(CopyBuffer(hBB, 2, shift, 1, buft) <= 0) return false; bbLower = buft[0]; return true; } //-------------------- OnInit -------------------- int OnInit() { hEMAfast = iMA(_Symbol, PERIOD_M1, InpEMAFast, 0, MODE_EMA, PRICE_CLOSE); hEMAmid = iMA(_Symbol, PERIOD_M1, InpEMAMid, 0, MODE_EMA, PRICE_CLOSE); hEMAslow = iMA(_Symbol, PERIOD_M1, InpEMASlow, 0, MODE_EMA, PRICE_CLOSE); if(hEMAfast==INVALID_HANDLE || hEMAmid==INVALID_HANDLE || hEMAslow==INVALID_HANDLE) return INIT_FAILED; hRSI = iRSI(_Symbol, PERIOD_M1, InpRSIPeriod, PRICE_CLOSE); if(hRSI==INVALID_HANDLE) return INIT_FAILED; hBB = iBands(_Symbol, PERIOD_M1, InpBBPeriod, 0, InpBBDeviation, PRICE_CLOSE); if(hBB==INVALID_HANDLE) return INIT_FAILED; trade.SetExpertMagicNumber((int)InpMagic); return INIT_SUCCEEDED; } //-------------------- OnTick -------------------- void OnTick() { if(_Period != PERIOD_M1) return; // new bar check datetime t0 = iTime(_Symbol, PERIOD_M1, 0); if(t0 == lastBarTime) { // still manage trailing intrabar ManageTrailing(); return; } lastBarTime = t0; if(HasOpenPosition()) { ManageTrailing(); return; } // Get indicators on closed candle (shift=1) double emaFast, emaMid, emaSlow, rsi; double bbUpper, bbBasis, bbLower; if(!GetIndi(emaFast, emaMid, emaSlow, rsi, bbUpper, bbBasis, bbLower)) return; // Fibonacci swing double swingHigh, swingLow; int highIndex, lowIndex; if(!GetSwingHighLow(swingHigh, swingLow, highIndex, lowIndex)) return; // Determine impulse direction by which swing occurred later: // If lowIndex > highIndex (means low happened more recently, higher index is older? In our loop i=1..bars older increases) // In iHigh/iLow with shift i: i=1 is last closed candle, larger i is older. // So "more recent" has smaller i. bool lowMoreRecent = (lowIndex < highIndex); // low happened more recently bool upImpulse = lowMoreRecent; // low -> high impulse (up) double fib382, fib618; ComputeFibLevels(swingHigh, swingLow, fib382, fib618, upImpulse); // Prices (use last closed candle) double close1 = iClose(_Symbol, PERIOD_M1, 1); double open1 = iOpen(_Symbol, PERIOD_M1, 1); double high1 = iHigh(_Symbol, PERIOD_M1, 1); double low1 = iLow(_Symbol, PERIOD_M1, 1); // Fib zone checks bool inLongFibZone = (close1 >= MathMin(fib382, fib618) && close1 <= MathMax(fib382, fib618)); bool inShortFibZone = (close1 >= MathMin(fib382, fib618) && close1 <= MathMax(fib382, fib618)); // BB touch/close logic (reversion style) bool longBB = (low1 <= bbLower && close1 > bbLower) || (close1 > bbBasis); bool shortBB = (high1 >= bbUpper && close1 < bbUpper) || (close1 < bbBasis); // EMA alignment bool longEMA = (emaFast > emaMid && emaMid > emaSlow); bool shortEMA = (emaFast < emaMid && emaMid < emaSlow); // RSI 50 filter + direction hint (optional using two-candle change) double rsiPrev2 = 0.0; double tmp[1]; int shift2 = 2; if(CopyBuffer(hRSI, 0, shift2, 1, tmp) > 0) rsiPrev2 = tmp[0]; bool rsiLong = (rsi > InpRSILevel); bool rsiShort = (rsi < InpRSILevel); bool rsiRising = (rsiPrev2 > 0 ? (rsi > rsiPrev2) : true); bool rsiFalling = (rsiPrev2 > 0 ? (rsi < rsiPrev2) : true); // Structure SL estimate double sl=0,tp=0; double ask=SymbolInfoDouble(_Symbol, SYMBOL_ASK); double bid=SymbolInfoDouble(_Symbol, SYMBOL_BID); // ---- LONG ---- if(longEMA && rsiLong && rsiRising && longBB && inLongFibZone) { // SL method if(InpSL_Method == 2) { sl = close1 - InpFixedSL_Points * _Point; double sl_points = InpFixedSL_Points; double lots = CalcLots(sl_points); double tp_dist_points = sl_points * InpFixedTP_RR; tp = close1 + tp_dist_points * _Point; trade.Buy(lots, _Symbol, ask, sl, tp, "EMA_BB_FIB_LONG"); } else { // structure SL: below recent lowest low over lookback double recentLow = DBL_MAX; int bars = MathMin(InpFibLookbackBars, (int)Bars(_Symbol, PERIOD_M1)-2); for(int i=1;i<=bars;i++) recentLow = MathMin(recentLow, iLow(_Symbol, PERIOD_M1, i)); sl = recentLow - 5*_Point; double sl_points = (close1 - sl)/_Point; if(sl_points <= 0) return; double lots = CalcLots(sl_points); double tp = close1 + sl_points * InpFixedTP_RR * _Point; trade.Buy(lots, _Symbol, ask, sl, tp, "EMA_BB_FIB_LONG"); } } // ---- SHORT ---- if(shortEMA && rsiShort && rsiFalling && shortBB && inShortFibZone) { if(InpSL_Method == 2) { sl = close1 + InpFixedSL_Points * _Point; double sl_points = InpFixedSL_Points; double lots = CalcLots(sl_points); double tp_dist_points = sl_points * InpFixedTP_RR; tp = close1 - tp_dist_points * _Point; trade.Sell(lots, _Symbol, bid, sl, tp, "EMA_BB_FIB_SHORT"); } else { // structure SL: above recent highest high over lookback double recentHigh = -DBL_MAX; int bars = MathMin(InpFibLookbackBars, (int)Bars(_Symbol, PERIOD_M1)-2); for(int i=1;i<=bars;i++) recentHigh = MathMax(recentHigh, iHigh(_Symbol, PERIOD_M1, i)); sl = recentHigh + 5*_Point; double sl_points = (sl - close1)/_Point; if(sl_points <= 0) return; double lots = CalcLots(sl_points); double tp = close1 - sl_points * InpFixedTP_RR * _Point; trade.Sell(lots, _Symbol, bid, sl, tp, "EMA_BB_FIB_SHORT"); } } ManageTrailing(); } //-------------------- OnDeinit -------------------- void OnDeinit(const int reason) { // nothing }

Yanıtlandı

1
Geliştirici 1
Derecelendirme
(111)
Projeler
184
25%
Arabuluculuk
25
16% / 76%
Süresi dolmuş
16
9%
Serbest
2
Geliştirici 2
Derecelendirme
(1)
Projeler
2
0%
Arabuluculuk
0
Süresi dolmuş
1
50%
Çalışıyor
3
Geliştirici 3
Derecelendirme
(64)
Projeler
145
46%
Arabuluculuk
21
38% / 24%
Süresi dolmuş
32
22%
Serbest
4
Geliştirici 4
Derecelendirme
(33)
Projeler
38
21%
Arabuluculuk
5
0% / 60%
Süresi dolmuş
0
Serbest
5
Geliştirici 5
Derecelendirme
(7)
Projeler
9
67%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
Yayınlandı: 1 makale, 2 kod
6
Geliştirici 6
Derecelendirme
Projeler
0
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
7
Geliştirici 7
Derecelendirme
(631)
Projeler
709
42%
Arabuluculuk
2
100% / 0%
Süresi dolmuş
1
0%
Serbest
Yayınlandı: 9 kod
8
Geliştirici 8
Derecelendirme
Projeler
1
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
Yayınlandı: 4 kod
Benzer siparişler
Hello, I need an Expert Advisor for MetaTrader 5 in MQL5. 1. GENERAL: Scalping on M1, Monday to Friday, 3 symbols: XAUUSD, EURUSD, GBPUSD. Scan every tick. Fully automatic. NO MARTINGALE, NO GRID, NO HEDGING. 2. TIMEFRAME: M1 ONLY. Use PERIOD_M1 for all indicators. Magic 101010. Comment "Adaptive V11". Deviation 10. Spread filter: >30 points EURUSD/GBPUSD or >50 points XAUUSD = NO TRADE. 3. INDICATORS: EMA 20, EMA
CyberShadow AI 30 - 300 USD
I want a bot that’s trades using smc strategy having stop loss and take profit.I want it to be able to trade with small account I want a disciplined robot but a strong one to I also what it to trade using trend line and locate point of interest
I need an EA for MetaTrader 5 called AI Forex Robot V100. It must trade automatically on EURUSD and GBPUSD, M15 timeframe. Strategy: - Buy when fast EMA crosses above slow EMA and RSI is above 50 - Sell when fast EMA crosses below slow EMA and RSI is below 50 - Only 1 trade at a time - Stop Loss: 50 pips, Take Profit: 100 pips - Lot size: 0.01, with option to change in settings - Must have trailing stop and news
PROJECT: EXISTING MT5 EA MODIFICATION – XAUUSD SLIPPAGE REDUCTION 1. Project Objective I already have a fully developed MT5 Expert Advisor (.mq5 source code). I am looking for an experienced MQL5 developer who can optimize my existing EA to achieve the lowest possible execution slippage on a REAL LIVE trading account. My primary and only objective is to zero slippage. I am not looking for a new trading strategy or
Elektra Trading Robot 100 - 200 USD
Elektra Trading Robot is an automated Forex trading system designed to analyze market conditions execute trades according to predefined trading strategies. It aims to identify potential trading opportunities, manage trading positions, and apply risk management rules to help protect trading capital. The robot is designed for real-account trading and focuses on consistency, disciplined execution, and efficient trade
the final ea must faithfully implement the logic from the provided phython file run cleanly on mt5 and deliver solid backtest result.its shoild be very easy to set up use with clear input parameter proper risk management and no complicated installation steps
Forex Hunter MT5 30 - 250 USD
ثبت طلبك في مواصفات البوت الثاني كذا: الجودة والأمان أهم من السعر، وما يدخل إلا إذا الفرصة قوية، مع حماية عند الخسائر وانقطاع الاتصال وارتفاع السبريد، وتشغيل مستمر على سيرفر، مع اختبارات إلزامية قبل أي تشغيل حقيقي. بهذه الصيغة يصير يشتغل وأنت مرتاح بالِك، لكنه يوقف تلقائيًا وقت عطلة السوق أو أي خلل. بس أكون واضح معك: ما في بوت يضمن عدم الخسارة، خصوصًا بالمضاربات السريعة، هدفنا نقلل المخاطر ونمنع الخسائر غير المنضبطة
I'm looking for an experienced MQL5 developer to create a Opening Range Breakout EA. The EA should identify the high and low of a configurable trading session and open trades when price breaks out of this range. It should include configurable Stop Loss, Take Profit, fixed lot size, break-even option and trading hours. Full mq5 required
Matosfx 30 USD
Am called martin sselubiri I need a robot for trading forex and stock and I want know how this robot works and how much it costs for me to use it
AI Forex Trading Bot for MT4 and MT5 I need an advanced Forex trading robot (Expert Advisor) that works on both MetaTrader 4 and MetaTrader 5. The robot should automatically analyse the Forex market, identify BUY and SELL opportunities, and execute trades when the trading conditions are met. It should support GBPUSD, EURUSD, USDJPY and GBPJPY. The robot should use EMA, RSI, MACD, price action and trend analysis

Proje bilgisi

Bütçe
39+ USD

Müşteri

Verilmiş siparişler1
Arabuluculuk sayısı0