Forex Factory (https://www.forexfactory.com/forum.php)
-   Platform Tech (https://www.forexfactory.com/forumdisplay.php?f=69)
-   -   Maximum overkill Close-All script (https://www.forexfactory.com/showthread.php?t=716973)

Nicholishen Nov 22, 2017 9:15am | Post# 1

Maximum overkill Close-All script
 
2 Attachment(s)
The goal of this script is to minimize risk in all situations, especially when the shit hits the fan. This script provides the best and the fastest possible risk mitigation available thru MT4 by utilizing some unique logic not found in any other close-all scripts.

Operation Summary:

  1. Net positions are calculated per symbol (sum of all open trades).
  2. Symbols are prioritized to manage net-positions from larger (more risk) to smaller.
  3. Hedge orders are sent in the order of priority to close all exposure at once regardless of the number of trades.
  4. Once all open-expo is hedged the program prioritizes pending orders
  5. Pending orders are deleted in order of highest risk of being executed
  6. Remaining hedged positions (closed by hedge) are then reconciled on the broker server and there are no costs/spread/commissions charged on the hedge (it is literally treated like a closed position)

Note: This only works on non-FIFO hedging brokers. I have also included a different script that closes orders on FIFO brokers (slowww compared to hedging brokers).
You may also like the Hedge Trade Panel
FIFO_CloseAll_Options.mq4
HedgeAccountCloseAll.mq4


rosalieone Nov 23, 2017 9:40am | Post# 2

Interesting, thanks !

Jj1357 Aug 28, 2018 1:12pm | Post# 3

Very good thanks. But it would be better in the form of EA

tzamo Aug 28, 2018 10:59pm | Post# 4

Dear Nicholishen,

Many thanks again for providing these. I am just wondering, for the brokers that charge upfront full commissions, eg. $7 per lot as soon as the trade is opened and don't charge on close of that trade. If hedging trades are opened, would you still lose the extra commission fee?

Kind Regards,
Tzamo

Nicholishen Aug 28, 2018 11:22pm | Post# 5

Dear Nicholishen, Many thanks again for providing these. I am just wondering, for the brokers that charge upfront full commissions, eg. $7 per lot as soon as the trade is opened and don't charge on close of that trade. If hedging trades are opened, would you still lose the extra commission fee? Kind Regards, Tzamo
It's important to understand the difference between closing offsetting orders separately vs. closing them using closeby.

When you close offsetting orders separately: you get charged twice; once for each individual order.

When you use closeby: your platform will show individual orders with separate commissions while they are open, however, closeby sends a special command to the broker server to reconcile the offsetting orders like an options deal. That is, one order was OPEN and the second was CLOSE. It will then be reconciled as a round-trip trade and you're only charged one commission.

Jj1357 Aug 29, 2018 7:17am | Post# 6

What is the difference between HedgeAccountCloseAll.mq4 and HedgeAccountCloseAll__2.mq4?

Nicholishen Aug 29, 2018 1:18pm | Post# 7

What is the difference between HedgeAccountCloseAll.mq4 and HedgeAccountCloseAll__2.mq4?
No offense, but the source code is all there and you should be able to run a diff and see for yourself.

Jj1357 Aug 29, 2018 4:18pm | Post# 8

I do not know what a diff is

Do not you want to tell what the difference is? Are yours.

Nicholishen Aug 29, 2018 4:46pm | Post# 9

I do not know what a diff is Do not you want to tell what the difference is? Are yours.
No. I am not interested in taking time to explain it, and I posted the source codes so you can modify it however you want. You can do a diff on the files and spot the changes yourself. If you don't know how to diff you can try here.

Jj1357 Aug 29, 2018 5:11pm | Post# 10

But what interests me is whether the two are equally reliable.

Jj1357 Aug 31, 2018 5:59am | Post# 11

He does not want to talk about this topic

Nicholishen Aug 31, 2018 9:04am | Post# 12

He does not want to talk about this topic
I'm happy to talk concepts and theory with you, however, I find your query to be extremely trivial. Even a junior level developer should know how to diff two files, and I just don't feel like using my time to hold your hand through something you should be able to figure out on your own. I'm sorry if that sounds harsh but you are digging through source code, and you should know how to read it before asking questions that you likely won't understand the answers to.

If you have a specific question about the script's operation then please ask it, but I won't be offering classes on how to diff, ITT. Thanks.

Jj1357 Aug 31, 2018 10:47am | Post# 13

{quote} I'm happy to talk concepts and theory with you, however, I find your query to be extremely trivial. Even a junior level developer should know how to diff two files, and I just don't feel like using my time to hold your hand through something you should be able to figure out on your own. I'm sorry if that sounds harsh but you are digging through source code, and you should know how to read it before asking questions that you likely won't understand the answers to. If you have a specific question about the script's operation then please ask...
You say: "extremely trivial" and "you likely won't understand the answers to"
I'm not a developer.
I'm not investigating the source code.
I just want to know what is the best script.
And nothing more.

Nicholishen Aug 31, 2018 11:31am | Post# 14

Use the one in the OP.

Jj1357 Aug 31, 2018 11:42am | Post# 15

Use the one in the OP.
What is the OP?

VEEFX Sep 1, 2018 12:50am | Post# 16

{quote} You say: "extremely trivial" and "you likely won't understand the answers to" I'm not a developer. I'm not investigating the source code. I just want to know what is the best script. And nothing more.
Then be nice to someone who is freely sharing the source code of his effort
This shit takes time and effort to develop and test. And you are a complete noob to trading and to forums.

{quote} What is the OP?
OP = Opening Post i.e. the very first post in the thread. It is also refered to the thread starter/owner

Jj1357 Sep 1, 2018 7:34am | Post# 17

{quote} Then be nice to someone who is freely sharing the source code of his effort This shit takes time and effort to develop and test. And you are a complete noob to trading and to forums. {quote} OP = Opening Post i.e. the very first post in the thread. It is also refered to the thread starter/owner
I just asked a question!
Surely I am more profitable than you

Nicholishen Sep 1, 2018 8:58am | Post# 18

{quote} Then be nice to someone who is freely sharing the source code of his effort This shit takes time and effort to develop and test. And you are a complete noob to trading and to forums. {quote} OP = Opening Post i.e. the very first post in the thread. It is also refered to the thread starter/owner
I'm pretty sure this is a sockpuppet account of someone on my ignore list. Welp, they're back on it and won't be trolling my threads anymore...

VEEFX Sep 1, 2018 1:32pm | Post# 19

{quote} I'm pretty sure this is a sockpuppet account of someone on my ignore list. Welp, they're back on it and won't be trolling my threads anymore...
Yep. The swamp keeps growing with very few good guys left here to interact with.
When I ignore, many times, their buddies circle also go to the gutter :-)
Look around man. Every idiot is popping ex4 just about everyday with no evidence of any track record and noobs are jumping right on it willing to test without even understanding the inner workings of how the code was developed. They will never succeed in life if they depend on someone else to tell them how to trade. It's just a sad state of affairs that forums spread.

Keep up the good work brother. We need more guys like you around here!

MoneyZilla Sep 11, 2018 12:04pm | Post# 20

2 Attachment(s)
This is amazing work by Sir Nico.

Pity traders here do not recognize it.

Here is a small contribution by me.

Close All Pairs button is Sir Nico's super mighty close by hedging script, as a button inside this EA.

Not a coder myself, so I can't clean up my close by EA from the functions I am actively using.

So please ask me not what is this and that. Will not answer a thing.

Reporting and fixing bugs is another story. Will fully cooperate in the bug fixing department.

Haven't really tested all new stuffs in this EA.

Just very grateful to Sir Nico and would like to contribute a little here, too.
Click to Enlarge

Name: CloseZilla.png
Size: 83 KB
CloseZilla 1.20.mq4


© Forex Factory