HI
i want some one to make the following MQL5 code work for me. the code has errors.
#include <Trade\Trade.mqh> // Include the trade library
// Define input parameters
input double lotSize = 0.1; // Lot size for trading
input int stopLoss = 50; // Stop Loss in pips
input int takeProfit = 100; // Take Profit in pips
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
// Subscribe to OnTrade() event
EventSetMillisecondTimer(60); // Set a timer to check conditions every 60 milliseconds
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
// Deinitialization function (if needed)
EventKillTimer(); // Kill the timer when deinitializing
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
// Nothing to do here for conditions check, as we use OnTrade()
}
//+------------------------------------------------------------------+
//| Expert trade event handler |
//+------------------------------------------------------------------+
void OnTrade()
{
// Calculate the open and close prices of the previous day
double prevDayOpen = iOpen(Symbol(), PERIOD_D1, 1);
double prevDayClose = iClose(Symbol(), PERIOD_D1, 1);
// Check for Rule 1: Previous day was an uptrend
if (prevDayClose > prevDayOpen)
{
// Check if the current open price is between the previous day's open and close prices
double currentOpen = iOpen(Symbol(), PERIOD_D1, 0);
if (currentOpen > prevDayOpen && currentOpen < prevDayClose)
{
// Buy if the price breaks above the previous day's close price
double currentHigh = iHigh(Symbol(), PERIOD_D1, 0);
if (currentHigh > prevDayClose)
{
// Place a Buy order
double openPrice = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double stopLossPrice = openPrice - stopLoss * _Point;
double takeProfitPrice = openPrice + takeProfit * _Point;
int ticket = OrderSend(_Symbol, OP_BUY, lotSize, openPrice, 3, 0, 0, "", 0, clrNONE, 0, clrNONE);
if (ticket > 0)
{
// Order placed successfully - set Stop Loss and Take Profit
OrderSend(_Symbol, OP_SELL, lotSize, openPrice, 0, stopLossPrice, takeProfitPrice, "", 0, clrNONE, 0, clrNONE);
}
}
}
}
// Check for Rule 2: Opposite of Rule 1
if (prevDayClose < prevDayOpen)
{
// Check if the current open price is between the previous day's open and close prices
double currentOpen = iOpen(Symbol(), PERIOD_D1, 0);
if (currentOpen > prevDayOpen && currentOpen < prevDayClose)
{
// Sell if the price breaks below the previous day's close price
double currentLow = iLow(Symbol(), PERIOD_D1, 0);
if (currentLow < prevDayClose)
{
// Place a Sell order
double openPrice = SymbolInfoDouble(_Symbol, SYMBOL_BID);
double stopLossPrice = openPrice + stopLoss * _Point;
double takeProfitPrice = openPrice - takeProfit * _Point;
int ticket = OrderSend(_Symbol, OP_SELL, lotSize, openPrice, 3, 0, 0, "", 0, clrNONE, 0, clrNONE);
if (ticket > 0)
{
// Order placed successfully - set Stop Loss and Take Profit
OrderSend(_Symbol, OP_BUY, lotSize, openPrice, 0, stopLossPrice, takeProfitPrice, "", 0, clrNONE, 0, clrNONE);
}
}
}
}
}
相似订单
MT5 EA DEVELOPMENT SPECIFICATION CHANNEL + RSI REVERSAL STRATEGY I need a professional MetaTrader 5 Expert Advisor based on the following exact strategy. 1. Core Strategy The EA must automatically identify a valid price channel using confirmed swing highs and swing lows. The strategy trades reversals from the channel extremes: SELL: Upper channel + RSI above 70 + bearish rejection. BUY: Lower channel + RSI below 40 +
Hi, I have an existing MQL5 EA of around 18,000 lines that I would like you to review. It has two entry systems (Main + Scalper), many filters/parameters, risk management, and prop-firm functionality. The EA is already working, but I am struggling with optimization and obtaining robust backtest statistics. I would like to send you the complete source code so you can first review the architecture, strategy logic
Hello there, I am looking for a automated strategy for ninjatrader 5 Looking for a proven profit factor of 1.5 ( minimum ) on 15 mins time frame . I do MNQ futures I do not have the logic, but I like mean reverssion variable , plus RSI etc . that could make the automated tool robust and long lasting. i need fast response if you have
I need an Expert Advisor called ZONDII Scalpers for MT5 (MQL5). Timeframe: M5 Pairs: XAUUSD / EURUSD BUY when: Price > EMA200 and EMA50 crosses above EMA200 and RSI(14) > 50 SELL when: Price < EMA200 and EMA50 crosses below EMA200 and RSI(14) < 50 Risk: Fixed lot 0.01, SL 300 points, TP 600 points, Trailing start 200 points / step 100 points. Filter: Max spread 30 points. Only 1 trade at a time. Inputs must be
I am looking for a professional MT5 EA developer to build a high-performance trading bot specifically for XAUUSD (Gold). My target is approximately 200% return within 3 months, while keeping the drawdown and risk as controlled as reasonably possible. Requirements: MT5 Expert Advisor (EA) XAUUSD only Fully automated trading Clear risk management Stop Loss and Take Profit on trades No martingale or grid strategy unless
Hello, I’m looking for an experienced MT5 developer to build a professional Expert Advisor (EA) for trading Gold (XAUUSD). My requirements: Platform: MT5 Instrument: XAUUSD (Gold) Fully automatic trading Both BUY and SELL trades Adjustable lot size Stop Loss and Take Profit Trailing Stop / Break Even Daily maximum loss limit Maximum drawdown protection Maximum number of open trades Trading hours/session filter Spread
Develop an Expert Advisor trading trend reversals. Reversal signals will be generated based on Price Action patterns. Trend will be determined based on ADX, Alligator and MACD, while the indicator selection should be available in the EA's input parameters
1. PROJECT OVERVIEW Development of a custom automated and manual trading bot for NinjaTrader 8, primarily designed for Nasdaq Futures (NQ/MNQ). The bot will contain the original trading strategy, configurable risk management, automatic and manual operating modes, alerts, profit/loss management, partial profit taking, Break Even, backtesting functionality, and the additional configurable contract-averaging system
Hello, I have a custom indicator with a specific line. Logic I want: 1. When a candle closes and crosses the indicator line (I will tell you the buffer number of this line), start counting. 2. After the cross, wait for 3 consecutive candles with the same color / same direction. 3. If the 3 candles are bullish, open a BUY trade on the next candle open. 4. If the 3 candles are bearish, open a SELL trade on the
Ich möchte einen professionellen Expert Advisor (EA) für MetaTrader 5 entwickeln lassen, der sich funktional am ThunderGold Scalper orientiert. Instrument: XAUUSD / GOLD Zeitrahmen: M15 Plattform: MetaTrader 5 / MQL5 Der EA soll eine eigene, nachprogrammierte Strategie verwenden und keine geschützten Quellcodes oder proprietären Dateien des Originalprodukts kopieren. Gewünschte Funktionen: automatischer Handel auf