Yes!
The provided code seems mostly fine, but there's a small issue in how the stopLossPrice and takeProfitPrice are calculated for the sell trade. Since the stop loss for a sell trade should be set above the entry price and the take profit should be set below the entry price, you need to adjust the calculations accordingly.
Here's the corrected version of the code:
input double stopLoss = 1000; // Stop loss in points input double takeProfit = 2000; // Take profit in points input double lotSize = 0.01; // Lot size // ... (other code) void OnTick() { // ... (other code) else if (iClose(Symbol(), PERIOD_M5, 1) > iOpen(Symbol(), PERIOD_M5, 1) && iClose(Symbol(), PERIOD_M5, 2) < iOpen(Symbol(), PERIOD_M5, 2)) { // Bearish engulfing pattern detected, enter a sell trade double entryPrice = SymbolInfoDouble(Symbol(), SYMBOL_BID); double stopLossPrice = entryPrice + stopLoss * Point; // Adjusted calculation double takeProfitPrice = entryPrice - takeProfit * Point; // Adjusted calculation MqlTradeRequest request = {0}; MqlTradeResult result = {0}; request.action = TRADE_ACTION_DEAL; request.symbol = Symbol(); request.volume = lotSize; request.price = entryPrice; request.sl = stopLossPrice; request.tp = takeProfitPrice; request.type = ORDER_TYPE_SELL; request.type_filling = ORDER_FILLING_FOK; int ticket = OrderSend(request, result); if (ticket > 0) { Print("Sell trade opened at price: ", entryPrice); } else { Print("Error opening sell trade: ", GetLastError()); } } }I corrected the stopLossPrice and takeProfitPrice calculations for the sell trade to ensure that the stop loss is set above the entry price and the take profit is set below the entry price. This should resolve the compilation error you were facing. Hope this helps!
Here's the code: