KevinDWORZAK:
Hi everyone,
I have this code :
The idea for me was to change it everyday with the levels I'm interested in for the day. The only problem I have is this one error '*' - open parenthesis expected 170325.mq5 73 35
Can anyone help me with this?
Hi everyone,
I have this code :
The idea for me was to change it everyday with the levels I'm interested in for the day. The only problem I have is this one error '*' - open parenthesis expected 170325.mq5 73 35
Can anyone help me with this?
Traders and coders are working for free:
- if it is interesting for them personally, or
- if it is interesting for many members on this forum.
Freelance section of the forum should be used in most of the cases.
NOTE: some details in your code are common for AI-generated, so it can be hardly helped (would need considerable human review/corrections before being usable in a live trading environment).
Trading applications for MetaTrader 5 to order
- 2025.03.17
- www.mql5.com
The largest freelance service with MQL5 application developers
KevinDWORZAK:
Hi everyone,
I have this code :
The idea for me was to change it everyday with the levels I'm interested in for the day. The only problem I have is this one error '*' - open parenthesis expected 170325.mq5 73 35
Can anyone help me with this?
Hi everyone,
I have this code :
The idea for me was to change it everyday with the levels I'm interested in for the day. The only problem I have is this one error '*' - open parenthesis expected 170325.mq5 73 35
Can anyone help me with this?
#include <Trade\Trade.mqh> CTrade trade; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ void OnTick() { double levels[] = {1.10394, 1.10204, 1.09714, 1.09388, 1.09280, 1.09082, 1.08892, 1.08762, 1.08547, 1.08357}; double price = SymbolInfoDouble(_Symbol, SYMBOL_BID); double entryPrice, stopLoss, takeProfit; double lotSize = 1.5; for(int i = 0; i < ArraySize(levels); i++) { if(price > levels[i]) { entryPrice = levels[i] * 1.0001; stopLoss = entryPrice * 0.9989; takeProfit = entryPrice * 1.009; for(int j = 0; j < ArraySize(levels); j++) { if(levels[j] > entryPrice && levels[j] <= entryPrice * 1.005) { takeProfit = levels[j]; break; } } if(!PendingOrderExists(entryPrice)) PlacePendingOrder(ORDER_TYPE_BUY_LIMIT, entryPrice, stopLoss, takeProfit, lotSize); } else if(price < levels[i]) { entryPrice = levels[i] * 0.9999; stopLoss = entryPrice * 1.0011; takeProfit = entryPrice * 0.991; for(int j = 0; j < ArraySize(levels); j++) { if(levels[j] < entryPrice && levels[j] >= entryPrice * 0.995) { takeProfit = levels[j]; break; } } if(!PendingOrderExists(entryPrice)) PlacePendingOrder(ORDER_TYPE_SELL_LIMIT, entryPrice, stopLoss, takeProfit, lotSize); } } } //+------------------------------------------------------------------+ //| Check if a pending order exists at the given price | //+------------------------------------------------------------------+ bool PendingOrderExists(double price) { for(int i = 0; i < OrdersTotal(); i++) { ulong ticket = OrderGetTicket(i); if(OrderSelect(ticket)) { ENUM_ORDER_TYPE orderType = (ENUM_ORDER_TYPE)OrderGetInteger(ORDER_TYPE); double orderPrice = OrderGetDouble(ORDER_PRICE_OPEN); // ✅ FIX: Separate calculations for clarity double diff = MathAbs(orderPrice - price); double threshold = Point() * 10.0; if ((orderType == ORDER_TYPE_BUY_LIMIT || orderType == ORDER_TYPE_SELL_LIMIT) && (diff <= threshold)) // ✅ Fixed parenthesis issue { return true; } } } return false; } //+------------------------------------------------------------------+ //| Place a pending order | //+------------------------------------------------------------------+ void PlacePendingOrder(int orderType, double entry, double sl, double tp, double lotSize) { MqlTradeRequest request; MqlTradeResult result; ZeroMemory(request); request.action = TRADE_ACTION_PENDING; request.type = (ENUM_ORDER_TYPE)orderType; request.symbol = _Symbol; request.volume = lotSize; request.price = entry; request.sl = sl; request.tp = tp; request.deviation = 10; request.magic = 123456; request.comment = "Auto Trade"; request.type_filling = ORDER_FILLING_FOK; request.type_time = ORDER_TIME_GTC; if(!OrderSend(request, result)) Print("OrderSend failed: ", result.comment); }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have this code :
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px 'Helvetica Neue'} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px 'Helvetica Neue'; min-height: 15.0px} #include <Trade\Trade.mqh> CTrade trade; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ void OnTick() { double levels[] = {1.10394, 1.10204, 1.09714, 1.09388, 1.09280, 1.09082, 1.08892, 1.08762, 1.08547, 1.08357}; double price = SymbolInfoDouble(_Symbol, SYMBOL_BID); double entryPrice, stopLoss, takeProfit; double lotSize = 1.5; for(int i = 0; i < ArraySize(levels); i++) { if(price > levels[i]) { entryPrice = levels[i] * 1.0001; stopLoss = entryPrice * 0.9989; takeProfit = entryPrice * 1.009; for(int j = 0; j < ArraySize(levels); j++) { if(levels[j] > entryPrice && levels[j] <= entryPrice * 1.005) { takeProfit = levels[j]; break; } } if(!PendingOrderExists(entryPrice)) PlacePendingOrder(ORDER_TYPE_BUY_LIMIT, entryPrice, stopLoss, takeProfit, lotSize); } else if(price < levels[i]) { entryPrice = levels[i] * 0.9999; stopLoss = entryPrice * 1.0011; takeProfit = entryPrice * 0.991; for(int j = 0; j < ArraySize(levels); j++) { if(levels[j] < entryPrice && levels[j] >= entryPrice * 0.995) { takeProfit = levels[j]; break; } } if(!PendingOrderExists(entryPrice)) PlacePendingOrder(ORDER_TYPE_SELL_LIMIT, entryPrice, stopLoss, takeProfit, lotSize); } } } //+------------------------------------------------------------------+ //| Check if a pending order exists at the given price | //+------------------------------------------------------------------+ bool PendingOrderExists(double price) { for(int i = 0; i < OrdersTotal(); i++) { ulong ticket = OrderGetTicket(i); if(OrderSelect(ticket)) { ENUM_ORDER_TYPE orderType = (ENUM_ORDER_TYPE)OrderGetInteger(ORDER_TYPE); double orderPrice = OrderGetDouble(ORDER_PRICE_OPEN); // ✅ FIX: Separate calculations for clarity double diff = MathAbs(orderPrice - price); double threshold = Point * 10.0; if ((orderType == ORDER_TYPE_BUY_LIMIT || orderType == ORDER_TYPE_SELL_LIMIT) && (diff <= threshold)) // ✅ Fixed parenthesis issue { return true; } } } return false; } //+------------------------------------------------------------------+ //| Place a pending order | //+------------------------------------------------------------------+ void PlacePendingOrder(int orderType, double entry, double sl, double tp, double lotSize) { MqlTradeRequest request; MqlTradeResult result; ZeroMemory(request); request.action = TRADE_ACTION_PENDING; request.type = (ENUM_ORDER_TYPE)orderType; request.symbol = _Symbol; request.volume = lotSize; request.price = entry; request.sl = sl; request.tp = tp; request.deviation = 10; request.magic = 123456; request.comment = "Auto Trade"; request.type_filling = ORDER_FILLING_FOK; request.type_time = ORDER_TIME_GTC; if(!OrderSend(request, result)) Print("OrderSend failed: ", result.comment); }The idea for me was to change it everyday with the levels I'm interested in for the day. The only problem I have is this one error '*' - open parenthesis expected 170325.mq5 73 35
Can anyone help me with this?