Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
Messages Editor
- Andrew Terhune: but having an issue with order tracking.
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. What issue?
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problem -
double long_tp = current_close + (atr*6); double long_sl = current_close - (atr*2); ticket = OrderSend(_Symbol,OP_BUY,0.01,Ask,1000,long_sl,long_tp,"This is a buy",1,0,clrCrimson);
Why are your TP/SL relative to some variable instead of the Bid?
-
Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5/MT4+strict), it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum (2012)
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles (2014)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This was previously based on the logic of closing the previous position upon opening the last position, it was working as expected before i added the sl and tp values. I am not sure how i should reset the ticket variable to 0 in the event of a sl or tp, or if there is a different way i should be handling this.