Many people here on forexsoutheast.asia have been very kind to me personally along with my occasional demands for coding help.
Attached is a EA I typed, which does need a Forex account that allows hedging for it to be useful. Placing it on line here for others to use is simply to give something back to the forum and as a way to say thank you.
It's a Trade Manager type EA, not a trading egy.
It works as follows:
For all 3 regions (Free Margin, Equity Profit and Equity Loss), when it starts up (or you restart MT4), it calculates the difference between sell and buy lots that are open in addition to your opening equity and free margin levels.
At pre-set trigger points that you set in inputs, it will open a trade to balance lots.
Eg, With Equity Loss and Lending Profit, it makes the lots equal to lock in the profit or limit the reduction. With free Margin, it opens an reverse order to leave 50% of the trade in favor of the direction you have.
The cause points and lots info are displayed on the chart so you know where things are at.
Free Margin -
In inputs, you can pick the percent of completely free Margin at which stage the 50% balance trade gets opened. That's, extern int FM = 0.3 implies that if Free Margin boils down to 30 percent, it will open an opposite trade equivalent to 50% of the open lots. This leaves the majority of your open lots in favor of the direction you wanted, but prevents your account in any margin calls.
TakeProfitFM is your pips of profit this trade could be shut at.
Fiscal Discount -
In inputs, you can set the maximum loss of equity you will accept before an opposite order will balance your own buy/sell lots. That is extern double MaxLoss = 0.25 equals 25% loss of equity to my account will activate a balancing trade that makes buy and sell lots equal.
If this trade is opened, it resets the MaxLoss level at the set% lower.
NOTE: This code tracks best price/equity. As your account enhances equity/profit, it tracks and changes the MaxLoss tigger point in line with the new/higher level.
TakeProfitML is your pips in profit this trade could be shut at.
Equity Profit -
In inputs, you can set the maximum increase of equity you will accept prior to an opposite order will balance your buy/sell lots. That is extern double HeapsProfit = 0.25 equals 25% profit on equity to my account will activate a balancing trade the makes buy and sell lots equal. This will be to lock in a profit, which mentally we often see disappear before our eyes before we do it.
If this trade is opened, it resets the HeapsProfit level at the set% higher.
TakeProfitHP is your pips in profit those transactions could be shut at.
The best way to use this EA would be to link it to any chart. It's not related to time frames. Any other EAs you use of course run in their own charts. That's, this really is a standalone EA I use not to the key trades I open, but to cover my butt when things go bad or good.
Any comments welcome, however please do not think I'm interested in adding lots of functions - my programming skill is only a couple rungs up the learning curve ladder.
https://www.forexsoutheast.asia/atta...1129084545.mq4