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
pinky:
Is there not a simple instruction that can be put at the start of the EA that just says "if active trades >0 then do nothing"?
Yes there is. Try OrdersTotal().
Yes there is. Try OrdersTotal().
Hi
No it's not an OrdersTotal() issue.
Please see the post before your one to see my code, this is how far I have got. I'm trying to just make no trades enter whilst there is any trade on, regardless of direction.
The moment no trades are on, it is free to enter a trade again.
Thanks
Pinky
ok, so this is what I have got (but still wont work although it compiles correctly now):
At the start of the EA:
Then in the block where the ordersend() is:
Then the actual ordersend looks like this:
It compiles fine, but still it doesn't do the job of only opening orders if no other order is active.
Any ideas?
You have two versions of int count and both are local so they are not the same . . . now you obviously don't know local scope from global scope so you either need to learn or get someone else to write your code for you.
If you declare int count globally and remove the two other declarations then your code may work . . .
Is it regardless of:
Magic?
Symbol?
Pending?
Time-Frame?
Manual Orders?
Placed By Another Ea?
Anything What So Ever?
If it's indeed Anything What So Ever then the last poster is correct. What you need is OrdersTotal(). It's a built-in function which already keeps the count of Any-Active-Order within the Terminal regular-less of Magic#, Symbol, Pending or Market, Time-Frame or Manually Entered.
So what you need is:
Use Whroeder's code when you have something you want to Filter like Symbol() for example.Yes.
You have two versions of int count and both are local so they are not the same . . . now you obviously don't know local scope from global scope so you either need to learn or get someone else to write your code for you.
If you declare int count globally and remove the two other declarations then your code may work . . .
RaptorUK: Yes I get it, global covers complete EA and local is only for a portion. I tried that and it just freezes on the strategy tester when it tries to enter a trade, so that doesn't solve it.
ubzen: it needs to take into account magic number and symbol, nothing else
TradeStation: come back, all is forgiven
LOL
Pinky
Lol.... This could take all day with guessing games. Just attach the code.
Thanks ubzen
Ok this attached is my original code with none of the extras I put in tonight. I've gone back to the beginning and started over with a new, fresh re-write. The other one was written with another EA writer and it was much more complex/longer coding and was getting on my nerves. I prefer this one, which was built with http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/
This is the code brand new as fresh. All I want to do is add in that chunk of code from page 1 of this thread and the extra command you gave me to make sure that it will not open a reversal trade while a trade is still active. This will correspond to the symbol and magic number only.
I'm really tired as it is midnight now and I have to be up early for work, so I'll have another go at this tomorrow when I get time. It's made my eyes hurt tonight!! LOL!
Any advice from my code you can give would be gratefully received.
Goodnight and thanks again!
Pinky
I tested with the following line.
The expert never placed an extra trade within the tester. It does allot of things wrong but thats not one of them.
Thanks ubzen
Ok this attached is my original code with none of the extras I put in tonight. I've gone back to the beginning and started over with a new, fresh re-write. The other one was written with another EA writer and it was much more complex/longer coding and was getting on my nerves. I prefer this one, which was built with http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/
Oh dear . . . here we go again. https://www.mql5.com/en/forum/139865
. . . why + 0 ? what is the point of that ?
You shouldn't use Bars, it is unreliable . . . etc. etc.