- Your posted code is without context, so we can only guess. That code is likely inside another function.
-
OrderSend(Symbol(),OP_BUY,LotSize,Ask-(Stoploss*Pips),Ask+(TakeProfit*Pips),NULL,MagicNumber,0,Green); if(OrdersTotal()==1) OrderSend(Symbol(),OP_SELL,LotSize,Bid+(Stoploss*Pips),Bid-(TakeProfit*P
- You buy at the Ask and sell at the Bid. So for buy orders you pay the spread on open. For sell
orders you pay the spread on close.
- Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Not the Ask. Your SL is shorter by the spread and your TP would be longer. Don't you want the same/specified amount for either direction?
- Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask
reaches it. To trigger at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 - The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (Control-O) → charts → Show ask line.)
- Magic number only allows an EA to identify its trades from all others. Using OrdersTotal/OrdersHistoryTotal
(MT4) or PositionsTotal (MT5), directly and/or no Magic
number filtering on your OrderSelect / Position select loop means your code is incompatible with every EA
(including itself on other charts and manual trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 programming forum
PositionClose is not working - MQL5 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles Your code Documentation OrderSend( Symbol(), OP_BUY, LotSize, Ask-(Stoploss*Pips), Ask+(TakeProfit*Pips), NULL, MagicNumber, 0, Green );
int OrderSend( string symbol, // symbol int cmd, // operation double volume, // volume double price, // price int slippage, // slippage double stoploss, // stop loss double takeprofit, // take profit string comment=NULL, // comment int magic=0, // magic number datetime expiration=0, // pending order expiration color arrow_color=clrNONE // color );
- Check your return codes for errors, and report them including GLE/LE
and your variable values. Don't look at GLE/LE
unless you have an error. Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Hello, I just started coding and I cannot solve my errors, could you please help me ?
the errors are : '{' - function definition unexpected 68 3
'}' - expressions are not allowed on a global scope 86 3
Hello, I just started coding and I cannot solve my errors, could you please help me ?
the errors are : '{' - function definition unexpected 68 3
'}' - expressions are not allowed on a global scope 86 3
Why have you posted your mql5 question in the mql4 section?
Do not make multiple posts with the same issue.
I have deleted your other posts.
-
This is what you wrote. See the problem?
//this is support and resistance to show the charts trend study("Support and Resistance", overlay= true) left = input(10) right = input(10) hih = pivothigh(high, left, right) lol = pivotlow (low , left, right) top = valuewhen(hih, high[right], 0) bot = valuewhen(lol, low [right], 0) res = plot(top, color=top != top[1] ? na : red, offset=-left) sup = plot(bot, color=bot != bot[1] ? na : green, offset=-left) }
-
Next time post your MT5 question in the MT4 section.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi There,
I would like to know were I have gone wrong. Attached below is the code. It is giving the error message FUNCTION DEFINITION UNEXPECTED.