The specifications:
This EA uses the RSI exclusively for trade opens and closes. The RSI crosses 50 moving upward and alerts the EA to watch. When it reaches 53 it triggers a buy order. When the RSI reaches 70, it triggers a close order. Conversely, when the RSI crosses 50 moving downward, it alerts the EA. When it reaches 47 it triggers a sell order. This order is closed at RSI 30. There is also a contingency if the RSI crosses over the 50 moving the opposite direction that the trade would close.
As much is in the existing code.
Currently, the EA will only open and close one trade in the Strategy Tester. I would like you to modify the EA to operate according to these specifications.
I would also like you to add a trailing stop that can be adjusted.
Here is the existing code:
// Global Variables
enum StateType {WATCHING, LONG_ENTRY, SHORT_ENTRY, CLOSE_TRADE};
StateType state = WATCHING;
double LotSize = 0.1; // Lot size
double StopLoss = 20.0 * Point; // Stop loss in price difference
double TakeProfit = 100.0 * Point; // Take profit in price difference
int slippage = 3;
int RSI_Period = 14;
// OnTick function
void OnTick() {
double currentRSI = iRSI(Symbol(), 0, RSI_Period, PRICE_CLOSE, 0);
double previousRSI = iRSI(Symbol(), 0, RSI_Period, PRICE_CLOSE, 1);
if (state == WATCHING) {
if (currentRSI > 50 && previousRSI <= 50) {
state = LONG_ENTRY;
} else if (currentRSI < 50 && previousRSI >= 50) {
state = SHORT_ENTRY;
}
}
if (state == LONG_ENTRY && currentRSI >= 53) {
PlaceLongOrder();
} else if (state == SHORT_ENTRY && currentRSI <= 47) {
PlaceShortOrder();
}
if (state == CLOSE_TRADE) {
CloseTrade(currentRSI);
}
}
// Function to place a long order
void PlaceLongOrder() {
if (OrdersTotal() == 0) {
double price = Ask;
int ticket = OrderSend(Symbol(), OP_BUY, LotSize, price, slippage, price - StopLoss, price + TakeProfit, "Buy Order", 0, 0, clrGreen);
if (ticket > 0) state = CLOSE_TRADE;
}
}
// Function to place a short order
void PlaceShortOrder() {
if (OrdersTotal() == 0) {
double price = Bid;
int ticket = OrderSend(Symbol(), OP_SELL, LotSize, price, slippage, price + StopLoss, price - TakeProfit, "Sell Order", 0, 0, clrRed);
if (ticket > 0) state = CLOSE_TRADE;
}
}
// Function to close the trade based on RSI
void CloseTrade(double currentRSI) {
for (int i = 0; i < OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol()) {
if ((OrderType() == OP_BUY && currentRSI >= 70) || (OrderType() == OP_SELL && currentRSI <= 30)) {
bool closed = OrderClose(OrderTicket(), OrderLots(), (OrderType() == OP_BUY ? Bid : Ask), 3, clrRed);
if (closed) state = WATCHING;
} else if ((OrderType() == OP_BUY && currentRSI < 50) || (OrderType() == OP_SELL && currentRSI > 50)) {
closed = OrderClose(OrderTicket(), OrderLots(), (OrderType() == OP_BUY ? Bid : Ask), 3, clrRed);
if (closed) state = WATCHING;
}
}
}
}
相似订单
Hi, I am looking for someone who has already developed a high-performance Gold EA that can outperform the one shown in my screenshot. If you have such an EA, please apply for this job. Please describe how the EA works (for example, whether it uses a grid system) and provide backtest results along with the set files. If the EA meets my expectations, you can make the necessary adjustments and I will use it as my own
The best way forward to the future that is all over between the market in all orders for us and our team to make good projects with you on the general level
I am looking for a developer to create a trading robot (EA) to trade XAUUSD, NAS100 and SPX500. The rules are as follows: Buy when the 2 EMA crosses over the 10 EMA and price closes over the 50 ema. Sell when the 2 EMAs cross below the 10 EMAs and the price closes below the 50 EMAs. The take profit and stop loss can be adjusted by me selecting from a drop-down box. I am open to other parameters to optimize
Description I need an very low latency MT5 Expert Advisor (EA) developed in MQL5 to automate TradingView alerts into MT5 trades for alerts set up done on trading view. The EA must work on both DEMO and LIVE accounts whichever will be attached to MT5 (XM, IC Markets and similar MT5 brokers) and be suitable for fast 1-minute timeframe scalping.End to End solution. Functional Requirements 1. TradingView Integration
Project Overview I am looking for an experienced MQL5 developer to build a custom, prop-firm-compliant trend-following Expert Advisor (EA) for MetaTrader 5 . This EA will be used on prop firm accounts (e.g., FTMO-style rules), so strict risk control and rule compliance are mandatory . This is NOT a grid, martingale, scalping, or recovery EA. The goal is consistency, rule compliance, and capital preservation , not
I would like to buy ea that is proven to be good need to have stable profit and can be very unstable DD but not more than 40 %you can send eas in dm for sale. I am looking of an Expert Advisor (EA) that has undergone independent validation and demonstrates a capability to successfully navigate prop firm challenges, as well as efficiently manage funded accounts. It is imperative that you provide a comprehensive
I am looking of an Expert Advisor (EA) that has undergone independent validation and demonstrates a capability to successfully navigate prop firm challenges, as well as efficiently manage funded accounts. It is imperative that you provide a comprehensive explanation of the strategy utilized by your EA, along with a demo version that has a 30-day expiration. This will facilitate extensive back testing and forward
I am seeking a highly skilled developer to build a fully functional automated Expert Advisor for MetaTrader 5 (MQL5)- XAUUSD fast in and out EA scalper that opens multiple trades following trend, uses dynamic lot sizing, and has to be – 24/5 unlimited. require the development of a high-speed, continuous fully automated trading Expert Advisor (EA) for MetaTrader 5, optimized for live trading on ICmarkets. The EA must
Hellow,l hope you are well,l am writing to place an order for a professional trading robot.l am looking for a reliable,well optimized robot that can trade efficiently,manage risk properly and deliver consistent performance in the market,I am particularly interested in a trading robot that uses a proven and transparent strategy,has strong risk management features,works well on common trading platforms,is suitable for
I am looking for an experienced MQL5 developer to build a professional MT5 software (indicator or semi-automated EA) for metals and major forex pairs. 📌 PLATFORM & MARKETS Platform: MetaTrader 5 Instruments: XAUUSD (Gold vs USD) XAGUSD (Silver vs USD) EURUSD GBPUSD USDJPY Trading styles: Scalping Intraday / short-term swing 🎯 MAIN OBJECTIVE I do NOT want an aggressive fully automated robot. I want a