Alberto Tortella:
Hi all, is it correct this way to proceed?
I don't understand why sometimes the global varibale is properly stored, and other times no.
Thank you!
Hello,
try this part...
int ticket_long=-1;//set -1, not 0 if(ticket_long>-1) { if(OrderSelect(ticket_long,SELECT_BY_TICKET,MODE_TRADES)) { string Profit_Long_1 = StringConcatenate("Take_Profit_1_",OrderTakeProfit()); GlobalVariableSet(Profit_Long_1,Take_Profit_1_); } }
- Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. We can't see the rest of your broken code — we can only guess. Is ticket_long a static or global variable?
- Do you understand the mode is irrelevant when selecting by ticket? And it will select even if the order has 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.
Thank you
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
Hi all, is it correct this way to proceed?
I don't understand why sometimes the global varibale is properly stored, and other times no.
Thank you!