Gold liquidity expert

MQL5 EA Forex

명시

#property strict
#property version "1.00"
#property description "XAUUSD Liquidity Sweep + Fibonacci Extension EA"

#include <Trade/Trade.mqh>

CTrade trade;

//==================== INPUT SETTINGS ====================

input group "01. Strategy"
input ENUM_TIMEFRAMES SignalTimeframe = PERIOD_CURRENT;
input double SL_Buffer_Points = 20;
input ulong MagicNumber = 20261122;

input group "02. Fibonacci Extension"
input double TP1_Fib_Level = 3.0;
input double TP2_Fib_Level = 6.0;

input group "03. Position Sizing"
input double FixedLot = 0.01;
input double RiskPercent = 0.0; // 0 = Fixed Lot
input double PartialClosePercent = 50.0;

input group "04. Risk Management"
input int MaxOpenTrades = 1;
input double MaxDailyLoss = 0.0; // Account currency, 0 = disabled
input int MaxSpreadPoints = 100;
input int SlippagePoints = 30;

input group "05. Trade Settings"
input bool EnableBuy = true;
input bool EnableSell = true;

//==================== GLOBALS ====================

datetime lastBarTime = 0;
string gvPrefix = "GLS_EA_";

//==================== UTILITIES ====================

double NormalizePrice(double price)
{
   int digits = (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS);
   return NormalizeDouble(price, digits);
}

double NormalizeVolume(double volume)
{
   double minVol = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
   double maxVol = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
   double step = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);

   if(step <= 0) return 0;

   volume = MathMin(volume, maxVol);
   volume = MathFloor(volume / step + 1e-8) * step;

   if(volume < minVol) return 0;

   return NormalizeDouble(volume, 8);
}

bool IsNewBar()
{
   datetime current = iTime(_Symbol, SignalTimeframe, 0);

   if(current == 0 || current == lastBarTime)
      return false;

   lastBarTime = current;
   return true;
}

bool HasOpenPosition()
{
   for(int i = PositionsTotal() - 1; i >= 0; i--)
   {
      ulong ticket = PositionGetTicket(i);
      if(ticket == 0) continue;

      if(PositionGetString(POSITION_SYMBOL) == _Symbol &&
         (ulong)PositionGetInteger(POSITION_MAGIC) == MagicNumber)
         return true;
   }

   return false;
}

int CountOpenPositions()
{
   int count = 0;

   for(int i = PositionsTotal() - 1; i >= 0; i--)
   {
      ulong ticket = PositionGetTicket(i);
      if(ticket == 0) continue;

      if(PositionGetString(POSITION_SYMBOL) == _Symbol &&
         (ulong)PositionGetInteger(POSITION_MAGIC) == MagicNumber)
         count++;
   }

   return count;
}

bool DailyLossLimitReached()
{
   if(MaxDailyLoss <= 0)
      return false;

   MqlDateTime dt;
   TimeToStruct(TimeCurrent(), dt);

   dt.hour = 0;
   dt.min = 0;
   dt.sec = 0;

   datetime dayStart = StructToTime(dt);

   if(!HistorySelect(dayStart, TimeCurrent()))
      return false;

   double dailyProfit = 0;

   for(int i = 0; i < HistoryDealsTotal(); i++)
   {
      ulong deal = HistoryDealGetTicket(i);
      if(deal == 0) continue;

      if((ulong)HistoryDealGetInteger(deal, DEAL_MAGIC) != MagicNumber)
         continue;

      if(HistoryDealGetString(deal, DEAL_SYMBOL) != _Symbol)
         continue;

      dailyProfit += HistoryDealGetDouble(deal, DEAL_PROFIT);
      dailyProfit += HistoryDealGetDouble(deal, DEAL_SWAP);
      dailyProfit += HistoryDealGetDouble(deal, DEAL_COMMISSION);
   }

   return (dailyProfit <= -MaxDailyLoss);
}

double GetLotSize(ENUM_ORDER_TYPE orderType,
                  double entry, double stopLoss)
{
   if(RiskPercent <= 0)
      return NormalizeVolume(FixedLot);

   double riskMoney =
      AccountInfoDouble(ACCOUNT_BALANCE) * RiskPercent / 100.0;

   double profitForOneLot = 0;

   if(!OrderCalcProfit(orderType, _Symbol, 1.0,
                       entry, stopLoss, profitForOneLot))
      return 0;

   double lossPerLot = MathAbs(profitForOneLot);

   if(lossPerLot <= 0)
      return 0;

   return NormalizeVolume(riskMoney / lossPerLot);
}

