Supply and Demand Trading Bot

Specification

//+------------------------------------------------------------------+
//| Advanced Supply and Demand EA                                   |
//+------------------------------------------------------------------+
#property strict

// === Input parameters ===
input double LotSize = 0.1;
input int ZoneLookback = 30;
input int HigherTF = PERIOD_H1;
input int RSI_Period = 14;
input int RSI_Buy = 30;
input int RSI_Sell = 70;
input int ATR_Period = 14;
input double SL_ATR_Multiplier = 1.5;
input double TP_ATR_Multiplier = 3.0;
input int MaxTradesPerDay = 2;
input bool ShowZones = true;

// === Global variables ===
datetime lastTradeTime = 0;
double demandZone = 0;
double supplyZone = 0;
bool demandZoneActive = false;
bool supplyZoneActive = false;

//+------------------------------------------------------------------+
//| Initialization                                                  |
//+------------------------------------------------------------------+
int OnInit()
{
   Print("Advanced Supply and Demand EA Initialized");
   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Tick Function                                                    |
//+------------------------------------------------------------------+
void OnTick()
{
   static datetime lastBarTime = 0;
   if (Time[0] == lastBarTime) return;
   lastBarTime = Time[0];

   DetectZones();
   CheckEntryConditions();
}

//+------------------------------------------------------------------+
//| Zone Detection                                                   |
//+------------------------------------------------------------------+
void DetectZones()
{
   demandZone = 0;
   supplyZone = 0;
   demandZoneActive = false;
   supplyZoneActive = false;

   for (int i = 2; i < ZoneLookback; i++)
   {
      double body = MathAbs(Open[i] - Close[i]);
      double wickTop = High[i] - MathMax(Open[i], Close[i]);
      double wickBot = MathMin(Open[i], Close[i]) - Low[i];

      // Demand zone detection
      if (body > wickTop * 2 && Close[i] < Open[i] && Close[i+1] > Open[i+1])
      {
         demandZone = Low[i];
         demandZoneActive = true;
      }

      // Supply zone detection
      if (body > wickBot * 2 && Close[i] > Open[i] && Close[i+1] < Open[i+1])
      {
         supplyZone = High[i];
         supplyZoneActive = true;
      }
   }

   if (ShowZones)
   {
      DrawZone("DemandZone", demandZone, clrAqua);
      DrawZone("SupplyZone", supplyZone, clrOrangeRed);
   }
}

//+------------------------------------------------------------------+
//| Entry Conditions & Trade Logic                                   |
//+------------------------------------------------------------------+
void CheckEntryConditions()
{
   if (OrdersTotal() >= MaxTradesPerDay) return;

   double rsi = iRSI(Symbol(), PERIOD_M15, RSI_Period, PRICE_CLOSE, 0);
   double atr = iATR(Symbol(), PERIOD_M15, ATR_Period, 0);
   double ask = Ask;
   double bid = Bid;

   // BUY Condition
   if (demandZoneActive && bid <= demandZone + 10 * Point && rsi < RSI_Buy)
   {
      double sl = bid - SL_ATR_Multiplier * atr;
      double tp = bid + TP_ATR_Multiplier * atr;

      if (!OpenBuyOrder())
      {
         int buyTicket = OrderSend(Symbol(), OP_BUY, LotSize, ask, 2, sl, tp, "Buy Demand Zone", 0, clrAqua);
         if (buyTicket > 0) lastTradeTime = TimeCurrent();
      }
   }

   // SELL Condition
   if (supplyZoneActive && ask >= supplyZone - 10 * Point && rsi > RSI_Sell)
   {
      double sl = ask + SL_ATR_Multiplier * atr;
      double tp = ask - TP_ATR_Multiplier * atr;

      if (!OpenSellOrder())
      {
         int sellTicket = OrderSend(Symbol(), OP_SELL, LotSize, bid, 2, sl, tp, "Sell Supply Zone", 0, clrOrangeRed);
         if (sellTicket > 0) lastTradeTime = TimeCurrent();
      }
   }
}

//+------------------------------------------------------------------+
//| Check Open Buy Orders                                            |
//+------------------------------------------------------------------+
bool OpenBuyOrder()
{
   for (int i = 0; i < OrdersTotal(); i++)
   {
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
      {
         if (OrderSymbol() == Symbol() && OrderType() == OP_BUY)
            return true;
      }
   }
   return false;
}

//+------------------------------------------------------------------+
//| Check Open Sell Orders                                           |
//+------------------------------------------------------------------+
bool OpenSellOrder()
{
   for (int i = 0; i < OrdersTotal(); i++)
   {
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
      {
         if (OrderSymbol() == Symbol() && OrderType() == OP_SELL)
            return true;
      }
   }
   return false;
}

//+------------------------------------------------------------------+
//| Draw Supply/Demand Zones                                         |
//+------------------------------------------------------------------+
void DrawZone(string name, double level, color clr)
{
   if (level == 0) return;

   string objName = name + "_rect";
   if (!ObjectCreate(objName, OBJ_RECTANGLE, 0, Time[0], level, Time[ZoneLookback], level + 10 * Point))
   {
      ObjectMove(objName, 0, Time[0], level);
      ObjectMove(objName, 1, Time[ZoneLookback], level + 10 * Point);
   }

   ObjectSet(objName, OBJPROP_COLOR, clr);
   ObjectSet(objName, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(objName, OBJPROP_BACK, true);
}

Responded

1
Developer 1
Rating
(3)
Projects
4
0%
Arbitration
0
Overdue
0
Free
2
Developer 2
Rating
(279)
Projects
434
18%
Arbitration
26
46% / 27%
Overdue
27
6%
Busy
3
Developer 3
Rating
Projects
0
0%
Arbitration
1
0% / 0%
Overdue
0
Working
4
Developer 4
Rating
(4)
Projects
5
0%
Arbitration
0
Overdue
1
20%
Working
5
Developer 5
Rating
(1)
Projects
1
0%
Arbitration
1
0% / 0%
Overdue
0
Working
6
Developer 6
Rating
(216)
Projects
253
47%
Arbitration
10
40% / 0%
Overdue
14
6%
Loaded
7
Developer 7
Rating
(3)
Projects
2
50%
Arbitration
1
0% / 100%
Overdue
0
Free
8
Developer 8
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
Similar orders
⚙ Renko EA Entry Logic (Simplified & Professional) 🔹 Buy Entry EA opens a Buy when Fast MA crosses above Slow MA , signaling an uptrend. 🔹 Sell Entry EA opens a Sell when Fast MA crosses below Slow MA , signaling a downtrend. 🔹 Close on Next Entry (if enabled) If CloseOnNextEntry = true : • Closes opposite trade before opening a new one • Ensures only one active trade at a time 🔹 Trend Filter (if enabled) EA
Hello... I need an EA developer to create an MQL5 / Metatrader 5 EA Using Orderblocks, MA, and Bollingers Bands Timeframe used: Entry: 5M validation: H1 & 1D to see the trend direction (if this validation is not suitable, please change it) entry logic for buy: > If the price touches and presses the lower BB bands (Extreme), then a BUY execution will occur, but must first see the trend direction on H1 & D1 entry logic
Hello All, I need a developer who can help me to modify my existing expert advisor with below requirements : 1. I have already a mql4 file and I want to modified it with some new certain filters or conditions 2. I will add more filters conditions which I will tell you later for the selected developer. 3. Once it’s done so you must share the modified mql4 to me and I will do back test many times to make sure whether
Buna tuturor developerilor romani de pe aici, Am un indicator care functioneaza destul de bine insa cum intotdeauna este loc de mai bine as avea nevoie de niste update uri pentru el. In principiu as vrea sa fie adaugat 2 indicatori noi in logica existenta, primul este CCI al doilea este Accelerator Oscillator. Primul ar trebui sa functioneze in TF current, iar al doilea in TF curent + un TF mai mare. Mai multe
I’m looking for a custom indicator that can scan for ICT Smart Money "Breaker Structures" and alert me when they form. What I Need: The indicator should analyze markets (Oil/Gold/ but mostly Crypto (BTC)) for Breaker Structures—where price breaks a swing high/low but gets rejected, signaling a potential reversal. I primarily use TradingView, so I'd appreciate it if the script is compatible with TradingView and can
Hello All, I need News Filter For MT4. Input Parameters:- 1. News Filter ON/OFF 2. Stop Trade Before 3. Start Trade After 4. Low News ON/OFF 5.Medium News ON/OFF 6. High News ON/OFF 7. Number of News Show On Chart Example if user enter = 1 than only 1 Latest Upcoming News Show Get News Data From This Website Only : https://www.mql5.com/en/economic-calendar If News Filter is OFF than show NEWS FILTER IS OFF if
Modification 30+ USD
Hello I need a developer who can modify my EA. The ea should not open trades when stop loss is hit or trailing stop is hit or take profit is hit and wait for the next signal to begin opening trades again. The ea keeps opening trades after stop loss or trailing stop or take profit is hit using the old signal making it less profitable. It should not open another trade after stop loss ot trailing stop or take profit is
I want to a professional developer who is expert in creating the EA using Heikin Ashi candles. I am already having a simple trading view strategy, and just want to convert it to MT4 bot for auto execution of orders. Option for Changing SL and TP percentage in MT4 required. All other is mentioned in my simple strategy. [attached in txt file] Note: 1. The developer should back test the strategy on MT4 before accepting
I need an expert developer for an MT5 EA . You will be able to create an EA that first runs a TOP DOWN ANALYSIS using a candle stick formation/MA, and then goes on to execute a trade using the RSI+Stoch+candle stick confluence at discount extreme zones or premium zones or liquidity zones. Every other thing that will be contained in the parameter list will be provided in a full description. The Logic of the EA will be
I want to make a simple EA based of 2-3 indicators from trading view. Basic functions and basic logic. Needs to be backtestable and work on forex, indices and crypto

Project information

Budget
50+ USD
Deadline
from 1 to 12 day(s)

Customer

Placed orders1
Arbitrage count0