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);
}
}
}
}
}
Similar orders
I’m looking for one person who is both a Forex trader and a programmer . I don’t want a coder who only writes code without understanding the market, and I don’t want a trader who can’t program. I want someone who actively trades and understands market behavior, liquidity, volatility, and risk management. Most importantly, the bot must be built using real artificial intelligence that learns and adapts , not just
can anyone help me with building a complete automated pine code strategy and indicator that work for both FXs & CFDs and have a high winning rate proved through back testing. I have a very complex current code that developed mostly using AI but lots of gaps are there although it translate exactly what I have in my mind. So, you are free to decide whether wo build a complete new code or fix my current working code ( i
Project Title: Convert Pinescript TradingView Strategy to MQL5 to EA bot Project Description: I am looking for an experienced MQL5 developer to convert a TradingView Pine Script strategy into a fully automated MetaTrader 5 Expert Advisor (EA). The goal is to have an identical replication of the strategy logic and backtest results. Key Requirements: Logic Conversion: Translate all Pine Script indicators, entry
Hello, I have the code for an indicator file that works with binary options. I want to make a simple modification to it that won't take much effort for professionals. In short, the modification I want is that if the strategy's conditions are met, a buy or sell signal should appear at 17:55. The strategy works exclusively on the 5-minute timeframe, and I want to delay the signal by 7 minutes so that it appears and
描述(项目概述): 我需要为 MetaTrader 5 平台开发一个功能完整的智能交易系统( 专家顾问 ),用于交易 XAUUSD (伦敦金)。该 艺电 的核心是基于一份详细的技术规格书,实现一个多指标共振、多层条件过滤的短线反转策略。 1. 核心策略逻辑简述: 交易品种与周期:主交易周期为 M30 ,需在代码内部动态读取 H4 周期进行趋势过滤,并监控 M5 周期以执行复杂的出场逻辑。 入场机制:采用 “ 价格触发 -> 成交量确认 -> 多指标渐进式达标 ” 的严格流程。入场信号需在特定时间窗口内,同时满足布林带突破及 5 个动量指标( CCI、RSI、MFI, 威廉指标, 随机指标)的超买 / 超卖条件,并受 H4 级别趋势过滤器约束。 出场机制:采用三层递进逻辑,包括动态保本移动、 M5 周期指标集体反转信号以及基于 K 线形态的趋势反转终极止损。
SMC, etc.) - Backtest results and the set files you used - Whether you’re willing to make minor tweaks so I can use it as my own If the performance looks good, we can discuss adjustments and next steps. My requirements are screenshot, backtes results, demo fileS Let me know if you have anything that fits the bill
iF you already have an successful MT4 EA for scalping in M5 XAUUSD [and eventually EURUSD and USDJPY] working essentially ON the trend when there is an Break Of Structure but also on reversal eventually with strategy Martingale with param ON/OFF eventually with strategy Grid with param ON/OFF eventually with HEDGING with param ON/OFF and on each trade : Stop loss, Trailing sl without High Frequency Trades [means
Hi all, I would like to get a bot that trades based on a Tradingview indicator. The indicator is called sniper entries. It is very simple. If the indicator says "BUY" then the EA buys, if the indicator says "SELL" then the EA sells. I want the bot to possibly trade forex market pairs like XAUUSD, EURUSD, GBPUSD. Would you please inform me what i need to do to make it possible. I also want the bot to trade on a small
Good day, I am searching the very high level expert, which could create the auto-trade robot and I would like to order the trading robot for GOLD XAU/USD auto-trade on MetaTrader. I could pay a lot for the institutional grade auto-trade robot, just contact me and let me know what level of the robot you could offer and we will negotiate the price
Hello. I am finding an experienced python developer who can implement my trading strategies into robots. I like trend-following swing trading strategies and am going to automate my idea. More details can be discussed by chatting. If you have similar working experience it can be a plus. Thanks