You are trying to declare a function inside a function (OnTick here). This is not possible. Do the declaration outside on the global scope.
double GetSwap() { double swap=0.0; if (SymbolInfoDouble(_Symbol,SYMBOL_SWAP_LONG) < 0) { // go through all open BUY positions for _Symbol and add swaps here } return swap; } void OnTick() { ...
And think about negative swap for SHORT positions.

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
Hello Great people,
I am new to coding. I attempted to write a code for a simple expert advisor (MQL5) to return the value 0, if the swap on a long position (or series of long positions) is positive. If the swap is negative, the EA should retrieve, add up all the negative swaps of all Buy positions (for the symbol) and return the result. E.g -1.08 (Position1 swap) + -0.64 (Position2 swap) = -1.72 (Total negative swap). While compiling, I keep getting the errors: 1. unexpected end of program and 2. unbalanced parenthesis.
My code is as follows:
Kindly help take a look at this.
Thank you.