//+------------------------------------------------------------------+
//| MyFirstEA.mq5 |
//+------------------------------------------------------------------+
#property copyright "Me"
#property version "1.00"
#property strict
#include <Trade\Trade.mqh>
//--- Inputs
input double InpLots = 0.10; // Lot size
input int InpFastMA = 10; // Fast MA period
input int InpSlowMA = 30; // Slow MA period
input int InpStopLoss = 300; // Stop loss (points)
input int InpTakeProfit = 600; // Take profit (points)
input int InpMagic = 12345; // Magic number (identifies this EA's trades)
CTrade trade;
int hFast, hSlow;
datetime lastBarTime = 0;
//+------------------------------------------------------------------+
int OnInit()
{
trade.SetExpertMagicNumber(InpMagic);
hFast = iMA(_Symbol, PERIOD_CURRENT, InpFastMA, 0, MODE_EMA, PRICE_CLOSE);
hSlow = iMA(_Symbol, PERIOD_CURRENT, InpSlowMA, 0, MODE_EMA, PRICE_CLOSE);
if(hFast == INVALID_HANDLE || hSlow == INVALID_HANDLE)
{
Print("Failed to create MA handles");
return(INIT_FAILED);
}
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
if(hFast != INVALID_HANDLE) IndicatorRelease(hFast);
if(hSlow != INVALID_HANDLE) IndicatorRelease(hSlow);
}
//+------------------------------------------------------------------+
//| Returns true if we already have an open position for this EA |
//+------------------------------------------------------------------+
bool HasOpenPosition()
{
for(int i = PositionsTotal() - 1; i >= 0; i--)
{
ulong ticket = PositionGetTicket(i);
if(ticket == 0) continue;
if(PositionGetString(POSITION_SYMBOL) == _Symbol &&
PositionGetInteger(POSITION_MAGIC) == InpMagic)
return(true);
}
return(false);
}
//+------------------------------------------------------------------+
void OnTick()
{
// Only act once per bar — avoids spamming trades on every tick
datetime currentBar = iTime(_Symbol, PERIOD_CURRENT, 0);
if(currentBar == lastBarTime) return;
lastBarTime = currentBar;
// Read the two most recent completed values of each MA
double fast[3], slow[3];
if(CopyBuffer(hFast, 0, 0, 3, fast) < 3) return;
if(CopyBuffer(hSlow, 0, 0, 3, slow) < 3) return;
double point = _Point;
int digits = (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS);
// Crossover using bar 1 (last closed) vs bar 2 (the one before)
bool crossUp = (fast[2] < slow[2] && fast[1] > slow[1]);
bool crossDown = (fast[2] > slow[2] && fast[1] < slow[1]);
if(HasOpenPosition()) return;
if(crossUp)
{
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double sl = NormalizeDouble(ask - InpStopLoss * point, digits);
double tp = NormalizeDouble(ask + InpTakeProfit * point, digits);
trade.Buy(InpLots, _Symbol, ask, sl, tp, "EA long");
}
else if(crossDown)
{
double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
double sl = NormalizeDouble(bid + InpStopLoss * point, digits);
double tp = NormalizeDouble(bid - InpTakeProfit * point, digits);
trade.Sell(InpLots, _Symbol, bid, sl, tp, "EA short");
}
}
Pedidos semelhantes
Hello, looking for a profitable long term bot to use on real live capital. No martingale allowed. Willing to also give % base ofnprofits for performing fees. Backtest is a must with real ticks
I NEED A PROFITABLE FOREX /FUTURES TRADING ROBOT. A VERY SIMPLE PROFITABLE TRADING ROBOT WITH 3 TECHNICAL CHECKS [AN MQL5 FOREX/FUTURES BOT] . THAT I CAN BOTH USED ON MY PRIVATE LIVE ACCOUNT AND PROP FIRM CHALLENGE ACCOUNT. THE STRATEGIES / LOGIC AND THE ALGORITHM CAN BE ANY PRICE ACTION BOT, IT CAN ANY PRICE ACTION COMBINED WITH ANY INDICATOR TO FILTER THE TREND OR TO GIVE ME THE TREND. THESE ARE MUST HALF
Seeking an Established and Profitable Gold Scalping System – MT5 I am a serious buyer looking to acquire an existing, fully operational Expert Advisor specifically designed for scalping XAUUSD (Gold) on MetaTrader 5. I am particularly interested in experienced developers and quantitative traders who have developed successful proprietary trading systems, including systems that are not publicly available on the MQL5
I am looking for the original developer from Egypt who sent me the MJ v3.01 Gold EA (mj.ex5) on December 2, 2026, with a 10-day demo trial. You were Developer #28 in my previous Freelance job and offered the EA for $200. Unfortunately, I lost access to our previous conversation and would like to reconnect with you. I am still interested in your EA and would like to complete the testing, discuss the settings, and
Build an MT5 Expert Advisor using MQL5. I want an automated trading bot for Exness MT5. Markets: XAUUSD (Gold) BTCUSD (Bitcoin), subject to the broker's actual symbol name. Trading strategy: H1 timeframe for trend direction. M15 timeframe for trade entries. EMA 20 and EMA 50 for trend identification. Only buy when the confirmed trend is bullish. Only sell when the confirmed trend is bearish. Use candle-close
create money on forex ensuring nothing but profit basically also crypto an d ensure you use every means possible to ensure in turn a profit is made that what i want i want perfection
If you already have a working gold order-flow EA that matches the logic described here, I'm open to buying or licensing it instead of a custom build. Please provide: A demo version that I can run in the MT5 Strategy Tester (for example, a time-limited or demo-account-only build) A clear explanation of the trading logic: what triggers an entry, how the stop loss and take profit are set, and which order-flow or
I'm looking to purchase an already-developed, profitable trading bot specifically for Deriv. I'm not interested in building a new one from scratch. The bot must have a test version that I can try out, as well as verifiable historical live trading results demonstrating its profitability. I'm only interested in proven bots with a track record of real-market performance
I am looking to purchase an existing, fully developed and operational XAUUSD scalping Expert Advisor (EA) for MetaTrader 5. IMPORTANT: I am NOT looking for new development, custom programming, or an experimental strategy. I am only interested in an existing, ready-made and proven trading system. Requirements: Fully automated XAUUSD scalping EA for MT5. Short-duration trades with an active trading frequency. Hard Stop
The idea of the trading system is as follows : market entries are performed when MACD's main and signal lines intersect in the current trend direction . 2. Trend is determined based on the Exponential Moving Average with the specified period (InpMATrendPeriod). If the current EMA value is greater than the previous one, the trend is seen as growing (ema_current > ema_previous). Alternatively, if current EMA is