bool SpreadIsValid()
{
   MqlTick tick;

   if(!SymbolInfoTick(_Symbol, tick))
      return false;

   double spread =
      (tick.ask - tick.bid) / SymbolInfoDouble(_Symbol, SYMBOL_POINT);

   return spread <= MaxSpreadPoints;
}

ENUM_ORDER_TYPE_FILLING GetFillingMode()
{
   long filling = SymbolInfoInteger(_Symbol, SYMBOL_FILLING_MODE);

   if((filling & SYMBOL_FILLING_FOK) != 0)
      return ORDER_FILLING_FOK;

   if((filling & SYMBOL_FILLING_IOC) != 0)
      return ORDER_FILLING_IOC;

   return ORDER_FILLING_RETURN;
}

//==================== LIQUIDITY SWEEP ====================

void CheckLiquiditySweep()
{
   if(!SpreadIsValid()) return;
   if(DailyLossLimitReached()) return;
   if(CountOpenPositions() >= MaxOpenTrades) return;

   MqlRates rates[];
   ArraySetAsSeries(rates, true);

   if(CopyRates(_Symbol, SignalTimeframe, 0, 3, rates) < 3)
      return;

   // rates[1] = completed sweep candle
   // rates[2] = previous reference candle

   double sweepHigh = rates[1].high;
   double sweepLow  = rates[1].low;

   double prevHigh = rates[2].high;
   double prevLow  = rates[2].low;

   double sweepClose = rates[1].close;

   // Bullish: sweep below previous low and close back inside
   bool bullishSweep =
      (sweepLow < prevLow &&
       sweepClose > prevLow &&
       sweepClose <= prevHigh);

   // Bearish: sweep above previous high and close back inside
   bool bearishSweep =
      (sweepHigh > prevHigh &&
       sweepClose < prevHigh &&
       sweepClose >= prevLow);

   // Ignore ambiguous candles sweeping both sides
   if(bullishSweep == bearishSweep)
      return;

   if(bullishSweep && EnableBuy)
      ExecuteTrade(true, sweepHigh, sweepLow);

   if(bearishSweep && EnableSell)
      ExecuteTrade(false, sweepHigh, sweepLow);
}

//==================== TRADE EXECUTION ====================

void ExecuteTrade(bool isBuy,
                  double sweepHigh,
                  double sweepLow)
{
   MqlTick tick;

   if(!SymbolInfoTick(_Symbol, tick))
      return;

   double range = sweepHigh - sweepLow;

   if(range <= 0)
      return;

   double entry = isBuy ? tick.ask : tick.bid;

   double sl, tp1, tp2;

   if(isBuy)
   {
      sl  = sweepLow - SL_Buffer_Points *
            SymbolInfoDouble(_Symbol, SYMBOL_POINT);

      tp1 = sweepLow + range * TP1_Fib_Level;
      tp2 = sweepLow + range * TP2_Fib_Level;
   }
   else
   {
      sl  = sweepHigh + SL_Buffer_Points *
            SymbolInfoDouble(_Symbol, SYMBOL_POINT);

      tp1 = sweepHigh - range * TP1_Fib_Level;
      tp2 = sweepHigh - range * TP2_Fib_Level;
   }

   sl  = NormalizePrice(sl);
   tp1 = NormalizePrice(tp1);
   tp2 = NormalizePrice(tp2);

   // Validate target direction
   if(isBuy && (sl >= entry || tp1 <= entry || tp2 <= tp1))
      return;

   if(!isBuy && (sl <= entry || tp1 >= entry || tp2 >= tp1))
      return;

   // Broker minimum stop distance
   double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
   long stopsLevel = SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL);
   double minDistance = stopsLevel * point;

   if(MathAbs(entry - sl) < minDistance ||
      MathAbs(tp2 - entry) < minDistance)
   {
      Print("Trade rejected: Broker stop distance restriction.");
      return;
   }

   ENUM_ORDER_TYPE orderType =
      isBuy ? ORDER_TYPE_BUY : ORDER_TYPE_SELL;

   double lot = GetLotSize(orderType, entry, sl);

   if(lot <= 0)
   {
      Print("Invalid lot size.");
      return;
   }

   trade.SetExpertMagicNumber(MagicNumber);
   trade.SetDeviationInPoints(SlippagePoints);
   trade.SetTypeFillingBySymbol(_Symbol);

   bool result = false;

   if(isBuy)
      result = trade.Buy(lot, _Symbol, 0, sl, tp2,
                         "Bullish Liquidity Sweep");
   else
      result = trade.Sell(lot, _Symbol, 0, sl, tp2,
                          "Bearish Liquidity Sweep");

   if(!result)
   {
      Print("Order failed: ", trade.ResultRetcode(),
            " ", trade.ResultRetcodeDescription());
      return;
   }

   // Save TP1 against the position identifier
   for(int i = PositionsTotal() - 1; i >= 0; i--)
   {
      ulong ticket = PositionGetTicket(i);
      if(ticket == 0) continue;

      if(PositionGetString(POSITION_SYMBOL) != _Symbol ||
         (ulong)PositionGetInteger(POSITION_MAGIC) != MagicNumber)
         continue;

      long identifier = PositionGetInteger(POSITION_IDENTIFIER);

      string key = gvPrefix + (string)identifier;

      GlobalVariableSet(key + "_TP1", tp1);
      GlobalVariableSet(key + "_DONE", 0);

      Print("Trade opened. Entry: ", entry,
            " SL: ", sl, " TP1: ", tp1, " TP2: ", tp2);

      break;
   }
}

