Termos de Referência
//+------------------------------------------------------------------+
//| EA: Execution & Risk Manager v1 (MT4 / MQL4) |
//| - Time window (Greece time via offset) |
//| - Max trades/day, max loss trades/day |
//| - Optional: one trade at a time |
//| - Auto SL/TP (RR), break-even, trailing |
//+------------------------------------------------------------------+
#property strict
// ---------- Inputs ----------
input int MagicNumber = 260208; // Unique ID for this EA
input double FixedLots = 0.01; // If UseFixedLots=true
input bool UseFixedLots = true;
input int MaxTradesPerDay = 4;
input int MaxLossTradesPerDay = 2;
input bool OneTradeAtATime = true;
input bool UseTradeWindow = true;
input int GR_UTC_Offset_Hours = 2; // Greece offset from UTC (Feb = 2, summer often 3)
input int TradeStartHourGR = 14; // e.g. 14:00
input int TradeStartMinuteGR = 0;
input int TradeEndHourGR = 18; // e.g. 18:30
input int TradeEndMinuteGR = 30;
input bool AutoSetSLTP = true;
input int StopLossPips = 120; // adjust per symbol volatility
input double RiskReward = 2.0; // TP = SL * RR
input bool UseBreakEven = true;
input int BreakEvenAfterPips = 80; // when profit >= this, move SL to entry(+buffer)
input int BreakEvenBufferPips = 5;
input bool UseTrailing = true;
input int TrailStartPips = 120; // start trailing after profit >= this
input int TrailDistancePips = 80; // distance from price
// ---------- Helpers ----------
double PipValue()
{
// For 5-digit / 3-digit brokers, 1 pip = 10 points
if(Digits == 3 || Digits == 5) return(Point * 10);
return(Point);
}
datetime GreeceTimeNow()
{
// Use UTC time + GR offset (manual). This avoids dependency on broker server time.
return(TimeGMT() + GR_UTC_Offset_Hours * 3600);
}
bool IsInTradeWindow()
{
if(!UseTradeWindow) return(true);
datetime grNow = GreeceTimeNow();
int h = TimeHour(grNow);
int m = TimeMinute(grNow);
int cur = h*60 + m;
int start = TradeStartHourGR*60 + TradeStartMinuteGR;
int end = TradeEndHourGR*60 + TradeEndMinuteGR;
return(cur >= start && cur <= end);
}
int TodayKeyGR()
{
datetime grNow = GreeceTimeNow();
// Unique key per day (YYYYMMDD)
return(TimeYear(grNow)*10000 + TimeMonth(grNow)*100 + TimeDay(grNow));
}
bool IsOurOrder()
{
return(OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol());
}
int CountTodayTradesClosed()
{
int key = TodayKeyGR();
int cnt = 0;
for(int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if(!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
if(OrderMagicNumber() != MagicNumber) continue;
if(OrderSymbol() != Symbol()) continue;
datetime closeT = OrderCloseTime();
// Convert close time to Greece time using same UTC logic:
// Note: History time is server-based, but close time is datetime; we approximate via GMT offset.
// For robust use, we focus on date in Greece by converting GMT.
datetime closeGR = (closeT - (TimeCurrent() - TimeGMT())) + GR_UTC_Offset_Hours*3600;
int closeKey = TimeYear(closeGR)*10000 + TimeMonth(closeGR)*100 + TimeDay(closeGR);
if(closeKey == key) cnt++;
}
return(cnt);
}
int CountTodayLossTradesClosed()
{
int key = TodayKeyGR();
int cnt = 0;
for(int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if(!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
if(OrderMagicNumber() != MagicNumber) continue;
if(OrderSymbol() != Symbol()) continue;
datetime closeT = OrderCloseTime();
datetime closeGR = (closeT - (TimeCurrent() - TimeGMT())) + GR_UTC_Offset_Hours*3600;
int closeKey = TimeYear(closeGR)*10000 + TimeMonth(closeGR)*100 + TimeDay(closeGR);
if(closeKey != key) continue;
double profit = OrderProfit() + OrderSwap() + OrderCommission();
if(profit < 0) cnt++;
}
return(cnt);
}
int CountOpenPositions()
{
int cnt = 0;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if(!IsOurOrder()) continue;
if(OrderType() == OP_BUY || OrderType() == OP_SELL) cnt++;
}
return(cnt);
}
bool CanTradeNow()
{
if(!IsInTradeWindow()) return(false);
int closedToday = CountTodayTradesClosed();
int lossToday = CountTodayLossTradesClosed();
if(closedToday >= MaxTradesPerDay) return(false);
if(lossToday >= MaxLossTradesPerDay) return(false);
if(OneTradeAtATime && CountOpenPositions() > 0) return(false);
return(true);
}
// Apply SL/TP management on existing positions
void ManageOpenTrades()
{
double pip = PipValue();
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if(!IsOurOrder()) continue;
int type = OrderType();
if(type != OP_BUY && type != OP_SELL) continue;
double entry = OrderOpenPrice();
double sl = OrderStopLoss();
double tp = OrderTakeProfit();
// 1) Auto set SL/TP if missing
if(AutoSetSLTP)
{
if(sl <= 0 || tp <= 0)
{
int slP = StopLossPips;
double newSL = 0;
double newTP = 0;
if(type == OP_BUY)
{
newSL = entry - slP * pip;
newTP = entry + (slP * RiskReward) * pip;
}
else
{
newSL = entry + slP * pip;
newTP = entry - (slP * RiskReward) * pip;
}
// Only modify if values are valid
bool ok = OrderModify(OrderTicket(), entry, newSL, newTP, 0, clrNONE);
if(!ok) Print("OrderModify SL/TP failed: ", GetLastError());
continue; // re-check next tick
}
}
// 2) Break-even
if(UseBreakEven)
{
double profitPips = 0;
if(type == OP_BUY) profitPips = (Bid - entry) / pip;
if(type == OP_SELL) profitPips = (entry - Ask) / pip;
if(profitPips >= BreakEvenAfterPips)
{
double beSL = entry;
if(type == OP_BUY) beSL = entry + BreakEvenBufferPips * pip;
if(type == OP_SELL) beSL = entry - BreakEvenBufferPips * pip;
// Move SL only in favorable direction
bool shouldMove = false;
if(type == OP_BUY && (sl < beSL)) shouldMove = true;
if(type == OP_SELL && (sl > beSL || sl == 0)) shouldMove = true;
if(shouldMove)
{
bool ok = OrderModify(OrderTicket(), entry, beSL, tp, 0, clrNONE);
if(!ok) Print("OrderModify BE failed: ", GetLastError());
}
}
}
// 3) Trailing stop (simple)
if(UseTrailing)
{
double profitPips = 0;
if(type == OP_BUY) profitPips = (Bid - entry) / pip;
if(type == OP_SELL) profitPips = (entry - Ask) / pip;
if(profitPips >= TrailStartPips)
{
double trailSL = sl;
if(type == OP_BUY)
{
double desiredSL = Bid - TrailDistancePips * pip;
if(desiredSL > sl) trailSL = desiredSL;
}
else
{
double desiredSL = Ask + TrailDistancePips * pip;
if(sl == 0 || desiredSL < sl) trailSL = desiredSL;
}
if(trailSL != sl)
{
bool ok = OrderModify(OrderTicket(), entry, trailSL, tp, 0, clrNONE);
if(!ok) Print("OrderModify Trail failed: ", GetLastError());
}
}
}
}
}
// ---------- MT4 events ----------
int OnInit()
{
Print("EA Execution & Risk Manager v1 loaded. Symbol=", Symbol(), " Magic=", MagicNumber);
return(INIT_SUCCEEDED);
}
void OnTick()
{
// Always manage existing trades
ManageOpenTrades();
// Trading permissions (for manual entries guidance)
// This EA does NOT open trades by itself in v1.
// But we can display status in Experts log:
static int lastKey = 0;
int key = TodayKeyGR();
if(key != lastKey)
{
lastKey = key;
Print("New day (GR). ClosedToday=", CountTodayTradesClosed(), " LossToday=", CountTodayLossTradesClosed());
}
// Optional: warn if user tries to trade outside limits (informational)
if(!CanTradeNow())
{
// keep quiet; you can uncomment to log periodically
// Print("Trading blocked now (window/limits).");
}
}
//| EA: Execution & Risk Manager v1 (MT4 / MQL4) |
//| - Time window (Greece time via offset) |
//| - Max trades/day, max loss trades/day |
//| - Optional: one trade at a time |
//| - Auto SL/TP (RR), break-even, trailing |
//+------------------------------------------------------------------+
#property strict
// ---------- Inputs ----------
input int MagicNumber = 260208; // Unique ID for this EA
input double FixedLots = 0.01; // If UseFixedLots=true
input bool UseFixedLots = true;
input int MaxTradesPerDay = 4;
input int MaxLossTradesPerDay = 2;
input bool OneTradeAtATime = true;
input bool UseTradeWindow = true;
input int GR_UTC_Offset_Hours = 2; // Greece offset from UTC (Feb = 2, summer often 3)
input int TradeStartHourGR = 14; // e.g. 14:00
input int TradeStartMinuteGR = 0;
input int TradeEndHourGR = 18; // e.g. 18:30
input int TradeEndMinuteGR = 30;
input bool AutoSetSLTP = true;
input int StopLossPips = 120; // adjust per symbol volatility
input double RiskReward = 2.0; // TP = SL * RR
input bool UseBreakEven = true;
input int BreakEvenAfterPips = 80; // when profit >= this, move SL to entry(+buffer)
input int BreakEvenBufferPips = 5;
input bool UseTrailing = true;
input int TrailStartPips = 120; // start trailing after profit >= this
input int TrailDistancePips = 80; // distance from price
// ---------- Helpers ----------
double PipValue()
{
// For 5-digit / 3-digit brokers, 1 pip = 10 points
if(Digits == 3 || Digits == 5) return(Point * 10);
return(Point);
}
datetime GreeceTimeNow()
{
// Use UTC time + GR offset (manual). This avoids dependency on broker server time.
return(TimeGMT() + GR_UTC_Offset_Hours * 3600);
}
bool IsInTradeWindow()
{
if(!UseTradeWindow) return(true);
datetime grNow = GreeceTimeNow();
int h = TimeHour(grNow);
int m = TimeMinute(grNow);
int cur = h*60 + m;
int start = TradeStartHourGR*60 + TradeStartMinuteGR;
int end = TradeEndHourGR*60 + TradeEndMinuteGR;
return(cur >= start && cur <= end);
}
int TodayKeyGR()
{
datetime grNow = GreeceTimeNow();
// Unique key per day (YYYYMMDD)
return(TimeYear(grNow)*10000 + TimeMonth(grNow)*100 + TimeDay(grNow));
}
bool IsOurOrder()
{
return(OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol());
}
int CountTodayTradesClosed()
{
int key = TodayKeyGR();
int cnt = 0;
for(int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if(!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
if(OrderMagicNumber() != MagicNumber) continue;
if(OrderSymbol() != Symbol()) continue;
datetime closeT = OrderCloseTime();
// Convert close time to Greece time using same UTC logic:
// Note: History time is server-based, but close time is datetime; we approximate via GMT offset.
// For robust use, we focus on date in Greece by converting GMT.
datetime closeGR = (closeT - (TimeCurrent() - TimeGMT())) + GR_UTC_Offset_Hours*3600;
int closeKey = TimeYear(closeGR)*10000 + TimeMonth(closeGR)*100 + TimeDay(closeGR);
if(closeKey == key) cnt++;
}
return(cnt);
}
int CountTodayLossTradesClosed()
{
int key = TodayKeyGR();
int cnt = 0;
for(int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if(!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
if(OrderMagicNumber() != MagicNumber) continue;
if(OrderSymbol() != Symbol()) continue;
datetime closeT = OrderCloseTime();
datetime closeGR = (closeT - (TimeCurrent() - TimeGMT())) + GR_UTC_Offset_Hours*3600;
int closeKey = TimeYear(closeGR)*10000 + TimeMonth(closeGR)*100 + TimeDay(closeGR);
if(closeKey != key) continue;
double profit = OrderProfit() + OrderSwap() + OrderCommission();
if(profit < 0) cnt++;
}
return(cnt);
}
int CountOpenPositions()
{
int cnt = 0;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if(!IsOurOrder()) continue;
if(OrderType() == OP_BUY || OrderType() == OP_SELL) cnt++;
}
return(cnt);
}
bool CanTradeNow()
{
if(!IsInTradeWindow()) return(false);
int closedToday = CountTodayTradesClosed();
int lossToday = CountTodayLossTradesClosed();
if(closedToday >= MaxTradesPerDay) return(false);
if(lossToday >= MaxLossTradesPerDay) return(false);
if(OneTradeAtATime && CountOpenPositions() > 0) return(false);
return(true);
}
// Apply SL/TP management on existing positions
void ManageOpenTrades()
{
double pip = PipValue();
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if(!IsOurOrder()) continue;
int type = OrderType();
if(type != OP_BUY && type != OP_SELL) continue;
double entry = OrderOpenPrice();
double sl = OrderStopLoss();
double tp = OrderTakeProfit();
// 1) Auto set SL/TP if missing
if(AutoSetSLTP)
{
if(sl <= 0 || tp <= 0)
{
int slP = StopLossPips;
double newSL = 0;
double newTP = 0;
if(type == OP_BUY)
{
newSL = entry - slP * pip;
newTP = entry + (slP * RiskReward) * pip;
}
else
{
newSL = entry + slP * pip;
newTP = entry - (slP * RiskReward) * pip;
}
// Only modify if values are valid
bool ok = OrderModify(OrderTicket(), entry, newSL, newTP, 0, clrNONE);
if(!ok) Print("OrderModify SL/TP failed: ", GetLastError());
continue; // re-check next tick
}
}
// 2) Break-even
if(UseBreakEven)
{
double profitPips = 0;
if(type == OP_BUY) profitPips = (Bid - entry) / pip;
if(type == OP_SELL) profitPips = (entry - Ask) / pip;
if(profitPips >= BreakEvenAfterPips)
{
double beSL = entry;
if(type == OP_BUY) beSL = entry + BreakEvenBufferPips * pip;
if(type == OP_SELL) beSL = entry - BreakEvenBufferPips * pip;
// Move SL only in favorable direction
bool shouldMove = false;
if(type == OP_BUY && (sl < beSL)) shouldMove = true;
if(type == OP_SELL && (sl > beSL || sl == 0)) shouldMove = true;
if(shouldMove)
{
bool ok = OrderModify(OrderTicket(), entry, beSL, tp, 0, clrNONE);
if(!ok) Print("OrderModify BE failed: ", GetLastError());
}
}
}
// 3) Trailing stop (simple)
if(UseTrailing)
{
double profitPips = 0;
if(type == OP_BUY) profitPips = (Bid - entry) / pip;
if(type == OP_SELL) profitPips = (entry - Ask) / pip;
if(profitPips >= TrailStartPips)
{
double trailSL = sl;
if(type == OP_BUY)
{
double desiredSL = Bid - TrailDistancePips * pip;
if(desiredSL > sl) trailSL = desiredSL;
}
else
{
double desiredSL = Ask + TrailDistancePips * pip;
if(sl == 0 || desiredSL < sl) trailSL = desiredSL;
}
if(trailSL != sl)
{
bool ok = OrderModify(OrderTicket(), entry, trailSL, tp, 0, clrNONE);
if(!ok) Print("OrderModify Trail failed: ", GetLastError());
}
}
}
}
}
// ---------- MT4 events ----------
int OnInit()
{
Print("EA Execution & Risk Manager v1 loaded. Symbol=", Symbol(), " Magic=", MagicNumber);
return(INIT_SUCCEEDED);
}
void OnTick()
{
// Always manage existing trades
ManageOpenTrades();
// Trading permissions (for manual entries guidance)
// This EA does NOT open trades by itself in v1.
// But we can display status in Experts log:
static int lastKey = 0;
int key = TodayKeyGR();
if(key != lastKey)
{
lastKey = key;
Print("New day (GR). ClosedToday=", CountTodayTradesClosed(), " LossToday=", CountTodayLossTradesClosed());
}
// Optional: warn if user tries to trade outside limits (informational)
if(!CanTradeNow())
{
// keep quiet; you can uncomment to log periodically
// Print("Trading blocked now (window/limits).");
}
}
Respondido
1
Classificação
Projetos
0
0%
Arbitragem
2
0%
/
100%
Expirado
0
Livre
2
Classificação
Projetos
19
16%
Arbitragem
3
67%
/
0%
Expirado
0
Livre
3
Classificação
Projetos
0
0%
Arbitragem
0
Expirado
0
Livre
4
Classificação
Projetos
4
0%
Arbitragem
1
0%
/
100%
Expirado
0
Livre
5
Classificação
Projetos
1
0%
Arbitragem
0
Expirado
0
Livre
6
Classificação
Projetos
0
0%
Arbitragem
0
Expirado
0
Livre
Pedidos semelhantes
i have an exper advisor in ex4 ...want to convert it to mq4 or mq5 file this is ea was created thru a programmer and received only ex4 file....that time i was new so did not know about mq4 file. of if anyone can help me to replicate this ea to mq4 or mq5
Vinh_TradeExpert
45+ USD
//+------------------------------------------------------------------+ //| Vinh_TradeCode.mq5 | //| BTC Double Bottom / Double Top EA (MT5 - MQL5) | //+------------------------------------------------------------------+ #property strict #property version "1.01" #include <Trade/Trade.mqh> CTrade trade; //==================== INPUT ==================== input long MagicNumber =
I need to create an MT5 expert advisor that enters and exits based on my custom Fibonacci levels connecting with the proper highs and lows. all details provided in the text document fyi
hello great developer I need help developing an ICT 2022 model indicator and testing it thoroughly to ensure optimal performance and accuracy. Scope of work - Create an ICT 2022 model indicator with specified features. - Conduct repeated tests and strategy tests to refine the indicator. - Implement midnight to 9:30 box high and low range settings. - Include signal settings for major liquidity and structure break with
Floating bot
30+ USD
I need someone to build an easy bot for me. Whenever the candle closes outside a particular horizonal line I will put on my mt5 chart then immediately after the candle close there will be an instant execution trade after the close of the candle and the sl will be at the current last low or high below or above for buy or sell. I will have a place where I will input the amount to be risked by one pair. For instance in
Buscamos un desarrollador experto en MQL5 (MetaTrader 5) para crear un Expert Advisor (EA) profesional , completamente autónomo, seguro y escalable, con entradas y salidas automáticas , backtesting integrado y panel de control paramétrico . El EA será de propiedad intelectual exclusiva del cliente y deberá diseñarse desde el inicio para ampliaciones futuras (nuevas estrategias, multi-par, integración con Python /
Core Requirements: Two selectable timeframes - dropdown inputs to choose from M1, M5, M15, H1, H4, D1, W1, MN1 Timeframe 1 = Chart's own timeframe (if chart is M5, TF1 should be M5) Timeframe 2 = Higher timeframe for confluence All Ichimoku components displayed for both timeframes: Tenkan-sen Kijun-sen Senkou Span A Senkou Span B Chikou Span Cloud (bullish and bearish) Technical Settings: All buffers accessible for
Need MT5 robot created
60+ USD
I need experience developer on mt5, simple strategy and basic inputs on take profit, stoploss closing candle, and average profit, average loss and lot increment and some inputs come to private I will be explain all
I have EA available for boom 900 able to make 30$ daily from 100$ . I need investors to partner together and create a substantial capital for greater gains and equitable pooling and distribution
Trade copier
80+ USD
I need a local trade copier solution to transmit trades from MT4 and MT5 to NinjaTrader 8 instantly for arbitrage purposes, with ultra-low latency and no cloud services involved. Scope of work - Develop MT4/MT5 EA or script for detecting and sending trades locally. - Create NT8 NinjaScript for listening to and executing trades. - Support market orders and lot size conversion. - Implement symbol mapping for trades. -
Informações sobre o projeto
Orçamento
30+ USD
IVA (24%):
7.2
USD
Total:
37
USD
Desenvolvedor
27
USD
Cliente
Pedidos postados1
Número de arbitragens0