The ‘Hedge’ Rocks Expert Advisor for MT4


The ‘Hedge’ Rocks Expert Advisor for MT4. I warn you now that I am more of a math dude than a MQL/MT4 programmer: my programming techniques are much like my surroundings… disorganized and messy. However, the math is sound and matches the FR trading system to a high degree of precision. Feel free to clean up my code if you wish.

Now some caveats:

1) This EA was never tested on the real thing… only demos. It is still somewhat buggy. Don’t run it on a live account unless you thoroughly test it on a demo account.

2) I wrote this using the demo account. It is calibrated to use 200:1 leverage with 100K lot sizes and roughly a 10K or 100K account balance.

3) The sizes of your purchased lots (according to FR) should be no less than .5 to ensure that the ratios between the hedge groups are optimized. It still seems to work fine with less. If you choose the highest leverage or use 10K or ‘micro’ lot sizes to trade, the purchased lots will be higher. If you can’t change your lot sizes or your leverage… than you have to increase the amount you trade… via the Margin Percentage or the account balance… or both. It seems to work just fine with purchased lots of less than .5 but, that is what they say.

4) I simply copied the FR system as best I could and have no opinion on its validity. They all seem a bit fanatical if you ask me… and that whole direct marketing thing is just not my cup of tea. It certainly can lose in spite what your Cool-Aide-Drinking friends at FR might tell you.


1) During the placing of the initial orders, sometimes one of two members of a currency group gets rejected by the broker which causes it to sell the remaining pair and reorder the group… causing you to eat the spread on the sold pair. It has something to do with the speed at which some brokers can accept orders.

2) Rarely, it has a problem getting the historical data and crashes out my little Pearson Correlation routine at the end. I put in a bunch of catches but it still throws an error on rare occasion.

Feel free to ask me questions. I will post some instructions next.




What is the process behind this hedge EA? After going +30 in one direction LONG (if TP=30 pips) and in oposite direction is -30 SHORT (we disregard the spread), is this EA going to open new trade in the LONG direction with same lot size, and leave SHORT open positon go on?

Daniel Carter

ea parameters

Hi. By the way I would like to know which parameters in EA users are allowed to choose or modify. I wonder if it is not too risky leave orders at an EA mercy. If you could share with exactly which parameters are open to define before the EA starts its work, it’d be very helpful. Dan
that is why you have to set your own ea. This is the only way you can trust it, of course before you need to test it on a demo. Do you have mt4?