any hedge tool or ea to minimize any loose position has open by another ea - page 2

 
Keith Watford:

...
In trading, "hedging" does not offset any costs and can actually incur additional costs. So "hedging" in trading makes absolutely no sense whatsoever.

All is clear

But

I have an experimental MQL5 EA with a simple logic that has an optional hedging feature

That is, the EA can open the opposite position leaving the initial position open

Optimization mode in tester with hedging shows better results then without it

I can post .ex5 file in this thread so that anyone can make check this

But I would like this to not be considered advertising or promotion

 
AIRAT SAFIN:

All is clear

But

I have an experimental MQL5 EA with a simple logic that has an optional hedging feature

That is, the EA can open the opposite position leaving the initial position open

Optimization mode in tester with hedging shows better results then without it

I can post .ex5 file in this thread so that anyone can make check this

But I would like this to not be considered advertising or promotion

There is no need to post the file, just explain the logic.
If an EA makes more profit by "hedging" it is not because of the "hedging" aspect but due to something else in the code. Maybe different lot sizes for the "hedge" trade.

It is mathematically impossible to gain any benefit from "hedging".

Earlier Alain posted a link to my topic from long ago that totally dispels the myth that "hedging" is beneficial. Please read it.

 
Keith Watford:

There is no need to post the file, just explain the logic...

The logic is very simple

HEDGING

   1> OVERVIEW
      1> This EA works with 2 positions => 1 TRADE and 1 HEDGE
      2> Position TRADE means that first opened position is always TRADE
      3> Position HEDGE attempts to open when profit of TRADE position < 0
      4> Each position may be independently trailed by signal TRAIL
      5> Each position may be independently closed  by signal CLOSE
      6> Work with HEDGE position is optional
      7> To turn HEDGE option ON need to set parameter HEDGE OPEN: FACTOR > 0
   2> HEDGE PARAMETERS
      1> There are 6 parameters of hedging
         1 => HEDGE TAKE:  INDEX
         2 => HEDGE TRAIL: INDEX
         3 => HEDGE OPEN:  INDEX
         4 => HEDGE TAKE:  FACTOR
         5 => HEDGE TRAIL: FACTOR
         6 => HEDGE OPEN:  FACTOR
      2> INDEX defines working TF
           => INDEX = 0 defines current TF
           => INDEX = 1 defines M1
           => INDEX = 2 defines M5
           => INDEX = 3 defines M15
           => INDEX = 4 defines M30
           => INDEX = 5 defines H1
           => INDEX = 6 defines H4
           => INDEX = 7 defines D1
      3> HEDGE INDEX defines working time frames for signals
         1 => HEDGE TAKE
         2 => HEDGE TRAIL
         3 => HEDGE OPEN
      4> Then EA computes Range of Bar 1 of selected TF for each signal
            => RANGE_TAKE     = HIGH_TAKE   - LOW_TAKE
            => RANGE_TRAIL    = HIGH_TRAIL  - LOW_TRAIL
            => RANGE_OPEN     = HIGH_OPEN   - LOW_OPEN
      5> HEDGE TAKE: FACTOR defines distance for TP
            => DISTANCE_TAKE  = RANGE_TAKE  * FACTOR_TAKE
      6> HEDGE TRAIL: FACTOR defines distance for TRAIL
            => DISTANCE_TRAIL = RANGE_TRAIL * FACTOR_TRAIL
      7> HEDGE OPEN: FACTOR defines distance that allows open HEDGE
            => DISTANCE_OPEN  = RANGE_OPEN  * FACTOR_OPEN
      8> HEDGE open distance means following
         "if MathAbs ( CURRENT_PRICE - POSITION_PRICE ) >= HEDGE_DISTANCE_OPEN
             where POSITION_PRICE is open price for position TRADE
          and     if ( SIGNAL_TO_OPEN () == true )
          then EA attemts to open HEDGE position"
      9> TP and SL computing
            => for BUY  position => TAKE = ASK + TAKE_DISTANCE
                                    STOP = POSITION_OPEN_PRICE
            => for SELL position => TAKE = BID - TAKE_DISTANCE
                                    STOP = POSITION_OPEN_PRICE

Position volumes are always equal in this sample


 
Keith Watford:

There is no need to post the file, just explain the logic.
If an EA makes more profit by "hedging" it is not because of the "hedging" aspect but due to something else in the code. Maybe different lot sizes for the "hedge" trade.

It is mathematically impossible to gain any benefit from "hedging".

Earlier Alain posted a link to my topic from long ago that totally dispels the myth that "hedging" is beneficial. Please read it.

Some people will never understand.
 
AIRAT SAFIN:

All is clear

But

I have an experimental MQL5 EA with a simple logic that has an optional hedging feature

That is, the EA can open the opposite position leaving the initial position open

