Specification
//+------------------------------------------------------------------+
//| XAUUSD Automated Forex Robot |
//| Enhanced Version with Error Handling and Improvements |
//+------------------------------------------------------------------+
input int FastMA = 10; // Fast moving average period
input int SlowMA = 50; // Slow moving average period
input int RSI_Period = 14; // RSI period
input double Overbought = 70; // RSI overbought level
input double Oversold = 30; // RSI oversold level
input double RiskPercent = 1.0; // Risk per trade as a percentage of account equity
input double ATRMultiplier = 2.0; // ATR multiplier for stop-loss
input double TrailingStop = 300; // Trailing stop in points
input double MinLotSize = 0.01; // Minimum lot size
input double LotStep = 0.01; // Lot size increment
input int ATR_Period = 14; // ATR period
input int MaxSlippage = 3; // Maximum slippage in points
input int MAGIC_NUMBER = 123456; // Unique identifier for trades
input string TradeComment = "XAUUSD Bot"; // Trade comment
//+------------------------------------------------------------------+
//| OnTick Function - Main Logic |
//+------------------------------------------------------------------+
void OnTick() {
// Calculate indicators
static double fastMA, slowMA, rsi, atr;
fastMA = iMA(NULL, 0, FastMA, 0, MODE_EMA, PRICE_CLOSE, 0);
slowMA = iMA(NULL, 0, SlowMA, 0, MODE_EMA, PRICE_CLOSE, 0);
rsi = iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, 0);
atr = iATR(NULL, 0, ATR_Period, 0);
// Check for existing trades
bool buyOpen = IsTradeOpen(OP_BUY);
bool sellOpen = IsTradeOpen(OP_SELL);
// Entry logic
if (fastMA > slowMA && rsi > Oversold && rsi < 50 && !buyOpen) {
// Buy Signal
double sl = Bid - ATRMultiplier * atr;
double tp = Bid + ATRMultiplier * atr * 2;
double lotSize = CalculateLotSize(sl);
OpenTrade(OP_BUY, lotSize, sl, tp);
}
if (fastMA < slowMA && rsi < Overbought && rsi > 50 && !sellOpen) {
// Sell Signal
double sl = Ask + ATRMultiplier * atr;
double tp = Ask - ATRMultiplier * atr * 2;
double lotSize = CalculateLotSize(sl);
OpenTrade(OP_SELL, lotSize, sl, tp);
}
// Exit logic (Close trades when conditions reverse)
if (buyOpen && (fastMA < slowMA || rsi >= Overbought)) {
CloseTrade(OP_BUY);
}
if (sellOpen && (fastMA > slowMA || rsi <= Oversold)) {
CloseTrade(OP_SELL);
}
// Manage Trailing Stop
ManageTrailingStop();
}
//+------------------------------------------------------------------+
//| Calculate Lot Size Based on Risk |
//+------------------------------------------------------------------+
double CalculateLotSize(double stopLossPrice) {
double accountEquity = AccountEquity();
double riskAmount = (RiskPercent / 100) * accountEquity;
double stopLossDistance = MathAbs(Bid - stopLossPrice);
double lotSize = riskAmount / (stopLossDistance * MarketInfo(Symbol(), MODE_TICKVALUE));
// Adjust lot size to broker limits
lotSize = MathMax(lotSize, MinLotSize);
lotSize = NormalizeDouble(MathFloor(lotSize / LotStep) * LotStep, 2);
return lotSize;
}
//+------------------------------------------------------------------+
//| Open Trade Function |
//+------------------------------------------------------------------+
void OpenTrade(int tradeType, double lotSize, double stopLoss, double takeProfit) {
double price = tradeType == OP_BUY ? Ask : Bid;
int ticket = OrderSend(Symbol(), tradeType, lotSize, price, MaxSlippage, stopLoss, takeProfit, TradeComment, MAGIC_NUMBER, 0, Blue);
if (ticket < 0) {
int errorCode = GetLastError();
Print("Error opening trade: ", errorCode, ". Retrying...");
Sleep(1000); // Retry after 1 second
ticket = OrderSend(Symbol(), tradeType, lotSize, price, MaxSlippage, stopLoss, takeProfit, TradeComment, MAGIC_NUMBER, 0, Blue);
if (ticket < 0) {
Print("Failed to open trade after retry. Error: ", GetLastError());
}
} else {
Print("Trade opened: ", ticket);
}
}
//+------------------------------------------------------------------+
//| Close Trade Function |
//+------------------------------------------------------------------+
void CloseTrade(int tradeType) {
for (int i = OrdersTotal() - 1; i >= 0; i--) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Symbol() && OrderType() == tradeType && OrderMagicNumber() == MAGIC_NUMBER) {
int ticket = OrderClose(OrderTicket(), OrderLots(), tradeType == OP_BUY ? Bid : Ask, MaxSlippage, Red);
if (ticket < 0) {
Print("Error closing trade: ", GetLastError());
} else {
Print("Trade closed: ", ticket);
}
}
}
}
}
//+------------------------------------------------------------------+
//| Manage Trailing Stop Function |
//+------------------------------------------------------------------+
void ManageTrailingStop() {
for (int i = OrdersTotal() - 1; i >= 0; i--) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC_NUMBER) {
double newStopLoss;
if (OrderType() == OP_BUY) {
newStopLoss = Bid - TrailingStop * Point;
if (newStopLoss > OrderStopLoss()) {
OrderModify(OrderTicket(), OrderOpenPrice(), newStopLoss, OrderTakeProfit(), 0, Blue);
}
} else if (OrderType() == OP_SELL) {
newStopLoss = Ask + TrailingStop * Point;
if (newStopLoss < OrderStopLoss()) {
OrderModify(OrderTicket(), OrderOpenPrice(), newStopLoss, OrderTakeProfit(), 0, Blue);
}
}
}
}
}
}
//+------------------------------------------------------------------+
//| Check if Trade Exists |
//+------------------------------------------------------------------+
bool IsTradeOpen(int tradeType) {
for (int i = OrdersTotal() - 1; i >= 0; i--) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Symbol() && OrderType() == tradeType && OrderMagicNumber() == MAGIC_NUMBER) {
return true;
}
}
}
return false;
}
Responded
1
Rating
Projects
188
57%
Arbitration
10
80%
/
0%
Overdue
0
Free
Published: 1 code
2
Rating
Projects
298
28%
Arbitration
33
24%
/
61%
Overdue
9
3%
Loaded
3
Rating
Projects
38
21%
Arbitration
5
0%
/
60%
Overdue
0
Free
4
Rating
Projects
498
19%
Arbitration
33
42%
/
30%
Overdue
32
6%
Loaded
5
Rating
Projects
20
10%
Arbitration
4
50%
/
50%
Overdue
5
25%
Free
6
Rating
Projects
621
53%
Arbitration
29
55%
/
24%
Overdue
6
1%
Loaded
7
Rating
Projects
8
13%
Arbitration
3
0%
/
33%
Overdue
2
25%
Free
Published: 1 code
8
Rating
Projects
13
23%
Arbitration
7
0%
/
71%
Overdue
3
23%
Working
9
Rating
Projects
105
60%
Arbitration
0
Overdue
0
Free
10
Rating
Projects
6
17%
Arbitration
0
Overdue
3
50%
Free
11
Rating
Projects
2
0%
Arbitration
5
0%
/
80%
Overdue
1
50%
Free
12
Rating
Projects
134
66%
Arbitration
36
25%
/
56%
Overdue
22
16%
Free
Published: 10 codes
13
Rating
Projects
483
75%
Arbitration
5
80%
/
0%
Overdue
0
Working
14
Rating
Projects
157
21%
Arbitration
23
9%
/
78%
Overdue
16
10%
Working
15
Rating
Projects
619
33%
Arbitration
35
37%
/
49%
Overdue
11
2%
Busy
16
Rating
Projects
1
0%
Arbitration
1
0%
/
100%
Overdue
0
Free
17
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
Published: 1 code
18
Rating
Projects
81
43%
Arbitration
27
11%
/
70%
Overdue
8
10%
Free
19
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Working
Similar orders
Job Title MT5 Developer Needed – Sync Data Feed Between Two MT5 Accounts Job Description I am a trader using multiple MT5 accounts and need a reliable way to have the same market data from one MT5 account reflected in another MT5 account. One account already has a stable and accurate data feed, and I want the second MT5 account to receive identical pricing and symbols for analysis and execution purposes. What I Need
im looking for a skilled coder who can modify my existing EA and indicator. I want a signal created when my custome indicators,( a channel and a few fiilters)align at certain conditions. The EA entry options are good as they are once a signal is produced, The main job is mainly on a differnt signal to be produced under different condttions, and an indicator which just draws an arrow along with channel for backtesting
Hello, I have a very simple TradingView (Pine Script) indicator that I want to be converted and implemented in ATAS . The logic is straightforward, with no complex calculations or strategy execution. I will provide the TradingView script and full explanation of how it works . What I Need: Convert the existing TradingView script logic to ATAS Ensure the indicator behaves the same way as on TradingView Clean
Ninjatrader 8 bot
200+ USD
hello great developer We are looking for someone to create a Ninja Trader bot that can identify liquidity sweeps using lux algos indicator. once liquidity sweep occurs we need the bot to use the fibonnachi tool to idenfity the 61% level and 71% level. then enter the trade for us please check the video for better understanding Here is first video: https://youtu.be/ZaGZGNgzZlc?si=we3poeWB91nWqkz5 Here is Second video
I already have a preliminary economic calendar panel. I need to optimize it to add trading functions and UI elements. What I'm looking for is an interactive control panel for trading
Beschreibung: Ich suche einen erfahrenen MQL5-Entwickler, der meinen bestehenden Expert Advisor für MT5 fertigstellt und optimiert. Der EA basiert auf einer 30-Minuten-Breakout-Strategie für XAUUSD (Gold) und enthält bereits die Grundlogik sowie FTMO-Regeln (Tagesverlust, Gesamtverlust, Handelszeiten, Spread-Filter, Lotbegrenzung). Was gemacht werden muss: Code-Feinschliff und Debugging Überprüfung der Breakout-Logik
Greeting Im in need of a programmer that can help me convert from TOS to trading view? The script is available with me, kindly bid if it is what you can do for me Thanks
I need an MT4 Expert Advisor based on my existing manual trading system. PLATFORM: - MetaTrader 4 (MT4 only) TIMEFRAMES: - Main version: M30 entries with H1 structure - Second mode: M5 entries with M30 structure - Both modes should be inside ONE EA (switch by input) INDICATORS (already available on my chart as external indicators): 1) SuperTrend - ATR period: 10 - Multiplier: 1.7 2) XXSS Candle - Same settings
Atm strategy nt8
30+ USD
can you help me with I need an ATM strategy for NT8, here's the criteria: Forex trade entry 100,000 units with a starting SL of 70 pips. The following proft targets: 33 pips, 68, 125, 180. All targets exit 25,000 units each. As each target is hit, move SL to BE+5, then BE+35, then BE+70. So the SL's are fixed, not trailing. I can't figure this out on my platform
I need a robot advisory based on AOX signals. It must be the main criteria for opening and closing. The price should be higher than the previous bar Trades
Project information
Budget
100+ USD