//==================== PARTIAL CLOSE ====================

bool ClosePartial(ulong ticket, double volume)
{
   if(!PositionSelectByTicket(ticket))
      return false;

   ENUM_POSITION_TYPE positionType =
      (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);

   double remaining =
      PositionGetDouble(POSITION_VOLUME) - volume;

   double minVol = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);

   // If broker cannot support a valid remaining position,
   // close the entire position at TP1.
   if(remaining < minVol - 1e-8)
      return trade.PositionClose(ticket);

   MqlTick tick;
   if(!SymbolInfoTick(_Symbol, tick))
      return false;

   MqlTradeRequest request = {};
   MqlTradeResult result = {};

   request.action = TRADE_ACTION_DEAL;
   request.position = ticket;
   request.symbol = _Symbol;
   request.volume = volume;
   request.magic = MagicNumber;
   request.deviation = SlippagePoints;
   request.type_filling = GetFillingMode();

   if(positionType == POSITION_TYPE_BUY)
   {
      request.type = ORDER_TYPE_SELL;
      request.price = tick.bid;
   }
   else
   {
      request.type = ORDER_TYPE_BUY;
      request.price = tick.ask;
   }

   bool sent = OrderSend(request, result);

   if(!sent ||
      (result.retcode != TRADE_RETCODE_DONE &&
       result.retcode != TRADE_RETCODE_DONE_PARTIAL))
   {
      Print("Partial close failed: ", result.retcode);
      return false;
   }

   return true;
}

//==================== POSITION MANAGEMENT ====================

void ManagePositions()
{
   for(int i = PositionsTotal() - 1; i >= 0; i--)
   {
      ulong ticket = PositionGetTicket(i);

      if(ticket == 0) continue;

      if(PositionGetString(POSITION_SYMBOL) != _Symbol ||
         (ulong)PositionGetInteger(POSITION_MAGIC) != MagicNumber)
         continue;

      long identifier = PositionGetInteger(POSITION_IDENTIFIER);

      string key = gvPrefix + (string)identifier;

      if(!GlobalVariableCheck(key + "_TP1"))
         continue;

      double tp1 = GlobalVariableGet(key + "_TP1");
      double done = GlobalVariableGet(key + "_DONE");

      if(done >= 1)
         continue;

      ENUM_POSITION_TYPE type =
         (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);

      double currentVolume =
         PositionGetDouble(POSITION_VOLUME);

      MqlTick tick;
      if(!SymbolInfoTick(_Symbol, tick))
         continue;

      bool tp1Reached = false;

      if(type == POSITION_TYPE_BUY && tick.bid >= tp1)
         tp1Reached = true;

      if(type == POSITION_TYPE_SELL && tick.ask <= tp1)
         tp1Reached = true;

      if(!tp1Reached)
         continue;

      double closeVolume = NormalizeVolume(
         currentVolume * PartialClosePercent / 100.0
      );

      if(closeVolume <= 0)
         closeVolume = currentVolume;

      if(ClosePartial(ticket, closeVolume))
      {
         GlobalVariableSet(key + "_DONE", 1);

         Print("TP1 reached. Partial close executed. Ticket: ",
               ticket);
      }
   }
}

