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);
}
}
}
}
}
相似订单
NinjaTrader 8 / NinjaScript Phase 1 build: convert an existing Auction Market Theory (AMT) strategy into objective, alert-only decision-support logic. Not a bot, no auto-execution — trades stay manual. Covers NQ/MNQ, ES, CL, MGC using 30-min TPO/Volume Profile context with 5-min confirmation: one 5-min close outside VAH/VAL = acceptance, close back inside = rejection. Dashboard shows bias, auction state, location
Hi i need help to connect my chat gtp with ninja trader I have all tools. Just need supervision and seeking a professional who can do that for me. This the bridge extension https://crosstrade.io/blog/chatgpt-to-ninjatrader-mcp-walkthrough
Hello, I am looking for an experienced MQL5 developer to convert an open-source TradingView indicator into a fully functional MetaTrader 5 Expert Advisor (automated trading robot). Source Indicator: Heikin Ashi RSI Oscillator (HARSI) by JayRogers TradingView Link: Target Platform: MetaTrader 5 (MT5) Core Requirements: Indicator Replication: The EA must accurately replicate the HARSI candle logic, smoothing
I need a pine script coder to automate my strategy (based on trendline) on tradingview platform. I simply need tradingview to open a position when the price touches the specified trendline with options to buy or sell and SL level. Please let me know if you are interested and I can give you exact details. Thank you
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 +
Senior MQL5 Developer Required — XAUUSD & BTCUSD Algorithmic EA I am looking for an experienced MQL5 developer to design and build a robust MT5 Expert Advisor for XAUUSD (Gold) and BTCUSD . This is not a request for a basic RSI/EMA EA, martingale, grid, or recovery system . I want a properly engineered algorithmic trading system with a demonstrable trading rationale, robust risk management, reliable execution and
Fully automated entry and exit of trades. Identify market trends using price action and reliable technical indicators. Trade major Forex pairs and XAU/USD (Gold). Automatic Stop Loss and Take Profit on every trade. Adjustable risk management, with default risk of 1% per trade. Maximum daily loss protection to stop trading after a specified loss. Break-even and trailing-stop functions. Adjustable lot size, risk %
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
Date:29.08.2026 **TECHNICAL SPECIFICATIONS** PDF Attached for reference rest all details given below. Required: Creation, Integration and successful execution of trading algo/robot in MT5 using MT5 VPS. Brokers: Trades to be executed in both brokers Swissquote and Pepperstone. Symbols: All available in MT5. ** Common parameters for all executions: · Manual Start/Stop. · Session time (defined / always
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