Optimization mode in tester with hedging shows better results then without it

...

You would have yet better results without "hedging" and closing your losing trade.

 
Alain Verleyen:

You would have yet better results without "hedging" and closing your losing trade.

Not a fact for many reasons

Moreover, the initial position can be hedged when the profit on it is > 0

 
AIRAT SAFIN:

Not a fact for many reasons

Please give us your reasons.

Moreover, the initial position can be hedged when the profit on it is > 0

Hedging a profitable position ? What to do ?
 
AIRAT SAFIN:

The logic is very simple

HEDGING

   1> OVERVIEW
      1> This EA works with 2 positions => 1 TRADE and 1 HEDGE
      2> Position TRADE means that first opened position is always TRADE
      3> Position HEDGE attempts to open when profit of TRADE position < 0
      4> Each position may be independently trailed by signal TRAIL
      5> Each position may be independently closed  by signal CLOSE
      6> Work with HEDGE position is optional
      7> To turn HEDGE option ON need to set parameter HEDGE OPEN: FACTOR > 0
   2> HEDGE PARAMETERS
      1> There are 6 parameters of hedging
         1 => HEDGE TAKE:  INDEX
         2 => HEDGE TRAIL: INDEX
         3 => HEDGE OPEN:  INDEX
         4 => HEDGE TAKE:  FACTOR
         5 => HEDGE TRAIL: FACTOR
         6 => HEDGE OPEN:  FACTOR
      2> INDEX defines working TF
           => INDEX = 0 defines current TF
           => INDEX = 1 defines M1
           => INDEX = 2 defines M5
           => INDEX = 3 defines M15
           => INDEX = 4 defines M30
           => INDEX = 5 defines H1
           => INDEX = 6 defines H4
           => INDEX = 7 defines D1
      3> HEDGE INDEX defines working time frames for signals
         1 => HEDGE TAKE
         2 => HEDGE TRAIL
         3 => HEDGE OPEN
      4> Then EA computes Range of Bar 1 of selected TF for each signal
            => RANGE_TAKE     = HIGH_TAKE   - LOW_TAKE
            => RANGE_TRAIL    = HIGH_TRAIL  - LOW_TRAIL
            => RANGE_OPEN     = HIGH_OPEN   - LOW_OPEN
      5> HEDGE TAKE: FACTOR defines distance for TP
            => DISTANCE_TAKE  = RANGE_TAKE  * FACTOR_TAKE
      6> HEDGE TRAIL: FACTOR defines distance for TRAIL
            => DISTANCE_TRAIL = RANGE_TRAIL * FACTOR_TRAIL
      7> HEDGE OPEN: FACTOR defines distance that allows open HEDGE
            => DISTANCE_OPEN  = RANGE_OPEN  * FACTOR_OPEN
      8> HEDGE open distance means following
         "if HEDGE_DISTANCE_OPEN > MathAbs ( CURRENT_PRICE - POSITION_PRICE ) )
             where POSITION_PRICE is open price for position TRADE
          then EA attemts to open HEDGE position"
      9> TP and SL computing
            => for BUY  position => TAKE = ASK + TAKE_DISTANCE
                                    STOP = POSITION_OPEN_PRICE
            => for SELL position => TAKE = BID - TAKE_DISTANCE
                                    STOP = POSITION_OPEN_PRICE

Position volumes are always equal in this sample


  So please explain how there is any benefit to this "hedging" strategy.

  Using an initial buy trade for example.

Instead of opening the sell "hedge" simply close the buy and then re-enter the buy when the "hedge" sell would hit TP or SL. The result would be exactly the same except by not using the "hedge" you may save on swap costs.

Your strategy is flawed as the only way that it can make a net profit is if the sell hits TP and then price reverses to at least the sell entry price. This is because while both the buy and sell are open, the profit from the sell will be nullified by the additional loss with the buy.

If the sell hits the SL, you have made a net loss because the buy will have reversed to its entry price, meaning it is at BE, but you have made a loss on the sell.

So the only way that you can benefit is if the sell hits TP. Now a good trader would have a reason to believe that the price is heading down and if that good trader opens a sell, he certainly wouldn't leave a buy open.

I don't know why you have mentioned TF as they are irrelevant to a "hedging" strategy.

 

I actually using hedging strategy for more than 11 month and it works for me.

Don't hedging if you're not clearly understand how the characteristics of the pair you trade.

It works for me, but maybe it doesn't suit for you.

 
Yopie Prismananda Aringgi:

I actually using hedging strategy for more than 11 month and it works for me.

Don't hedging if you're not clearly understand how the characteristics of the pair you trade.

It works for me, but maybe it doesn't suit for you.

Anybody that uses "hedging" and claims that it "works" for them is delusional and don't even understand simple mathematics.

Reason: