I have moved your topic to the MQL4 and Metatrader 4 section.
Also, in your code,
Always use
#property strict
When starting a project use the "New" button top left of the editor. #property strict will be included automatically.
If the compiler issues a warning don't ignore it, fix it.
OrderSend(); //may give you the error that the return value of OrderSend should be checked. The minimum that should be done is to print the error if it fails //preferably also print the open price, TP, SL. int ticket=OrderSend(_Symbol,OP_BUY,0.1,Ask,20,0,0,NULL,12345,0,clrNONE); if(ticket==-1) { Print("OrderSend for Buy order failed with error code ",GetLastError()); }
ishf fady: I am new and trying to learn programming Expert Advice. I have simple EA and it is running fine. eg
ticket = OrderSend(_Symbol, OP_BUY, lots, Ask, 100, stopOrder, orderTarget, "Buy Order", 1,0, clrGreen);
How do capture or find out when StopOrder or ProfitTarget get trigger on a given order. I would like to let reset the value to ticket.
For that ticket, select the order and check its Closing Time. If it is non-zero, then it has been closed. You then check the Closing Price and see if it is closer to the S/L or closer to the T/P. I say closer because due to slippage, it can be and usually is different.
Since your example code is for MQL4, have a look at the documentation of OrderSelect, OrderCloseTime, OrderClosePrice (just follow the links).
- 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
I am new and trying to learn programming Expert Advice.
I have simple EA and it is running fine. eg
ticket = OrderSend(_Symbol, OP_BUY, lots, Ask, 100, stopOrder, orderTarget, "Buy Order", 1,0, clrGreen);
How do capture or find out when StopOrder or ProfitTarget get trigger on a given order.
I would like to let reset the value to ticket.
Please can someone advice.
Kind regards
ish