Need help with OrderMagicNumber Please!!!!

 
Hello I need help with eliminating opening more than 1 position by my EA, I want to do something like this if(Ordertotal(OrderMagicNumber(012345))!=0) But it does not working! Please can somebody help me????


 
gorbi97:
Hello I need help with eliminating opening more than 1 position by my EA, I want to do something like this if(Ordertotal(OrderMagicNumber(012345))!=0 But it does not working! Please can somebody help me????

Have a look at the documentation and you will find:

- Its OrdersTotal() - not Ordertotal()

- The OrderTotal() function accepts no parameters and returns the total number of open and pending orders in the account context

So, following your logic, you will need to construct a loop which loops through the open orders and in that loop you will check the magic number, add to a counter, decide which surplus order to kill etc.


Me- I'd just maintain a bool called OrderPermitted or similar, set it to false once you've opened your order and set it to true when you've closed it. Job done.

You're over-complicating things with magic numbers if you're only managing one order in your EA.


Do try to read the docs.


And let me know how you feel about this logic, and how you get on with it.