I am assuming this is supposed to be MQL5 code - in which case I suggest you read the documentation on the MT5 version of the OrderSend function as it is nothing like the MT4 version you have used here.
#include <Trade/Trade.mqh> // include Trade library for OrderSend function
this line currently does nothing, it would only be useful if you are using the Standard Library Trade Classes. Once again see the MQL5 documentation.
You are mixing MQL5 and MQL4 code! Which one is it — 4 or 5?
- "Trade.mqh" is part of the MQL5 Standard Library, but it is NOT necessary for using OrderSend.
- The OrderSend function is present in both MQL4 and MQL5, but its use and parameters are completely different:
for MQL5 — Documentation on MQL5: Trade Functions / OrderSend
for MQL4 — OrderSend - Trade Functions - MQL4 Reference

- docs.mql4.com
You are mixing MQL5 and MQL4 code! Which one is it — 4 or 5?
- "Trade.mqh" is part of the MQL5 Standard Library, but it is NOT necessary for using OrderSend.
- The OrderSend function is present in both MQL4 and MQL5, but its use and parameters are completely different:
for MQL5 — Documentation on MQL5: Trade Functions / OrderSend
for MQL4 — OrderSend - Trade Functions - MQL4 Reference
mt5
If you are using MT5, then you have two options ...
- an object oriented programming approach by using the Trade Classes of the MQL5 Standard Library.
- a imperative procedural programming approach by using the MQL5 version of OrderSend.
If you are using MT5, then you have two options ...
- an object oriented programming approach by using the Trade Classes of the MQL5 Standard Library.
- a imperative procedural programming approach by using the MQL5 version of OrderSend.
thanks guys
HI TEAM, i am facing almost the same challenge, I'm using MT5 platform, kindly assist.
1) 'OP_SELL' - undeclared identifier
2) 'OrderSend' - wrong parameters count - built-in: bool OrderSend(const MqlTradeRequest&,MqlTradeResult&)
input double LotSize = 0.2;
@Arif9696 Your code is for MT4 but seems you want to use it on MT5.
I strongly suggest to use CTrade classes and their semplified commands, documentation always help. At the moment it seems you only declared it but not used.
https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use