Forex Hedge Devil Expert Advisor

Forex Hedge Devil Expert Advisor review:

This is a semi-auto Forex Hedge Devil Expert Advisor to help you protect your position, using Hedging, when the market goes opposite direction. It will manages all lots automatically and exits the market in a proper way.

Features

  • Trailing stop an existing position when it makes profit.
  • Opens a Hedging position when market goes in opposite direction.
  • Exits the market when the sum of profit > 0 or specific condition is triggered.
  • The EA WILL NOT enter the market by itself. It deals with how to exit only.
  • Devil in the EA.

Inputs

  • HedgeDistance(Pts): The hedge distance in points (ex. EURUSD buy at 1.12345, HedgeDistance(Pts)= 1000 means Open a Sell at 1.11345).
  • HedgeLotRatio: Ratio factor multiplied by the last total opposite position (ex. ratio=1.4 and total buy lots = 1.0, then open a sell 1.0*1.4=1.4 lots to hedging. Default value = 1.414. Range from 1.0 to 99.0).
  • SpreadLimited(Pts): In floating spread condition, EA will not close the position when spread > SpreadLimited(Pts).
  • SCLot: The SectionClose Operation threshold (please refer to SectionClose Operation description below).
  • MaxLot: The safety threshold of maximum lots (If last open lot > MaxLot, Hedging will stop and make total buy = total sell, more detailed description is below).
  • MagicNumber: The magic number of EA.
  • TrailingStopDistance(Pts): Trailing stop distance in points.
  • DisplayMessage: Show a message window in left corner.
  • OpenTime(local): The timer. Open a initial position in specific time (local time). This feature can be used in backtesting or real time trading.
  • Operation: The operation of the initial position. DirLong = buy; DirShort = sell; DirNone = do nothing.
  • InitialLot: The initial lot size opened by timer.

The Hedging Idea

For example you have bought 0.02 lots EURUSD at 1.12000. Then EA will pend a hedge order to protect the initial position.

Hedgedistance = 400, HedgeLotRatio = 1.414. There will be a SellStop order with 0.03(=0.02*1.414) lots at 1.11500.

1. If the market goes up, the EA will set a trailing stop level, then close the order when stop level is triggered.

2. If the market goes down, and SellStop order triggers, you have 0.02 lots of buy and 0.03 lots of sell. If the market continues going down and down enough (depending on the Hedgedistance and HedgeLotRatio you have set), the sum of profit may come to positive and the EA will close both buy and sell orders.

3. If the SellStop order has been triggered, EA will pend a BuyStop Order with 0.02 lots at 1.12000. If market goes up again, you have 0.04 lots of buy and 0.03 lots of sell. If market continues going up, you may exit the market, otherwise the EA will continue the pending loop until you can exit.

SectionClose Operation

Sometimes in hedging condition the market will not move deep enough so that you could not have a positive total profit, but some part of it. Now you have 2 options:

1. You can wait and continue the loop till the market goes sufficiently long distance. The lot size may grow very big and cause bankrupt if your balance is not enough to fulfill the margin requirement.

2.You can close some part of hedging orders using the last hedging order’s profit. Decrease the total lot size and wait for the next chance to open a new order.

The SectionClose Operation is to calculate the profit of the last hedging order, and how many orders could be closed within the small profit.

The SCLot parameter means that if the last hedging lot > SCLots, SectionClose Operation will be executed. A small value (0.01) means permanent execution, and a big value (99) means never.

After the operation, you may have an equal lot size in both side.

Broker

This EA works on 5 or 3 digits brokers with fix spread or floating spread. I have been tested and running it on demo and real accounts.

Test results:

Forex Hedge Devil Expert Advisor

Installation

Copy and paste the file into the MQL4 Experts folder of the Metatrader 4 trading platform.

You can access this folder from the top menu as follows:

File > Open Data Folder > MQL4 > Experts (paste here)

Other forex indicators and strategies

Leave a Comment