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
Print your variables before and inside if statements and find out why.
Ok thank you, I will do that and research this more. I also found this bit of code which intrigues me because the SL and TP is separated from OrderSend. Will look into this as well
Hi Everyone
I have fixed most of my issues and the EA works fine in the tester, but I'm still having issues with OrdersTotal. In Demo mode it will sometimes open both pending Stop orders, but most of the time only the buy or the sell. I want both pending orders to open at the same time (within a few seconds), but only if no other orders or pending orders are open. I think what happens is that sometimes it opens both pending orders before it has a chance to calculate the number of orders, and other times it actually realize that a pending order got send, and won't open the other one. I thought that if I put the Ordersends within curly brackets it will excecute both when the if condition is met? I also now know that it will continue to open pending orders when I delete them for as long as the last candle is being formed, i.e. as long as the Time variable matches the Time[0] candle, ticks are irrelevant.
Here is that bit of code:
So is there a better or easier way for me to do this? Thank you
Hi Everyone
I have fixed most of my issues and the EA works fine in the tester, but I'm still having issues with OrdersTotal. In Demo mode it will sometimes open both pending Stop orders, but most of the time only the buy or the sell. I want both pending orders to open at the same time (within a few seconds), but only if no other orders or pending orders are open. I think what happens is that sometimes it opens both pending orders before it has a chance to calculate the number of orders, and other times it actually realize that a pending order got send, and won't open the other one. I thought that if I put the Ordersends within curly brackets it will excecute both when the if condition is met? I also now know that it will continue to open pending orders when I delete them for as long as the last candle is being formed, i.e. as long as the Time variable matches the Time[0] candle, ticks are irrelevant.
Here is that bit of code:
So is there a better or easier way for me to do this? Thank you
Are you checking the value of buystop_ticket and sellstop_ticket ? If there is only 1 open, the second will never be open (unless you remove the first manually).
Thank you for the reply. Actually both buystop and sellstop orders open about 50% of the time. The other 50% of the time either the buy or sell get send. But I did find something out. I asked for the last error and on those occurences where both get send, there are no errors, but when only one opens, I get error 130 on the one that did not open. So it appears as if my stops are invalid, but I don't know why. Here is the code for SL:
Also I added the Print function. Is that what you meant with "Are you checking the value of buystop_ticket and sellstop_ticket ? "? It returns two values namely:
2016.03.24 17:11:22.532 News_v10 GBPUSD,M1: Buystop ticket =-1
2016.03.24 17:11:23.227 News_v10 GBPUSD,M1: Buystop ticket =49644335
When ECN brokers started, the OrderSend would fail with SL/TP set. Most have fixed this since build 600.
Thank you for the reply. Actually both buystop and sellstop orders open about 50% of the time. The other 50% of the time either the buy or sell get send. But I did find something out. I asked for the last error and on those occurences where both get send, there are no errors, but when only one opens, I get error 130 on the one that did not open. So it appears as if my stops are invalid, but I don't know why. Here is the code for SL:
Also I added the Print function. Is that what you meant with "Are you checking the value of buystop_ticket and sellstop_ticket ? "? It returns two values namely:
2016.03.24 17:11:22.532 News_v10 GBPUSD,M1: Buystop ticket =-1
2016.03.24 17:11:23.227 News_v10 GBPUSD,M1: Buystop ticket =49644335
You need to add RefreshRates() between your 2 OrderSend().