Fix bug on opening first buy order
Updated condition to open buy and sell orders when PREVENT HEDGING is set to true.
Now if the "prevent hedging" parameter is set to true it blocks the EA to open opposite orders only when none are present (so, the EA doesn't open a reverse grid if one is already present). But if a new position is opened manually (using buy/sell or normal "New Order" function in MT4).
This is an improvement useful in a live trading scenarion when you want to add a new opposite position manually and then allow the EA to add more grid positions if needed. When the new order is opened, if it is closed by profit, no other positions in that direction will be taken autonomously by the EA unless the opposite position grid is completely over.
Move piggy panel option to user interface section
Opening limits removed
- Removed some old unused parameters (duplicated TP and grid step for buy and sell)
- Removed old hedging not more needed with piggy bank feature
- Added minimum loss to be reached to use the Piggy Bank profit
Piggy Bank is now disabled by default (to avoid problems on update).
Piggy bank panel status fix
The purpose of this is to add another way to reduce Drawdown and close positions far away from the current price. To have an overall picture, basically, EA should work as follow:
• Open positions following indicator -> if goes in the right direction close with Take Profit or Stop Loss (to gain more profit) if trailing profit is enabled
• If the price moves against the opened position, those actions are taken:
o Grid positions added, to improve the average price and move the profit level closer to the actual price
o If too many grid positions are added and prices continue to move in the wrong direction, the DDR functionality will help in reducing the Drawdown by closing profitable positions and the worst position together, to have an overall profit but using a % of the profit to close the loss.
o The new Piggy Bank features come into play when DDR is not able to close the largest loss position. This could happen if the profitable positions cannot get enough profit because the price is not pulling back enough. Piggy bank profit acts with two simultaneous actions to use profit of the last closed orders to compensate the loss of the worst position in the grid.
These functions, when enabled because the number of grid position set for activation are reached, are two:
1. Apply a trailing profit strategy for every single position that reaches a minimum value in profit (in points. This allows the EA to get profit even if the average profit of the grid is far away from the current price
2. When the profit of the past closed orders is enough to compensate for the worst position of the grid, the position will be closed. The % of the profit to be used is configurable, to avoid losing all the profit to close lossy positions.
• ENABLED: if turned off or not
• Show panel: hide / show panel
• Enable min orders: minimum orders in the grid to enable this feature. The suggestion is to have a gap between the values that enable DDR and the ones that enable Piggy Bank
• Use all pairs: when trading with more than a pair in the account, if this is turned on it can use also profits done by other pairs to compensate losses and close positions
• % of the profit to use: how much historical profit to be used to close lossy positions
• Older order date: do not use the profit of orders closed before this date
• Profit to enable TP: profit in point to be reached by the single position before adding the Stop Loss
• Trailing profit distance for current price: the amount in point for trailing profit (same settings that is been set with the MetaTrader interface.
- Fixed distance computing for profit in DDR: used ask for sell and bid for buy
- Fixed a typo in the DDR panel
Added the possibility to automatically disable the DDR feature when the prices come close to the TP.
Two parameters are added:
- Disable close to profit (true/false): when set to true, the new feature is enabled otherwise the usual behaviour take place
- Min distance from profit: the minimum distance, in points, that the price should have from the TP level to let the DDR functionality working. If the price goes closer, DDR will be disabled.
In the DDR panel, those changes have been made:
- Added indication for take profit buy distance (TP B.) and take profit sell distance (TP S.). It is shown as [CURRENT DISTANCE]/[MINIMUM DISTANCE]. If the current distance is less than the minimum the text is in red (DDR disabled), otherwise in green (DDR enabled).
- Added a custom message for DDR status, "Disabled - Close to TP" when the DDR functionality is disabled because the price is too close to the take profit level (according to settings).
Added a trend indicator, with two parameters:
- Timeframe: indicate the timeframe that will be used by the indicator, that will be independent of the chart timeframe
- Deviation: the number of candles taken into account by the indicator to determine the current trend
Fixed max number of positions used by DDR. Now, for the bug, it takes one position more than expected by parameter.
Added two new parameters:
- Max DDR order count: when using DrawDown Reduction this parameter limit the number of orders used
- Max Grid step: same as Max Lot Size, but for the grid step. It limits the maximum value that the grid step can reach, no matters what is the output of the grid function and factor.
Changed handle all orders parameter to true / false for easier understanding
Fix a regression on hedging trades
Two main features on this update:
- removed old unused parameter, with functionality replaced by DDR
- added the option to handle all orders on the account/currency, also manually added and not only the ones with the same Magic Number set by the EA
This new version is a minor update to improve the user interface:
- Added a new parameter "Panel font size" which is the basic font size used for the panel
- cleanup on parameters, moving all the parameters regarding the user interface in an appropriate section.
Hint: in backtesting/optimization, is a good practice to turn of trend lines, stats, and DDR panel to speed up the backtesting, as far as the user interface is not useful.
- Added a new indicator, Open When None: it simply add positions when all previous one in the same direction were closed. This feature is useful when using hedging orders
- Added minimum grid increase parameter: ensure that a minimum increase is done between the last grid position and the new one. I've added this new feature to improve the benefits of the DDR functionality.
This update ensures that the last grid position is never smaller than the last one. This can occur when using the DDR feature, that closes previous positions to reduce drawdown (or even if the user manually closes some positions).
Fixed a bug with DDR functionality when the profit used to cover losses is exactly 0 and causes a divide by 0 error.