- Home
- Skills
- Trading & Investing
- hometrader forex bot
hometrader forex bot
MQL5 Expert Advisor for MT5 featuring EMA crossovers, RSI confirmation, and ATR-based risk management.
$5
hometrader forex bot
Example session with this skill installed
Generate the MQL5 code for the HomeTrader bot on EURUSD with a 0.5% risk per trade and a 30 point spread filter.
- Read your context and instructions
- Compiled the hometrader forex bot
I have generated the HomeTrader Expert Advisor code for MetaTrader 5. This script implements the EMA crossover logic with RSI confirmation and ATR-based risk management as specified.
HomeTrader MQL5 Expert Advisor
//+------------------------------------------------------------------+
//| HomeTraderBot.mq5 |
//| Copyright 2024, HomeTrader |
//| https://mql5.com |
//+------------------------------------------------------------------+
#property copyright "HomeTrader"
#property link "https://mql5.com"
#property version "1.00"
#property strict
#include <Trade\Trade.mqh>
//--- Input Parameters
input int FastEMA = 20;
input int SlowEMA = 50;
input int RSIPeriod = 14;
input int ATRPeriod = 14;
input double ATRMultiplier = 2.0;
input double RewardRisk = 2.0;
input double RiskPercent = 0.5;
input int MaxSpreadPoints = 30;
input long MagicNumber = 20261102;
//--- Global Variables
CTrade trade;
int handleFastEMA, handleSlowEMA, handleRSI, handleATR;
int OnInit() {
handleFastEMA = iMA(_Symbol, _Period, FastEMA, 0, MODE_EMA, PRICE_CLOSE);
handleSlowEMA = iMA(_Symbol, _Period, SlowEMA, 0, MODE_EMA, PRICE_CLOSE);
handleRSI = iRSI(_Symbol, _Period, RSIPeriod, PRICE_CLOSE);
handleATR = iATR(_Symbol, _Period, ATRPeriod);
trade.SetExpertMagicNumber(MagicNumber);
return(INIT_SUCCEEDED);
}
void OnTick() {
if(PositionsTotal() > 0) return;
if(SymbolInfoInteger(_Symbol, SYMBOL_SPREAD) > MaxSpreadPoints) return;
double emaF[], emaS[], rsi[], atr[];
CopyBuffer(handleFastEMA, 0, 1, 2, emaF);
CopyBuffer(handleSlowEMA, 0, 1, 2, emaS);
CopyBuffer(handleRSI, 0, 1, 2, rsi);
CopyBuffer(handleATR, 0, 1, 1, atr);
bool buySignal = (emaF[1] > emaS[1] && emaF[0] <= emaS[0]) == false && (emaF[1] > emaS[1] && rsi[0] > 50);
bool sellSignal = (emaF[1] < emaS[1] && emaF[0] >= emaS[0]) == false && (emaF[1] < emaS[1] && rsi[0] < 50);
double slRange = atr[0] * ATRMultiplier;
double lotSize = (AccountInfoDouble(ACCOUNT_BALANCE) * RiskPercent / 100.0) / (slRange / _Point * SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE));
if(buySignal) {
double sl = SymbolInfoDouble(_Symbol, SYMBOL_ASK) - slRange;
double tp = SymbolInfoDouble(_Symbol, SYMBOL_ASK) + (slRange * RewardRisk);
trade.Buy(lotSize, _Symbol, 0, sl, tp, "HomeTrader Buy");
} else if(sellSignal) {
double sl = SymbolInfoDouble(_Symbol, SYMBOL_BID) + slRange;
double tp = SymbolInfoDouble(_Symbol, SYMBOL_BID) - (slRange * RewardRisk);
trade.Sell(lotSize, _Symbol, 0, sl, tp, "HomeTrader Sell");
}
}
Next steps
- Open MetaEditor in MT5, create a new Expert Advisor named
HomeTrader, and paste the code above. - Press F7 to compile and check the Errors tab for a successful build.
- Open the Strategy Tester (Ctrl+R) and run a backtest on M15 using "Every tick based on real ticks" to verify performance.
Connects securely to your tools. The creator never sees your data.
About this skill
Writing MQL5 Expert Advisors from scratch is error-prone, especially when managing technical indicator alignment and risk-based position sizing. This skill provides a complete MetaTrader 5 (MT5) trading bot implementation based on the HomeTrader strategy, handling the boilerplate and logic for automated forex execution.
What it does
- Signal logic executes trades based on EMA 20/50 crossovers confirmed by RSI 50 levels.
- Dynamic risk management calculates position sizes using a fixed 0.5% balance risk per trade.
- Volatility-based stops utilizes ATR (Average True Range) to set Stop Loss and Take Profit levels relative to market movement.
- Operational filters prevents entry during high-volatility spikes using a 30-point spread limit.
- Trade management enforces a one-position-at-a-time rule to prevent over-exposure.
How it works
- Source the template by requesting the HomeTrader MQL5 code block for a specific pair like EURUSD.
- Compile the code in the MetaEditor (F7) after placing the file in the MQL5/Experts folder.
- Configure inputs such as
RiskPercent,MagicNumber, andMaxSpreadPointsvia the MT5 terminal interface. - Run backtests using the Strategy Tester (Ctrl+R) to validate the Profit Factor and Drawdown before deployment.
Frameworks & tools
The skill generates pure MQL5 code designed for the MetaTrader 5 platform. It relies on standard library includes for trade execution and technical indicator buffers.
Why this beats prompting it yourself
Writing trading logic manually often leads to "off-by-one" errors in bar indexing or incorrect lot size calculations that can wipe accounts. This skill uses a pre-defined logic structure that ensures signals only trigger on closed bars and risk is strictly enforced at the code level.
Use cases
- Automate trend-following strategies on M15 or H1 timeframes.
- Backtest EMA/RSI crossover efficacy over historical tick data.
- Enforce strict 1:2 Risk/Reward ratios across multiple forex pairs.
- Implement automated spread filtering to avoid slippage in illiquid markets.
Known limitations
This skill is designed for education and demo backtesting only. It is restricted to the specific HomeTrader strategy parameters and requires manual compilation in MetaEditor.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 12 days ago
- Accounts
- Forex broker account (Demo recommended)
- Software
- MetaTrader 5Windows PCorWindows VPS
- Optional
- EURUSD, GBPUSD, USDJPY charts on M15orH1MQL5 / MetaEditor (to edit settings)
Install on MT5: File Open Data Folder MQL5 Experts paste HomeTrader EA, then attach to EURUSD M15 chart. Backtest on demo first. Risk is set to 0.5% per trade. For education only, not financial advice.
Permissions
File Scopes
Only reads SKILL.md to follow the EMA + RSI strategy. Does not access personal files, passwords, or broker login.
What's inside
Frequently Asked Questions
New in Trading & Investing
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Trading & Investing.