The Eternal Pro DayTrading (Non-Repaint) Expert Advisor is designed to automate trading strategies based on a set of predefined rules. This EA utilizes a combination of market indicators, including the Bulls Power, Bears Power, and a custom BullsBearsEyes indicator, to guide trading decisions.
By analyzing market data, the EA determines optimal entry and exit points, helping traders manage their trades efficiently. Its focus on non-repainting indicators ensures that the signals remain consistent, providing clarity in decision-making. The Eternal Pro DayTrading EA aims to streamline the trading process by executing trades based on its programmed logic, allowing for systematic trading without manual intervention.
extern int BullBearPeriod = 5; // Period for Bulls/Bears Power
extern double lots = 1.0; // Lot size
extern double TrailingStop = 15; // Trailing stop in points
extern double takeProfit = 150; // Take profit in points
extern double stopLoss = 45; // Stop loss in points
extern double slippage = 3; // Slippage
extern string nameEA = "DayTrading"; // EA identifier
double bull, bear; // Indicator values
double PrevBBE, CurrentBBE; // Custom indicator values
double realTP, realSL, b, s, sl, tp; // Trade-related variables
bool isBuying = false, isSelling = false, isClosing = false; // Trade signals
int cnt, ticket; // Counters
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {
return(0); // Initialization complete
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
return(0); // Deinitialization complete
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() {
// Check for sufficient bars and validate take profit
if(Bars < 200) {
Print("Not enough bars for this strategy - ", nameEA);
return(-1);
}
calculateIndicators(); // Calculate indicators' values
// Control open trades
int totalOrders = OrdersTotal();
int numPos = 0;
for(cnt = 0; cnt < totalOrders; cnt++) {
OrderSelect(cnt, SELECT_BY_POS); // Select order by position
// Check if the order is for the current symbol and is a market order
if(OrderSymbol() == Symbol() && OrderType() <= OP_SELL) {
numPos++;
if(OrderType() == OP_BUY) { // For buy trades
if(TrailingStop > 0 && (Bid - OrderOpenPrice() > TrailingStop * Point)) {
if(OrderStopLoss() < (Bid - TrailingStop * Point)) {
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - TrailingStop * Point, OrderTakeProfit(), 0, Blue);
}
}
} else { // For sell trades
if(TrailingStop > 0 && (OrderOpenPrice() - Ask > TrailingStop * Point)) {
if(OrderStopLoss() == 0 || OrderStopLoss() > Ask + TrailingStop * Point) {
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + TrailingStop * Point, OrderTakeProfit(), 0, Red);
}
}
}
}
}
// If no open trades exist for this pair and EA
if(numPos < 1) {
if(AccountFreeMargin() < 1000 * lots) {
Print("Not enough money to trade ", lots, " lots. Strategy:", nameEA);
return(0);
}
// Check for BUY entry signal
if(isBuying && !isSelling && !isClosing) {
sl = Ask - stopLoss * Point;
tp = Bid + takeProfit * Point;
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage, sl, tp, nameEA + CurTime(), 0, Green);
if(ticket < 0) {
Print("OrderSend (", nameEA, ") failed with error #", GetLastError());
}
}
// Check for SELL entry signal
if(isSelling && !isBuying && !isClosing) {
sl = Bid + stopLoss * Point;
tp = Ask - takeProfit * Point;
ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, slippage, sl, tp, nameEA + CurTime(), 0, Red);
if(ticket < 0) {
Print("OrderSend (", nameEA, ") failed with error #", GetLastError());
}
}
}
return(0); // End of start function
}
//+------------------------------------------------------------------+
//| Calculate indicators' values |
//+------------------------------------------------------------------+
void calculateIndicators() {
bull = iBullsPower(NULL, 0, BullBearPeriod, PRICE_CLOSE, 1);
bear = iBearsPower(NULL, 0, BullBearPeriod, PRICE_CLOSE, 1);
CurrentBBE = iCustom(NULL, 0, "BullsBearsEyes", 13, 0, 0.5, 300, 0, 0);
PrevBBE = iCustom(NULL, 0, "BullsBearsEyes", 13, 0, 0.5, 300, 0, 1);
b = (1 * Point) + (iATR(NULL, 0, 5, 1) * 1.5); // Calculate buy trailing stop
s = (1 * Point) + (iATR(NULL, 0, 5, 1) * 1.5); // Calculate sell trailing stop
// Determine trade signals based on indicators
isBuying = (CurrentBBE > 0.50);
isSelling = (CurrentBBE < 0.50);
isClosing = false;
// Trailing stop for open positions
for(int i = 0; i < OrdersTotal(); i++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() == OP_BUY) {
TrailingStop = b;
if(Bid - OrderOpenPrice() > TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) {
if(OrderStopLoss() < Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) {
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(), Red);
}
}
} else if(OrderType() == OP_SELL) {
TrailingStop = s;
if(OrderOpenPrice() - Ask > TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) {
if((OrderStopLoss() > Ask + TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) || (OrderStopLoss() == 0)) {
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(), Red);
}
}
}
}
return(0); // End of calculateIndicators function
}
How the DayTrading EA Works
The DayTrading EA is designed to execute buy and sell orders based on specific signals derived from Bulls Power and Bears Power indicators, as well as a custom indicator called BullsBearsEyes. These indicators help the EA decide when to open or close trades by analyzing market conditions.
Key Variables and Parameters
The EA begins by setting a few key variables and parameters:
- BullBearPeriod: This is the period over which the Bulls Power and Bears Power indicators are calculated. A shorter period may make the indicators more sensitive, while a longer period may smooth out the signals.
- lots: This variable controls the size of each trade. It determines how much of the asset will be bought or sold when a trade signal is generated.
- TrailingStop: A trailing stop is used to protect profits by adjusting the stop loss as the trade becomes more profitable. In this EA, the trailing stop is defined in points.
- takeProfit and stopLoss: These define the exit points for each trade. The takeProfit variable specifies the profit level at which a trade should be closed, while stopLoss limits potential losses.
Analyzing the Market with Indicators
The Role of Bulls Power and Bears Power
The Bulls Power and Bears Power indicators are used to assess the strength of buyers (bulls) and sellers (bears) in the market. The EA calculates these indicators over the specified BullBearPeriod and uses their combined value to determine market direction:
- Bulls Power measures the ability of buyers to push prices higher.
- Bears Power measures the ability of sellers to push prices lower.
By analyzing these two forces, the EA can decide whether the market is more likely to rise or fall.
Introducing the BullsBearsEyes Indicator
The BullsBearsEyes is a custom indicator that provides additional insight into market dynamics. The EA uses this indicator to refine its decision-making process:
- CurrentBBE: The current value of the BullsBearsEyes indicator. This value helps determine whether the market is in a buying or selling condition.
- PrevBBE: The previous value of the BullsBearsEyes indicator, used for comparison to see how market conditions are evolving.
Trade Execution and Management
Opening New Trades
The EA monitors the market and waits for the right conditions to open a new trade. These conditions are based on the values of the Bulls Power, Bears Power, and BullsBearsEyes indicators:
- A buy signal is generated if the CurrentBBE is greater than 0.50, indicating that the market is potentially in an upward trend.
- A sell signal is generated if the CurrentBBE is less than 0.50, indicating a possible downward trend.
Before placing a trade, the EA checks the account’s free margin to ensure there is enough capital to cover the trade.
Managing Open Trades
Once a trade is open, the EA manages it using the TrailingStop, takeProfit, and stopLoss settings:
- Trailing Stop: As the trade moves in the desired direction, the trailing stop adjusts the stop loss to lock in profits. This means if the market suddenly reverses, the trade will be closed at the trailing stop level, securing some of the profits.
- Take Profit and Stop Loss: These parameters define the maximum profit or loss the EA will accept for each trade. The EA automatically closes the trade when either level is hit.
Important Considerations
While this EA provides a structured approach to trading, it’s important to note that the indicators used have their limitations:
- Non-Lagging: The EA’s calculations are based on current market data, but it doesn’t fully eliminate lag since it still reacts to changes rather than predicting them.
- Non-Repaint: The signals from the indicators do not repaint, meaning they don’t change after they are generated.
- Recalculation: The EA recalculates indicator values on every tick, which can sometimes lead to signals that change rapidly in volatile markets.
Final Thoughts
The DayTrading EA is a robust tool that automates trading decisions using a combination of standard and custom indicators. By setting clear entry and exit rules, it helps traders manage their positions effectively. However, as with any automated system, understanding its logic and potential limitations is crucial for its successful application.