Unexpected end of program and unbalanced parentheses in my code
Please EDIT your post (don't create a new one) and post your code properly (and eliminate any unnecessary empty lines) ...
Joaquín Defranza: Hey I wrote this code that I thought it would be simple but I'm having this two errors (Unexpected end of program and unbalanced parentheses) and I don't know how to solve it. This is my first code so if someone could help me I would be so grateful. It's a MQL5 code. I let the code here and in files. Thanks :)
Here are some tips ...
// This EA will open a buy order when the price of the asset falls at least 5 points, // take profits when there are 4 points of profit and set a stop loss at 5 points of loss. //inputs: extern double takeProfit = 4.0; extern double stopLoss = 5.0; //variables double openPrice; // <- Uninitialised global variable // OnTick function void OnTick() { // Get the current price double currentPrice = MarketInfo(Symbol(), MODE_BID); // <- This is MQL4 code, not MQL5 code // Check if the open price has been set if (openPrice == 0) // <- using a variable before it is initialised { // Check if the price has fallen at least 5 points if (currentPrice < (openPrice - 5.0)) { // Open a buy order openPrice = currentPrice; OrderSend(Symbol(), OP_BUY, Lots, currentPrice, 0, 0, 0, "My EA", 0, 0, Green); // <- This is MQL4 code, not MQL5 code } } // Check if there is an open position if (PositionSelect(Symbol())) { // <- You were missing the code block braces // <- Where is the rest of the code? } // <- You were missing the code block braces } // <- You were missing the closing brace for the OnTick()
However, there are still errors after correcting the braces, mainly because of the unrecognised MQL4 code ...
That's MQL4 not MQL5, in MQL5 there is no MarketInfo function, OP_BUY, and OrderSend doesn't work in the same way

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
Hey I wrote this code that I thought it would be simple but I'm having this two errors (Unexpected end of program and unbalanced parentheses) and I don't know how to solve it. This is my first code so if someone could help me I would be so grateful. It's a MQL5 code.
Thanks :)