//==================== CHART DRAWING ====================

void DrawLevel(string name, double price, color clr)
{
   if(ObjectFind(0, name) < 0)
      ObjectCreate(0, name, OBJ_HLINE, 0, 0, price);

   ObjectSetDouble(0, name, OBJPROP_PRICE, price);
   ObjectSetInteger(0, name, OBJPROP_COLOR, clr);
   ObjectSetInteger(0, name, OBJPROP_STYLE, STYLE_DASH);
   ObjectSetInteger(0, name, OBJPROP_WIDTH, 1);
}

void DrawSetup(bool isBuy,
               double high, double low,
               double tp1, double tp2)
{
   string id = "GLS_" + IntegerToString((int)TimeCurrent());

   DrawLevel(id + "_HIGH", high, clrOrange);
   DrawLevel(id + "_LOW", low, clrOrange);
   DrawLevel(id + "_TP1", tp1, clrDodgerBlue);
   DrawLevel(id + "_TP2", tp2, clrLimeGreen);

   string fibName = id + "_FIB";

   if(ObjectCreate(0, fibName, OBJ_FIBO, 0,
                   TimeCurrent(), high,
                   TimeCurrent() + PeriodSeconds(SignalTimeframe),
                   low))
   {
      ObjectSetInteger(0, fibName, OBJPROP_LEVELS, 7);

      for(int i = 0; i <= 6; i++)
      {
         ObjectSetDouble(0, fibName, OBJPROP_LEVELVALUE, i, i);
         ObjectSetString(0, fibName, OBJPROP_LEVELTEXT,
                         i, "Fib " + IntegerToString(i));
      }

      ObjectSetInteger(0, fibName, OBJPROP_COLOR,
                       isBuy ? clrLimeGreen : clrTomato);
   }
}

//==================== EVENTS ====================

int OnInit()
{
   trade.SetExpertMagicNumber(MagicNumber);
   trade.SetDeviationInPoints(SlippagePoints);
   trade.SetTypeFillingBySymbol(_Symbol);

   lastBarTime = iTime(_Symbol, SignalTimeframe, 0);

   Print("Gold Liquidity Sweep EA initialized.");

   return INIT_SUCCEEDED;
}

void OnTick()
{
   ManagePositions();

   if(IsNewBar())
      CheckLiquiditySweep();
}

void OnDeinit(const int reason)
{
   Print("Gold Liquidity Sweep EA stopped.");
}

응답함

