Vinh_TradeExpert

MQL5 Uzman Danışmanlar

İş Gereklilikleri

//+------------------------------------------------------------------+
//|                         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);
}

Yanıtlandı

1
Geliştirici 1
Derecelendirme
(2)
Projeler
3
0%
Arabuluculuk
1
0% / 100%
Süresi dolmuş
0
Çalışıyor
2
Geliştirici 2
Derecelendirme
(16)
Projeler
35
23%
Arabuluculuk
4
0% / 50%
Süresi dolmuş
2
6%
Çalışıyor
3
Geliştirici 3
Derecelendirme
(517)
Projeler
786
63%
Arabuluculuk
33
27% / 45%
Süresi dolmuş
23
3%
Serbest
Yayınlandı: 1 kod
4
Geliştirici 4
Derecelendirme
(28)
Projeler
39
23%
Arabuluculuk
15
0% / 87%
Süresi dolmuş
4
10%
Çalışıyor
5
Geliştirici 5
Derecelendirme
(295)
Projeler
471
39%
Arabuluculuk
102
40% / 24%
Süresi dolmuş
78
17%
Meşgul
Yayınlandı: 2 kod
6
Geliştirici 6
Derecelendirme
(44)
Projeler
128
66%
Arabuluculuk
10
20% / 60%
Süresi dolmuş
35
27%
Serbest
7
Geliştirici 7
Derecelendirme
(3)
Projeler
4
25%
Arabuluculuk
1
0% / 100%
Süresi dolmuş
1
25%
Çalışıyor
Benzer siparişler
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
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
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

Proje bilgisi

Bütçe
45+ USD

Müşteri

Verilmiş siparişler1
Arabuluculuk sayısı0