- wout_753: I dont know how to fix this.Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
-
if(OrderSelect(openOrderID,SELECT_BY_TICKET)==true){
You select by ticket. What happens if the ticket has already closed? - EAs must be coded to recover. If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static/global ticket variables will have been lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover? Use a OrderSelect loop to recover, or persistent storage (GV+flush or files) of ticket numbers required.
-
stopLossPrice = entryPrice - maxLossInPips * 0.0001;
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.)
- PIP, Point, or Tick are all different in general.
What is a TICK? - MQL4 programming forumUnless you manually adjust your SL/TP for each separate symbol, using Point means code breaks on JPY pairs, exotics (e.g. USDZAR where spread is over 500 points,) and metals. Compute what a PIP is and use it, not points.
How to manage JPY pairs with parameters? - MQL4 programming forum
Slippage defined in index points - Currency Pairs - Expert Advisors and Automated Trading - MQL5 programming forum
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
Okay so I have created my first expert advisor and whenever my order is being send it gets deleted automatically. Like in this screenshot I provided.
Okay so this is the expert advisor. I'll also include the file of the CustomFunctions01.mqh
CustomFunctions01.mqh:
I hope someone can help because I dont know how to fix this. Thanks in advance!