Specification
#property strict
#property version "1.00"
#include <Trade/Trade.mqh>
CTrade trade;
// ===== ROBOT SETTINGS =====
input double Lots = 0.01;
input int FastEMA = 9; // Blue line
input int SlowEMA = 21; // Red line
input int StopLossPoints = 300;
input int TakeProfitPoints = 600;
input ulong MagicNumber = 123456;
// ===== INDICATOR HANDLES =====
int blueHandle;
int redHandle;
datetime lastBar = 0;
//+------------------------------------------------------------------+
//| Start the robot |
//+------------------------------------------------------------------+
int OnInit()
{
if(Lots <= 0 || FastEMA <= 0 ||
SlowEMA <= FastEMA ||
StopLossPoints < 0 || TakeProfitPoints < 0)
{
Print("Invalid robot settings.");
return INIT_PARAMETERS_INCORRECT;
}
blueHandle = iMA(
_Symbol, _Period, FastEMA, 0,
MODE_EMA, PRICE_CLOSE
);
redHandle = iMA(
_Symbol, _Period, SlowEMA, 0,
MODE_EMA, PRICE_CLOSE
);
if(blueHandle == INVALID_HANDLE ||
redHandle == INVALID_HANDLE)
{
Print("Could not create the moving averages.");
return INIT_FAILED;
}
trade.SetExpertMagicNumber(MagicNumber);
trade.SetTypeFillingBySymbol(_Symbol);
Print("Blue and Red EMA robot started.");
return INIT_SUCCEEDED;
}
//+------------------------------------------------------------------+
//| Check whether we have a position of a particular type |
//+------------------------------------------------------------------+
bool HasPosition(ENUM_POSITION_TYPE type)
{
for(int i = PositionsTotal() - 1; i >= 0; i--)
{
ulong ticket = PositionGetTicket(i);
if(ticket == 0)
continue;
if(PositionGetString(POSITION_SYMBOL) != _Symbol)
continue;
if((ulong)PositionGetInteger(POSITION_MAGIC)
!= MagicNumber)
continue;
if((ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE)
== type)
return true;
}
return false;
}
//+------------------------------------------------------------------+
//| Close positions of a particular type |
//+------------------------------------------------------------------+
bool ClosePositions(ENUM_POSITION_TYPE type)
{
bool success = true;
for(int i = PositionsTotal() - 1; i >= 0; i--)
{
ulong ticket = PositionGetTicket(i);
if(ticket == 0)
continue;
if(PositionGetString(POSITION_SYMBOL) != _Symbol)
continue;
if((ulong)PositionGetInteger(POSITION_MAGIC)
!= MagicNumber)
continue;
if((ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE)
!= type)
continue;
if(!trade.PositionClose(ticket))
{
Print("Close failed: ",
trade.ResultRetcodeDescription());
success = false;
}
}
return success;
}
//+------------------------------------------------------------------+
//| Main trading logic |
//+------------------------------------------------------------------+
void OnTick()
{
// Run the decision once per new candle
datetime barTime = iTime(_Symbol, _Period, 0);
if(barTime == 0 || barTime == lastBar)
return;
lastBar = barTime;
// Read the last two completed candles
double blue[2];
double red[2];
if(CopyBuffer(blueHandle, 0, 1, 2, blue) != 2 ||
CopyBuffer(redHandle, 0, 1, 2, red) != 2)
{
Print("Waiting for indicator data.");
return;
}
// Array index 1 is the most recently completed candle
double blueLine = blue[1];
double redLine = red[1];
ENUM_POSITION_TYPE wanted;
ENUM_POSITION_TYPE opposite;
if(blueLine > redLine)
{
wanted = POSITION_TYPE_BUY;
opposite = POSITION_TYPE_SELL;
}
else if(redLine > blueLine)
{
wanted = POSITION_TYPE_SELL;
opposite = POSITION_TYPE_BUY;
}
else
{
return;
}
// Close the old direction before opening the new one
ClosePositions(opposite);
// Do not open a new trade if closing failed
if(HasPosition(opposite))
{
Print("Opposite position remains open.");
return;
}
// If a position in the correct direction already exists,
// keep it instead of opening another one
if(HasPosition(wanted))
return;
MqlTick tick;
if(!SymbolInfoTick(_Symbol, tick))
return;
double sl = 0.0;
double tp = 0.0;
if(wanted == POSITION_TYPE_BUY)
{
if(StopLossPoints > 0)
sl = NormalizeDouble(
tick.ask - StopLossPoints * _Point, _Digits);
if(TakeProfitPoints > 0)
tp = NormalizeDouble(
tick.ask + TakeProfitPoints * _Point, _Digits);
if(!trade.Buy(Lots, _Symbol, 0.0, sl, tp,
"Blue above red"))
{
Print("BUY failed: ",
trade.ResultRetcodeDescription());
}
else
{
Print("BUY request completed.");
}
}
else
{
if(StopLossPoints > 0)
sl = NormalizeDouble(
tick.bid + StopLossPoints * _Point, _Digits);
if(TakeProfitPoints > 0)
tp = NormalizeDouble(
tick.bid - TakeProfitPoints * _Point, _Digits);
if(!trade.Sell(Lots, _Symbol, 0.0, sl, tp,
"Red above blue"))
{
Print("SELL failed: ",
trade.ResultRetcodeDescription());
}
else
{
Print("SELL request completed.");
}
}
}
//+------------------------------------------------------------------+
//| Release the indicators when the robot stops |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
if(blueHandle != INVALID_HANDLE)
IndicatorRelease(blueHandle);
if(redHandle != INVALID_HANDLE)
IndicatorRelease(redHandle);
}
Responded
1
Rating
Projects
4
0%
Arbitration
0
Overdue
0
Free
2
Rating
Projects
519
24%
Arbitration
61
57%
/
25%
Overdue
60
12%
Loaded
3
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
Published: 4 codes
4
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
Published: 7 codes
5
Rating
Projects
1
0%
Arbitration
0
Overdue
0
Free
Published: 3 codes
6
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
7
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
Published: 4 codes
8
Rating
Projects
7
0%
Arbitration
3
0%
/
33%
Overdue
1
14%
Working
9
Rating
Projects
310
75%
Arbitration
15
67%
/
0%
Overdue
6
2%
Working
10
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
11
Rating
Projects
2
0%
Arbitration
0
Overdue
0
Working
Published: 2 codes
12
Rating
Projects
0
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: 10 codes
Similar orders
a { text-decoration: none; color: #464feb; } tr th, tr td { border: 1px solid #e6e6e6; } tr th { background-color: #f5f5f5; } Project Description I need an Expert Advisor (EA) for MetaTrader 5 (MT5) that can automatically trade Gold (XAUUSD) and major Forex pairs. The EA must analyze market conditions, open and close trades automatically, manage risk effectively, and be fully compatible with the MT5 Strategy Tester
Hi mql5 community, I am actually looking for a dev who applied to my previous job posted few days ago regarding " Need a faithful ready made hft scalper ea robot" He already reached out with an EA which I was validating its performance on my end, but unfortunately the weekend absolutely got my away from internet while have to pay attention to some physical tasks, and during those time I couldn't been able to check
I am aspiring professional trader
30 - 70 USD
I can pay you 70 USD for consultation if you have something valuable. no scam please, I am too smart to be scammed, Thank you for your patient and attention. Have a nice day for you and your family, May God bless you and your family :)
MQL5/MT5 TRADING BOT
57+ USD
Hi i'm looking for a trading bot that will trade on mt5/MQL5. The bot must be able to follow trend and works on any pair,chart and symbol. All distance measured with ATR. Trend from a higher time frame (default H1) with a moving average;UP/DOWN. Support and resistance found automatically from recent swing highs and low nothing drawn on the chart. Two kinds of trades, each can be switched on/off. S/R trades; price
EA-MT5-XAUUSD-PuPrime-Live6 +10%/m
30 - 200 USD
I am looking for an EA using MT5, trading XAUUSD on PuPrime-Live6, Standard account. LIMITATIONS No martingale, no grid. Start equity 1000 EUR. Leverate 1:500 Account in USD. PuPrime-Live6 All settings (risk, time, drawdown %, cooldown, lot size) shall be adjustable on init or backtest. VERIFICATIONS The EA needs to reach the profit goals on Actual Ticks, 100ms slippage in backtests for each month 2026. profit goal
Hi All developers, I am looking for a EA which makes minimum 1:5 risk reward ratio with buy stop and sell stop orders placed based on candle open based or candle high low based or any other strategy .... If any having please share it for TEST, After proper TESTING only I will confirm the job... Please read this and respond
I’m looking for an experienced Pine Script developer to build a custom H1 price-action indicator. Requirements: Calculate levels using H1 candles only. Use New York RTH (9:30 AM–4:00 PM), excluding extended hours. Create horizontal levels when candle direction changes; dojis break the sequence. Invalidate levels only when an H1 candle body crosses them, not wicks. Confirm levels after the RTH session closes to
MT5 Trading EA — EMA/RSI Strategy with Risk Management and Trade Protection Hello, I'm looking for an experienced MQL5 developer to build a reliable Expert Advisor for MetaTrader 5 based on a simple trend-following strategy. My main priority is not adding as many features as possible. I want a clean, dependable EA that follows the specified rules consistently in both Strategy Tester and live/demo trading. 1. Trading
To create a unique description that meets the freelance site's requirements, you can type the following: "I am looking for an experienced MQL5 developer to create a custom Forex Expert Advisor. The trading strategy should be based on a moving average crossover system, filtered by the Relative Strength Index indicator. The expert advisor needs to feature distinct strategy modules with adjustable settings for the
Mt5
35+ USD
//+------------------------------------------------------------------+ //| HedgingBasket_EA.mq5 | //| Copyright 2026, Trading Bot | //+------------------------------------------------------------------+ #property copyright "Trading Assistant" #property version "1.00" #include <Trade\Trade.mqh> CTrade trade; //--- Input parameters input group "=== Hedging Settings ===" input double InpLotSize = 0.01; // Lot Size for
Project information
Budget
30+ USD
Customer
Placed orders1
Arbitrage count0