My EA only seems to place buy orders. I need a helping hand so it can place both buy and sell orders!

Back to topics list  | 1 2 To post a new topic, please log in or register
avatar
1325
jjc 2015.03.18 00:51 #
 
BartWinter:
jjc upon testing the code it works for opening trades but it doesn't close them when the MAs cross over again. I'm sorry to take more of your time but do you think you could have a look at the code to see if the problem can be deduced.

I can't immediately see a problem in the code around order closure. I have also tried running the code above - after zeroing out the problematic Stoploss values in the OrderSend() - in the MT4 strategy tester, and it closes both buy and sell positions.

I haven't inspected the code thoroughly to see whether it's closing positions when intended, but if it isn't closing them at all then I'd look for logic errors introduced for any further modifications you have made. For example, the code as exactly posted above doesn't compile because there is a missing }. If you have edited it incautiously, then you might have done something such as making the entire trading logic part of the block controlled by if(OrdersTotal()<MAX_ORDERS), which would mean that nothing at all further happens once three simultaneous positions have been opened.

If that's not the explanation then the key question is whether the OrderClose() is failing, and your Print() statements are generating messages in the log, or whether nothing is getting logged and therefore the OrderClose() isn't getting called at all.

avatar
18
BartWinter 2015.03.19 17:54 #
 
Thanks a lot for you help. I will have a look to see what I can do.
Back to topics list   | 1 2  

To add comments, please log in or register