Closing all open trades automatically results in losing price value even when the difference is positive profits - page 4
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Well didn't it occur to you that I have modified the code SINCE the thread has finished (thanks to Seng)?
Why should it have occurred to me?
What person in their right mind would continue to argue that their function is perfect as it was after they have found that they need to modify it?
At least you have finally admitted that your function needed improvement.
Why should it have occurred to me?
What person in their right mind would continue to argue that their function is perfect as it was after they have found that they need to modify it?
At least you have finally admitted that your function needed improvement.
"Why should it have occurred to me?"
Obviously it didn't. My goodness gracious this bloke.
"What person in their right mind would continue to argue that their function is perfect as it was after they have found that they need to modify it?"
What person in his right mind would continue to rant and wail on a thread that's already been solved? :-D:-D:-D:-D:-D
"At least you have finally admitted that your function needed improvement."
But of course! That's the reason I came to this forum in the first place. Otherwise if it's immaculate, why should I seek assistance? Back read. Did I just
told this thread it was the last step I was having issues about??
Basic. dude. ;-) :-D
The problem with you is you're way out of topic now. I got what I need, I thanked you for your efforts, and you keep on priding with your "perfect" coding.
What did I tell, you? I GOT WHAT I NEED. I DON't NEED YOUR CODE NOW. I don't care if you have the god code with you! Maybe later, but not now.
I got what I came for. It just happened it was not your solution. Do I need to speak in Parables?
You don't sound like a broken record - YOU ARE a broken record.
I will bet your life you are gonna reply to this thread again. A thread that is already done and closed as far as I am concerned. I'M SURE OF IT. You are itching now.
Here he goes again, in 3, 2, 1................ 3:) :-D :-D :-D
I repeat
What person in their right mind would continue to argue that their function is perfect as it was after they have found that they need to modify it
No, the error that Keith highlights is about the use of wrong prices for closing different order types. Remember I mentioned that you should use Bid when closing Buy, and Ask when closing Sell, and Keith suggested using OrderClosePrice() - which will insert the right Ask / Bid for you?
Your code uses either Ask or Bid to close all orders, due to the calling of OrderType() before OrderSelect().
It worked for you, because your spread happened to be 13, and you call OrderClose() with a slippage of 15. However, you'll encounter error when your spread is more than 15, or you call OrderClose() with a slippage of less than 13 - you can try that out.
Thank you Seng - a voice of common sense.
I repeat
Now, let's see if you can let it goI knew it! You are itching hehehehehehe!!!
What person in his right mind would continue to argue about their "perfect" program when the OP has already got their answers for their own needs and not bothering about the argumentator's "perfect" code.
Some god you must be. Perfect Code. Right.
Now, let's see if you can let it go!
In 3, 2,..... 3:)
Thank you Seng - a voice of common sense.
Seng (Not You Keith :-D, be quiet and listen >:P):
You are right when you said about the swap and commissions - I know the "perfect" dude is insisting on his OrderClosePrice() approach which I clearly insists that I opt not to use if an external library for that code uses it. BUT THEN AGAIN, I clearly stated I will plan to adopt that on my other project - just NOT on this code I'm working right now. Now you mentioned about the Swap ad Commissions, that's EXACTLY what I am missing. You gave the right suggestions for me to look at; all's OK, I'm satisfied, thanked you for that, CASE CLOSED.
Now the other guy can't get over inisisting his code is "far superior" to mine's.
What did I say?
"I don't care!"
Now backread for the rest of the story Keith (yeah, that's you now I'm talking to.) ;-)
You may have the best code in the world, but ....arrrrgghhhhh............. didn't I just said I got the answer to my issues and thanked you for your effort? Now move on. You made a valid suggestion, but I got the missing link already. Couldn't you just respect another person's choice of NOT choosing your way (whether you are wrong or otherwise)? You are forcing me to repeat the very same thing I've just mentioned above the threads, my golly. Let me just copy paste what I said again the last time:
"When someone disagrees with you, respect their stance. If you want to feel right about yourself, feel free to do so."
...Then don't force yourself on others ;-).
You may be the best programmer in the world, but I know what I want, - and it just happened to be not what you are fighting for.
Again, - again! - I'm not saying your suggestion sucks, I just moved on to another route of my mission. That's my choice. *Respect* that.
I don't care how wrong or right you are, this thread should have been closed, but you keep on whining like a baby about your perfectly engineered code. My goodness, it is perfect! That's Amazing!! Definitely the finest of the breed! #ClapClap - But I already got the other answer that I'm looking for, and it's not yours unfortunately.
I don't care if I need to further improve my own program or not, I don't expect it to be perfect and neither are yours, and why should you care?
If you want further answers - just backread. Because I'm not hitching a ride on the merry-go-round with you. ;-)
Well didn't it occur to you that I have modified the code SINCE the thread has finished (thanks to Seng)?
You are looking at an outdated code! :-D :-D :-D
Don't feel bad because I didn't follow your advice. We are all free to pick the ones we want to eat.
Now, go back to bed, and close the thread. ;-)
Could you post the last updated code ? So every future reader can benefit from it.
Surely Alain!
Here it is:
Don't mind the clutter of Prints. It's just my way of visualising the program flow. Essentially the logic is the same. Error checking and alerts are scattered all around the rest of the code, regardless of what it is. It's the swap and commissions I missed that was advised by Seng to me, you can backread the details. With the last part,I observed that most of the coders who do OrderClose on this forum and anywhere just use the Bid and Ask on their code, and I found out that's simple enough tweak for me (NOTE: I had one of my programmers check the 'prized' OrderClosePrice() the mod dude has been peddling and guess what - it doesn't need that stdlib at all upon testing :-). I could have used it, but my mixed clients of Finance gurus and IT guys decided my error checking to give them a bit of 'manual control' would be perfect enough for them; they have the gold, it's their rules, their decision, and I'm happy to get paid for it ;-)).
As I don't claim Divine Power over my code and I expect errors *always* along the way (who doesn't?), you are free to backtest that snippet and always, *appreciate* your valuable inputs. Whether I will use the suggestions or otherwise today or tomorrow, is a business decision that will be another matter entirely. I hope that clear things up for our readers. I'm new to MQL4 so I'm a 100% certain you guys are the best in your field of expertise, the reason I came here in the first place.
And with that, I hope this brings a final closure to a long foregone conclusion for me. I appreciate the tips/advice on the pros and cons of my approach/es, but my clients' decision will always comes first. Being more of a businessman than a tech guy myself, I just follow the money trail. ;-)
tompips2018:
(NOTE: I had one of my programmers check the 'prized' OrderClosePrice() the mod dude has been peddling and guess what - it doesn't need that stdlib at all upon testing :-).
You just can't leave it can you. You have to make yet another snide remark aimed at me. I am sure that most people just think that you are making yourself look foolish now.
I won't point out the glaringly obvious errors in your CloseAll function. I am surprised that nobody else has yet. Maybe they can't be bothered after seeing how you treat people that have only tried to help you.
Why on Earth would you think that OrderClosePrice() requires that you use stdlib? You don't have to use it, you can just print the error code.
I am pleased that you took note of my comment on your code and moved BuyOrSell into the loop where it should be.
What's wrong with "I had one of my programmers check the 'prized' OrderClosePrice() the mod dude has been peddling and guess what - it doesn't need that stdlib at all upon testing :-)."
Can't get over it? Did I hit a nerve? In fact I was saying I'm planning to use it. But business decision decides otherwise. So what's your problem with it? Are you the one paying for my services? Are you my client? ;-) :P :-)
If your ego get's bruised I'm so sorry it wasn't my intention. You have to look at it objectively. Everybody here got quiet already, you're the only one ranting and wailing. It's already a done deal. GET OVER IT.
It looks like you ain't backreading. I think that's the reason you keep on wailin'. C'mon, it's not that bad.
Let me tell you a bit about an open letter about the 'Powerdrill':
"Dear Neighbour,
I see you read my notice asking to borrow a tool for my woodwork. I also saw that you left your power drill at my doorstep for me to use. Your power drill does wonders with its multi-features and I am very sure it is something to be desired and to own.
However, the other guy next door already lend me his crude hand drill that despite its limitations, does the job that I wanted.
I am now done with my woodwork. Thank you for your offer, but right now I have no need of your power drill, but rest assured I will consider to borrow it sometime in the near future.
Thanks again.
Cheers!"
Hope that makes you feel better. That's all there is to it. No need to elaborate. Don't take it too personally. You may go to bed now. :-)