
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
Not far off . . . but you have 2 OrderClose calls there . . . you just need one of them, and add in a little more info to the print . .
So when we delete the first line and keep the second line, the second line will do the job of the first line in trying to close an order, plus it will print the information we need in case it could not do the job. Is that correct?
I had 10 short position and then had on long which closed the last 6 of those short at 1 price, before another long hit and close the first 4 at another single price. The error was 129. I did some research and found that it's about the price getting changed as I expected. https://docs.mql4.com/trading/errors
So as per jjc's suggestion, I replaced the Ask and Bid with OrderClosePrice(), and also saved one line of code like this.
Let's see how it is going to behave.
Meanwhile, since OrderClosePrice keeps calling some process which uses some additional resources that we don't need if the price doesn't move, I am wondering if there is a way to keep using Ask and Bid, but repeating the 'for' loop in case of the error. Perhaps by using the 'continue' keyword. Can you tell me what you think? If you agree, how can we do it?
What made me think of that is that as the counter is counting from top to bottom, I noticed that the first long order closed the last 6 short orders. It did not pick up orders randomly.
Your thought are appreciated.
Cheers,
I had 10 short position and then had on long which closed the last 6 of those short at 1 price, before another long hit and close the first 4 at another single price. The error was 129. I did some research and found that it's about the price getting changed as I expected. https://docs.mql4.com/trading/errors
So as per jjc's suggestion, I replaced the Ask and Bid with OrderClosePrice(), and also saved one line of code like this.
Let's see how it is going to behave.
Up until now, with OrderClosePrice(), the function has been closing all positions of the opposite direction no matter how many they are sometimes at 2 different prices. No other function is used like Refreshrates(). Your thoughts are welcome :)
6 shorts were closed closed at 1 price with 1 long, then 10 longs were closed at 2 prices (7+3) but with 1 short ... things like that.
I'd like to specially thank Raptor for continuous support, and Roeder, and the one from whom I learnt the most in this thread, jjc. Thank you all very much.
If someone still has a thought on this, they are very welcome. And I'd highly appreciate it if someone can help me with the other strategy here. No one has been able to do it as of now, although it is a straight forward kind of question (you can see my last post only).
Thank you,
tapo
Can you explain precisely what you are trying to achieve in regard to closing orders . . and can you show your code. Things have changed since your original post . . . .
Sure!
In regards to closing order, I'm done for now. The OrderClosePrice() function is doing a great job, although I'm still running the code on demo account form further testing observing its behaviour.
But on the other hand, I have created an RSI average strategy sample base on a simple RSI average indicator that I created earlier. I've the indicator to produce correct values, but the strategy is somehow producing correct values for RSI, yet wrong values for the average, even though the logic is the same! See my last post in this thread. There I have precisely explained what you're asking for posted both the indicator and strategy codes with a couple of screenshots. And should you want some more stuff, please let me know.
Your assistance appreciated :)
tapo
Your assistance appreciated :)
tapo
Sorry, I'm not good with Technical Indicators, the only RSI I know of is Repetitive Strain Injury ;-)