I mean when I execute script, "close" for example, it never run well, and I get the information as below:
I want to know why and how i can use script usually?
Thank you!
See:
I mean when I execute script, "close" for example, it never run well, and I get the information as below:
I want to know why and how i can use script usually?
Thank you!
https://www.mql5.com/en/forum/141672
I have done that and i know your meaning, but the exact problem is no here.
I have write down i unit of program code which can work in EA but can't in script.
so why ?
Show your code.
int total=OrdersTotal(); Print("total:",total); for(int i=total-1;i>=0;i--) { Print("此时i 为:",i); OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderType()==0) OrderClose(OrderTicket(),OrderLots(),Bid,20,0); if(OrderType()==1) OrderClose(OrderTicket(),OrderLots(),Ask,20,0); else OrderDelete(OrderTicket(),0); }Thank you very much!
You can do this instead . . .
if(OrderType() == OP_BUY || OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 20, 0);
and it makes your code more readable if you use OP_BUY and OP_SELL. In relation to your original question your code looks OK. For an EA you can enable live trading in the EA Common properties dialogue box . . . you can't do this for a script unless you
#property show_inputs
The simpler method is to allow live trading in MT4 rather than in the script or EA. Have you done that ?
You can do this instead . . .
and it makes your code more readable if you use OP_BUY and OP_SELL. In relation to your original question your code looks OK. For an EA you can enable live trading in the EA Common properties dialogue box . . . you can't do this for a script unless you
The simpler method is to allow live trading in MT4 rather than in the script or EA. Have you done that ?
Perfect!
Thank you very much!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I mean when I execute script, "close" for example, it never run well, and I get the information as below:
I want to know why and how i can use script usually?
Thank you!