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
We don't know what you are trying to do
If you only want one open trade at a time, check that there are no open orders before sending a new one.
If you only want one trade per bar, only test once per bar
If you want a combination of conditions, test the combination.
I explain here:
I have maximum 6 support & 6 resistance for each hour. It can be 2 support & 2 resistance or anything but maximum 6 support & 6 resistance for each hours.
I want to open limit order those S/R levels on start of the each hour.
I created one buy function & one sell function...so that I dont need to write down the same buy/sell code for total 12 S/R levels.
Now. when I used this following code:
It creates multiple same orders:
I used WHRoeder code too. In a seperate function. As i can't declare function within a function.
Your problem is not the function that you have posted, your problem is in the code that calls the function.
Obviously there is no check to see if the orders have already been placed
Your problem is not the function that you have posted, your problem is in the code that calls the function.
Obviously there is no check to see if the orders have already been placed
code for calling function (snapshot)
How to check that orders have been already placed or not? With buyticket > 0 conditions?
code for calling function (snapshot)
How to check that orders have been already placed or not? With buyticket > 0 conditions?
It is difficult to give advice as I don't know what you are doing at the end of the hour with un-triggered orders and how you are managing triggered orders.
You could create a globally declared array (or 2) and store the ticket numbers for the open orders. Before opening a new order, check the array element that corresponds to the level for a value >0.
Of course, you will also need to check the ticket numbers and if you delete un-triggered orders, set the array element to 0. You may also need to check if the order has closed and depending on your logic, re-set it to 0
It is difficult to give advice as I don't know what you are doing at the end of the hour with un-triggered orders and how you are managing triggered orders.
You could create a globally declared array (or 2) and store the ticket numbers for the open orders. Before opening a new order, check the array element that corresponds to the level for a value >0.
Of course, you will also need to check the ticket numbers and if you delete un-triggered orders, set the array element to 0. You may also need to check if the order has closed and depending on your logic, re-set it to 0
As I set expiry levels of Un-triggered orders, it get expired at 0:59 or 59th minute. For Triggered order SL & TP are set.
Previously I designed Ea which takes one either buy or sell order in each hour.. no problem code was simple. But here it seems very difficult.
Ok, i will try to code it as you said. If problem arise I will post here. Plus it will be good if you can share any simple code example for counting ticket number.
Thank you for your suggestion.
I solved my problem temporarily with this following code & running it on Hourly chart. Simple
Bars is unreliable (a refresh/reconnect can change number of bars on chart) volume is unreliable (miss ticks) Always use time. New candle - MQL4 forum
Thank you for the code. I added it on Tick function. But now my EA is not taking any trades. As I use buycall/sell call function for placing pending orders. I couldn't add this function inside the function.
Any Idea?
Plus the reverse trade on stopped orders is also not working.
Any highlight on the reverse code? why its not working?
Thank you.