Daily_Opening_EA_v2

Download script
Author: Bryan Wang
Profit factor:
0.00

This automated trading tool is designed to manage your trades by identifying specific market conditions at the start of each day and placing "pending" orders based on technical momentum. Instead of entering the market instantly, it waits for the price to hit specific levels, ensuring that trades are only activated if the market moves in the predicted direction.

Core Operating Logic

Daily Schedule and Market Monitoring The system is programmed to operate exclusively during the work week (Monday through Friday). It performs a check at the beginning of each new daily candle. If it is a weekend or outside of these active days, the script remains idle to avoid unnecessary market exposure.

Technical Analysis Filters Before placing any trades, the tool evaluates three distinct technical indicators to confirm the market's current strength:

  • RSI (Relative Strength Index): Used to determine if the asset is showing bullish or bearish momentum.
  • CCI (Commodity Channel Index): Helps identify whether the price is trading at a premium or discount relative to its average.
  • MACD (Moving Average Convergence Divergence): Provides confirmation of the overall trend direction.

The tool will only initiate a "Long" (buy) position if all three indicators signal upward momentum. Conversely, it will only initiate a "Short" (sell) position if all three signals point downward.

Dynamic Trade Execution Unlike standard trades that enter immediately, this script uses Pending Orders:

  • Buy Stops: Placed above the previous day's high. The trade only triggers if the price breaks upward.
  • Sell Stops: Placed below the previous day's low. The trade only triggers if the price breaks downward.

This strategy ensures that you are "trading with the breakout" rather than guessing where the price might go from its current position.

Automated Risk Management The script includes built-in intelligence to protect your account balance:

  • Dynamic Lot Sizing: It automatically calculates the number of units (lots) to trade based on a percentage of your total account equity. This ensures that your risk remains consistent regardless of your account size.
  • Safety Caps: There is a hard limit on the maximum lot size to prevent any single trade from becoming excessively large.
  • Defined Targets: Every trade is governed by pre-set Stop Loss and Take Profit levels to lock in gains or minimize losses automatically.

Order Maintenance The script constantly monitors its own active pending orders. If a pending order is not triggered within the expected timeframe, or if specific conditions change, it is designed to clean up the workspace by removing unnecessary pending orders, ensuring your trading screen remains organized and free of "ghost" trades.

Orders Execution
It Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
Relative strength indexCommodity channel indexMACD Histogram
7 Views
0 Downloads
0 Favorites
Daily_Opening_EA_v2
//+------------------------------------------------------------------+
//|                                          Daily Opening EA v2.mq4 |
//|                                                       Bryan Wang |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Bryan Wang"
#property link      ""
extern double SL = 100;
extern double TP = 100;
extern double Lots = 0.01;
extern double RiskPercentage = 0.02;
datetime PrevTime = 0;
datetime CurrTime = 0;
int PendingSell = -1;
int PendingBuy = -1;
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   CurrTime = iTime(NULL,0,1);
   if (CurrTime==PrevTime) return(0);
   if (PendingSell != -1) {
      OrderSelect(PendingSell,SELECT_BY_TICKET,MODE_TRADES);
      if (OrderType()==OP_SELLSTOP) {
         OrderDelete(PendingSell);
         PendingSell = -1;
      } else if (OrderType()==OP_SELL && OrderCloseTime() <= 0) {
         OrderClose(PendingSell,OrderLots(),Ask,3,Green);
         PendingSell = -1;
      }
   }
   if (PendingBuy != -1) {
      OrderSelect(PendingBuy,SELECT_BY_TICKET,MODE_TRADES);
      if (OrderType()==OP_BUYSTOP) {
         OrderDelete(PendingBuy);
         PendingBuy = -1;
      } else if (OrderType()==OP_BUY && OrderCloseTime() <= 0) {
         OrderClose(PendingBuy,OrderLots(),Bid,3,Red);
         PendingBuy = -1;
      }
   }
   if (TimeDayOfWeek(CurrTime)<1 || TimeDayOfWeek(CurrTime)>4) return(0);
   double RSI = iRSI(Symbol(),0,21,PRICE_CLOSE,1);
   double CCI = iCCI(Symbol(),0,50,PRICE_CLOSE,1);
   double MACD = iMACD(Symbol(),0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
   if (CCI > 0 && RSI > 50 && MACD > 0) OpenLong();
   if (CCI < 0 && RSI < 50 && MACD < 0) OpenShort();
   PrevTime = CurrTime;
   return(0);
  }
void OpenLong() {
   double spread = Ask-Bid;
   double Lots2 = (AccountEquity()*RiskPercentage)/SL;
   if (Lots2 > 10) Lots2 = 10;
   PendingBuy = OrderSend(Symbol(),OP_BUYSTOP,Lots2,High[1]+spread,3,High[1]-SL*Point+spread,High[1]+TP*Point+spread,"Daily open v2",72,0,Green);
}
void OpenShort() {
   double spread = Ask-Bid;
   double Lots2 = (AccountEquity()*RiskPercentage)/SL;
   if (Lots2 > 10) Lots2 = 10;
   PendingSell = OrderSend(Symbol(),OP_SELLSTOP,Lots2,Low[1],3,Low[1]+SL*Point-spread,Low[1]-TP*Point-spread,"Daily open v2",72,0,Red);
}
//+------------------------------------------------------------------+

Comments