1
개발자 1
등급
(268)
프로젝트
318
74%
중재
16
75% / 0%
기한 초과
6
2%
무료
2
개발자 2
등급
(22)
프로젝트
28
7%
중재
9
33% / 33%
기한 초과
1
4%
작업중
3
개발자 3
등급
프로젝트
0
0%
중재
0
기한 초과
0
무료
게재됨: 3 코드
4
개발자 4
등급
(10)
프로젝트
17
18%
중재
3
0% / 67%
기한 초과
3
18%
작업중
5
개발자 5
등급
프로젝트
0
0%
중재
0
기한 초과
0
무료
게재됨: 2 코드
6
개발자 6
등급
프로젝트
0
0%
중재
0
기한 초과
0
무료
7
개발자 7
등급
(23)
프로젝트
34
53%
중재
1
100% / 0%
기한 초과
1
3%
무료
8
개발자 8
등급
(5)
프로젝트
7
86%
중재
0
기한 초과
0
무료
게재됨: 4 코드
9
개발자 9
등급
(19)
프로젝트
22
18%
중재
9
33% / 44%
기한 초과
3
14%
작업중
게재됨: 2 코드
10
개발자 10
등급
프로젝트
1
0%
중재
0
기한 초과
0
무료
게재됨: 4 코드
11
개발자 11
등급
프로젝트
0
0%
중재
0
기한 초과
0
무료
12
개발자 12
등급
(1)
프로젝트
1
100%
중재
0
기한 초과
0
무료
13
개발자 13
등급
(2)
프로젝트
3
33%
중재
0
기한 초과
2
67%
무료
14
개발자 14
등급
프로젝트
0
0%
중재
0
기한 초과
0
무료
15
개발자 15
등급
프로젝트
0
0%
중재
0
기한 초과
0
무료
게재됨: 2 코드
16
개발자 16
등급
프로젝트
0
0%
중재
0
기한 초과
0
무료
17
개발자 17
등급
(1)
프로젝트
1
0%
중재
0
기한 초과
0
무료
게재됨: 4 코드
18
개발자 18
등급
(64)
프로젝트
145
46%
중재
21
38% / 24%
기한 초과
32
22%
무료
19
개발자 19
등급
(180)
프로젝트
276
63%
중재
4
50% / 25%
기한 초과
10
4%
작업중
비슷한 주문
Why is it difficult to get notifications from this website. Notifications seems stale, what’s happening? Also I noticed almost 90% of the jobs posted here are from people who aren’t ready for their work to be executed. Is it just me experiencing this or anyone else
Hello, I am an independent developer selling an Expert Advisor (EA) on the MQL5 Market. I am looking for an experienced Forex affiliate marketing company or professional marketer to promote my existing MT5 trading robot to customers worldwide. My proposed partnership offers a 30% commission per verified sale, with the possibility of a long-term collaboration. I would like to know: Do you promote third-party MT5
Robert for life money's cash maximum 16mb the jobs future linuox Trading robots are programs, which operate according to underlying algorithms. An algorithm is a set of actions that need to be performed in response to certain events. For example, the most common task in algo trading is the identification of the "New bar" event . When the event occurs, the robot checks the emergence of trading signals and acts
I would like to commission the development of a custom Expert Advisor (Trading Robot) for MetaTrader 5 (MT5) that replicates the exact logic of the "Custom Range Bar" study from Sierra Chart, renders the range bar levels as an independent background layer on the chart, displays a live/historical performance statistics dashboard, and executes/manages trades automatically based on the rules below. 1. Range Bar
Okay, this is a big one for MT5 traders. Let's do it properly. In Python, the "Merge Tool" usually means 2 things: 1. *Merge MT5 data from different symbols / timeframes into one DataFrame* 2. *Plot it as a clean graph* Here is a complete working setup: *Step 1: Install* pip install MetaTrader5 pandas matplotlib mplfinance *Step 2: Full Code - Get MT5 Data + Merge + Plot* import MetaTrader5 as mt5 import pandas as pd
I need someone to develop a simple EA that makes random orders. Just random orders no indicators needed. I should be able to set my TP and SL of choice
I am looking for a quantitative strategy researcher and MQL5 developer to help research, validate and prototype a fast automated XAUUSD trading system for MT5. The target is tick-level trading with positions typically held for seconds, closely spaced entries, and configurable bursts of multiple positions during a qualifying opportunity. IMPORTANT: We do not yet have a validated profitable strategy. I need someone who
Experienced Trading Software Developer Needed – Multi-Platform Development Hello! I'm looking for an experienced developer to create a custom trading indicator and convert it into an automated trading bot for the following platforms: MT5 NinjaTrader 8 Quantower cTrader The plan is to develop the same indicator and trading bot for all four platforms, one after another. Project requirements: Custom trading indicator
un écosystème logiciel asynchrone multi-comptes dopé par un module de supervision par Intelligence Artificielle (Guardian AI). La solution assure le pilotage automatisé, le filtrage de marché en temps réel et le contrôle des risques pour 20+ comptes MetaTrader 4/5 (via MetaApi) et Deriv sur VPS Equinix NY4. vous aurez plus de detail dans les échanges
Metafix 50 - 200 USD
Here is a professional specification you can send directly to your developer. # Project Requirements Specification: MetaTrader 5 Trading Robot Development ### 1. Project Overview I want to develop an automated Forex trading robot (Expert Advisor) for MetaTrader 5 (MT5). The robot should analyse the financial markets, identify trading opportunities, and execute trades automatically based on predefined strategies. ###

프로젝트 정보

예산
40 - 60 USD
기한
에서 1 로 2 일

고객

넣은 주문1
중재 수0