Tarea técnica
//+------------------------------------------------------------------+
//| 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 = 20240226;
input double TradeMoney = 100.0; // Số tiền vào lệnh (USDT)
input double StopLossPercent = 5.0; // SL %
input double TakeProfitPercent = 5.0; // TP %
input int LookbackBars = 200; // Số nến quét
input int PivotLeft = 3;
input int PivotRight = 3;
input int MinBarsBetween = 10;
input double TolerancePercent = 0.4; // Sai lệch % cho 2 đỉnh/đáy
input bool OneTradeOnly = true;
input bool TradeOnNewBar = true;
//==================== GLOBAL ====================
datetime lastBarTime = 0;
//==================== NEW BAR ====================
bool IsNewBar()
{
datetime t = iTime(_Symbol, PERIOD_CURRENT, 0);
if(t == 0) return false;
if(t != lastBarTime)
{
lastBarTime = t;
return true;
}
return false;
}
//==================== COUNT POSITIONS (FIXED) ====================
int CountMyPositions()
{
int count = 0;
int total = PositionsTotal();
int idx = 0; // <<< khai báo tách riêng để né lỗi parser
for(idx = 0; idx < total; idx++)
{
if(!PositionSelectByIndex(idx))
continue;
string psym = PositionGetString(POSITION_SYMBOL);
long pmag = (long)PositionGetInteger(POSITION_MAGIC);
if(psym == _Symbol && pmag == MagicNumber)
count++;
}
return count;
}
//==================== LOT FROM MONEY ====================
double CalcLotFromMoney(double money)
{
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double contract = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_CONTRACT_SIZE);
double minLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
double maxLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
double step = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
if(ask <= 0) ask = SymbolInfoDouble(_Symbol, SYMBOL_BID);
if(contract <= 0) contract = 1.0;
if(step <= 0) step = 0.01;
// money ≈ lots * contract * price
double lot = money / (ask * contract);
// round down to step
lot = MathFloor(lot / step) * step;
if(lot < minLot) lot = minLot;
if(lot > maxLot) lot = maxLot;
// normalize decimals (simple)
return lot;
}
//==================== PIVOT ====================
bool IsPivotLow(MqlRates &r[], int i)
{
int k = 0;
for(k = 1; k <= PivotLeft; k++)
if(r[i].low >= r[i - k].low) return false;
for(k = 1; k <= PivotRight; k++)
if(r[i].low >= r[i + k].low) return false;
return true;
}
bool IsPivotHigh(MqlRates &r[], int i)
{
int k = 0;
for(k = 1; k <= PivotLeft; k++)
if(r[i].high <= r[i - k].high) return false;
for(k = 1; k <= PivotRight; k++)
if(r[i].high <= r[i + k].high) return false;
return true;
}
//==================== SIGNAL ====================
// return: 1 = Buy (2 đáy), -1 = Sell (2 đỉnh), 0 = none
int GetSignal(MqlRates &rates[], int total)
{
int low1 = -1, low2 = -1;
int high1 = -1, high2 = -1;
int i = 0;
for(i = PivotLeft; i < total - PivotRight; i++)
{
if(IsPivotLow(rates, i))
{
low2 = low1;
low1 = i;
}
if(IsPivotHigh(rates, i))
{
high2 = high1;
high1 = i;
}
}
// DOUBLE BOTTOM (2 đáy)
if(low1 > 0 && low2 > 0 && MathAbs(low1 - low2) >= MinBarsBetween)
{
double avg = (rates[low1].low + rates[low2].low) / 2.0;
if(avg > 0)
{
double diff = MathAbs(rates[low1].low - rates[low2].low) / avg * 100.0;
if(diff <= TolerancePercent)
return 1;
}
}
// DOUBLE TOP (2 đỉnh)
if(high1 > 0 && high2 > 0 && MathAbs(high1 - high2) >= MinBarsBetween)
{
double avg = (rates[high1].high + rates[high2].high) / 2.0;
if(avg > 0)
{
double diff = MathAbs(rates[high1].high - rates[high2].high) / avg * 100.0;
if(diff <= TolerancePercent)
return -1;
}
}
return 0;
}
//==================== OPEN TRADE ====================
void OpenTrade(int direction)
{
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
if(ask <= 0 || bid <= 0) return;
double price = (direction == 1) ? ask : bid;
double sl = 0.0, tp = 0.0;
double slp = StopLossPercent / 100.0;
double tpp = TakeProfitPercent / 100.0;
if(direction == 1)
{
sl = price * (1.0 - slp);
tp = price * (1.0 + tpp);
}
else
{
sl = price * (1.0 + slp);
tp = price * (1.0 - tpp);
}
double lot = CalcLotFromMoney(TradeMoney);
trade.SetExpertMagicNumber(MagicNumber);
trade.SetDeviationInPoints(50);
bool ok = false;
if(direction == 1)
ok = trade.Buy(lot, _Symbol, 0.0, sl, tp, "DBuy");
else
ok = trade.Sell(lot, _Symbol, 0.0, sl, tp, "DSell");
if(!ok)
Print("Trade failed. retcode=", trade.ResultRetcode(), " desc=", trade.ResultRetcodeDescription());
}
//==================== INIT ====================
int OnInit()
{
lastBarTime = iTime(_Symbol, PERIOD_CURRENT, 0);
return INIT_SUCCEEDED;
}
//==================== ONTICK ====================
void OnTick()
{
if(TradeOnNewBar)
{
if(!IsNewBar()) return;
}
if(OneTradeOnly && CountMyPositions() > 0)
return;
MqlRates rates[];
ArraySetAsSeries(rates, true);
int copied = CopyRates(_Symbol, PERIOD_CURRENT, 0, LookbackBars, rates);
if(copied < (PivotLeft + PivotRight + 20))
return;
int sig = GetSignal(rates, copied);
if(sig != 0)
OpenTrade(sig);
}
Han respondido
1
Evaluación
Proyectos
3
0%
Arbitraje
1
0%
/
100%
Caducado
0
Trabaja
2
Evaluación
Proyectos
35
23%
Arbitraje
4
0%
/
50%
Caducado
2
6%
Trabaja
3
Evaluación
Proyectos
786
63%
Arbitraje
33
27%
/
45%
Caducado
23
3%
Libre
Ha publicado: 1 ejemplo
4
Evaluación
Proyectos
39
23%
Arbitraje
15
0%
/
87%
Caducado
4
10%
Trabaja
5
Evaluación
Proyectos
471
39%
Arbitraje
102
40%
/
24%
Caducado
78
17%
Ocupado
Ha publicado: 2 ejemplos
6
Evaluación
Proyectos
128
66%
Arbitraje
10
20%
/
60%
Caducado
35
27%
Libre
7
Evaluación
Proyectos
4
25%
Arbitraje
1
0%
/
100%
Caducado
1
25%
Trabaja
Solicitudes similares
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. -
Trading Bot
50+ USD
hello great developer I want to develop a trading bot which connects with my Binance account. A bot that can work with tradingview.com where I use trading indicator which is called " TonyUX Ema scalper ". This indicator generates Buy and Sell signal. So i want a bot which can execute trade on binance when it gets a Buy/sell signal on tradingview.com ( see attached picture) Most likely you already have a similar bot
I need an MT5 Expert Advisor based on SMC (Smart Money Concepts) and SCOB pattern. Entry logic (M1 first, must work all TF): 1. Detect OB or FVG. 2. When price touches OB/FVG, wait for SCOB candle confirmation. 3. Enter at close of SCOB. Stop Loss: - SL at the high/low of SCOB candle. Take Profit (Box TP rule): - Use distance between point 1 and point 2 as a box. - TP = 2 × box size. - Same method as drawing box and
Algo Trading Rebot/ EA
30 - 100 USD
I would like someone Who can design an EA for me. I will give him the Required Details and Trading Plan How it should Work. its going to be a Simple EA System Around Moving Averages Crossover. I will Provide Him the Moving Averages Settings and How It should execute trades and Exit them
Tradingview to Ninjatrader
30+ USD
Hello. I already have a fully working TradingView indicator written in Pine Script. I am NOT asking for a new strategy or indicator to be designed. I need an experienced NinjaTrader (NinjaScript / C#) developer to replicate the same logic and behavior of my existing TradingView indicator so it works on NinjaTrader. Important points: The TradingView indicator does NOT repaint (uses confirmed bars only). This is logic
No jokers copy pasters allowed. If you're proficient in MQL5, have a proven track record with EAs apply. Commissioning the development of a high-performance Expert Advisor (EA) engineered for the MetaTrader 5 (MT5) environment. The objective is to deploy an institutional-grade automated trading system capable of systematic market analysis, precision execution, and strict risk governance within the global forex
I’m looking to acquire an existing, profitable Expert Advisor (EA) with full source code to add to our client investment portfolio. To be clear, this is not a request to develop or design a new strategy. If you already have an EA that is proven, consistent, and production-ready, I’m open to reviewing it immediately. Please apply only if you meet all the requirements below. Submissions without a proper introduction or
Sniper
30+ USD
Hello, I would like you to develop a trading robot (EA) with the following specifications: The robot should be able to target large moves, ideally 60–100 pips or more per trade. It should use high-precision “sniper” entries, focusing on high-probability setups rather than frequent trades. Once the initial trade reaches breakeven, the robot should be able to add additional positions (scale in) while maintaining strict
True
30+ USD
Hello, I would like to commission the development of a trading robot (EA) designed specifically to pass a prop firm challenge within one week, with a maximum allowable drawdown of 2%. Key requirements: Strict risk management with drawdown hard-limits Controlled lot sizing and position management Strategy focused on high-probability, low-risk entries Full compliance with prop firm rules (daily drawdown, max drawdown
Sniper EA and pattern EA
30+ USD
I want you to help me and create a sniper entry robot and with proper risk management that follow trend and when is not going to the direction it exit
Información sobre el proyecto
Presupuesto
45+ USD
Cliente
Encargos realizados1
Número de arbitrajes0