| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| MQL Empty4 CODE FOR PROFIT CHECK BEFORE CLOSE https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4678 |
Page 1 of 2 |
| Author: | keydcuk [ Wed Apr 06, 2016 11:36 am ] |
| Post subject: | MQL Empty4 CODE FOR PROFIT CHECK BEFORE CLOSE |
Dear Coders, Although I am not a coder myself, I do know the basics of computer language and how formulae work. I have been experimenting with an EA that I think does a wonderful job at what it does but closes some trades at a loss. Personally, I think this can be avoided but I don't know how to modify the code to do this. Is there anybody out there that has a piece of code that I could use in the close conditions that would tell the EA: If the sum of orders about to close is < 0 DON'T CLOSE or only close if the sum of orders about to close > 0? Many Thanks & Best Regards, Daniel |
|
| Author: | Radar [ Wed Apr 06, 2016 3:38 pm ] |
| Post subject: | MQL Empty4 CODE FOR PROFIT CHECK BEFORE CLOSE |
Hey Keydcuk, Sounds like you're looking for Basket Management... Check out Baluda's MPBM (Multi-Purpose Basket Manager), found here. Have fun! Radar =8^) |
|
| Author: | keydcuk [ Wed Apr 06, 2016 3:43 pm ] |
| Post subject: | MQL Empty4 CODE FOR PROFIT CHECK BEFORE CLOSE |
Hi Radar, Thanks for your help. It is not a basket manager I am looking for. It is actually code to set a condition before closing trades. Basically in this EA I am looking at, it chooses certain positions to close while leaving others open. The conditions of closing the group of trades have already been determined but even though most trade groups close profitable, a select few close at a loss. I was thinking to myself if there was a condition I could add to the existing code to only close a group of trades if the sum of the group is in profit, then I would drop this in the EA. Many Thanks & Best Regards, Daniel |
|
| Author: | Radar [ Wed Apr 06, 2016 5:22 pm ] |
| Post subject: | MQL Empty4 CODE FOR PROFIT CHECK BEFORE CLOSE |
Hey Keydcuk, So, your EA opens a bunch of trades, then eventually selects a sub-set of those trades to close at once, and you want a final filter (sub-set_total_profit) before closing them? If that sub-set fails the profit test, then what? Does it get broken up and a new sub-set created, or is the original one re-tested until it passes? The concepts from basket management can be applied to sub-sets (target profit, average profit, etc), but the implementation would need some massaging to fit. Break the EA down and find where it creates the sub-set... From there, we put those trades' ticket numbers into an array, and pass the array to a function to get their total profit... If there's enough profit, close those trades, and kill the array. If there's not enough profit then...? Have fun! Radar =8^) |
|
| Author: | keydcuk [ Wed Apr 06, 2016 10:54 pm ] |
| Post subject: | MQL Empty4 CODE FOR PROFIT CHECK BEFORE CLOSE |
Now your getting into something slightly complex for me. I don't know how to code MQL. I only know enough of how to read it because I have dealt with basic programming a couple decades ago when there was a dinosaur called a Commodore 64 You are right though. There is a set of trades that close under condition and they are suppose to close only at profit but at the moment they are not for some reason. It is too complicated for me to understand within the code of why this is not happening so I thought that I could filter out the closure with some sort of line that says if these trades closing don't close in sum for a profit, then don't close. I think due to the nature of the EA, the trades would keep going and eventually fall into meeting a closure condition under profit, but you have given me something to think about. "What happens after the check and if it fail?" I can assume what I just stated but it might not work. I don't know. Maybe it's not as simple as I would have hoped it to be. Thanks anyway, Daniel |
|
| Author: | Radar [ Thu Apr 07, 2016 10:20 am ] |
| Post subject: | MQL Empty4 CODE FOR PROFIT CHECK BEFORE CLOSE |
Hey Keydcuk, I'll pull out some of my old code and modify it over the next few days... It'll work on the assumption that the sub-set is created on each loop of the EA, so it will create & populate the array, do the test, and close the trades if required. Whether the trades are closed or not, it will kill the array, ready for the next loop. You'll just have to plug it in (unless you want to post the EA either here or in a PM). Have fun! Radar =8^) |
|
| Author: | keydcuk [ Thu Apr 07, 2016 11:31 am ] |
| Post subject: | MQL Empty4 CODE FOR PROFIT CHECK BEFORE CLOSE |
Thanks for your help. It is greatly appreciated! |
|
| Author: | Radar [ Thu Apr 07, 2016 2:03 pm ] |
| Post subject: | MQL Empty4 CODE FOR PROFIT CHECK BEFORE CLOSE |
Hey Keydcuk, Code's done! First off add this to your external variables.. Code: Select all Code: Select all Code: Select all Code: Select all Straight after the testing loop, put the following... Code: Select all Have fun! Radar =8^) |
|
| Author: | keydcuk [ Thu Apr 07, 2016 6:00 pm ] |
| Post subject: | MQL Empty4 CODE FOR PROFIT CHECK BEFORE CLOSE |
Thanks again. I did try this and couldn't get it to work. I think that I will take your advice in the PM you sent me and leave it with the experts that are working on this. Cheers! Daniel |
|
| Author: | pascalx [ Fri Apr 08, 2016 11:14 am ] |
| Post subject: | MQL Empty4 CODE FOR PROFIT CHECK BEFORE CLOSE |
Code: Select all |
|
| All times are UTC | Page 1 of 2 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|