Experts: Simplest Hedging EA ever - page 2

 
BarrowBoy:
I would certainly add a time-of-day filter and test trailing stops

Hmmm... Ok BarrowBoy, I'll give that a go. Thanks :)
 

I had a thought about your closure and the idea of optimizing, see what you think of it. Instead of closing based on an optimization, what about comparing the two trades pip value and requiring an offset of pips to the positive...

TradeA (the positive trade) = +35 pips
TradeB (the negative trade) = -25 pips

If (MathABS(TradeA) >= (MathABS(TradeB) + DesiredProfitInPips))
{
      CloseAllTrades();
}
If (MathABS(TradeB) >= (MathABS(TradeA) + DesiredProfitInPips))
{
      CloseAllTrades();
}
 
Hi LEH,

That's certainly food for thought, but what would cause the two trades to drift apart by the desired number of pips?

M
 

Hi,
How to open several orders Ex: EURUSD, GBPUSD, etc ...
Each with its MAGIC and closing when the 2 positions are closed.

 
Hi Forexnet,

You could change the MAGIC from a constant to an external variable by changing this code:

#define MAGIC  1234
#define IDENT  "mo_bidir_v0_1"
 
extern double  lots           = 1;
extern double  stop_loss      = 80;   // (8 pips) optimise 50-2000
extern double  take_profit    = 750;  // (75 pips) optimise 50-2000
to:
#define IDENT  "mo_bidir_v0_1"
 
extern double  MAGIC          = 1234
extern double  lots           = 1;
extern double  stop_loss      = 80;   // (8 pips) optimise 50-2000
extern double  take_profit    = 750;  // (75 pips) optimise 50-2000
You would then be able to go into the "Expert Properties" and change the MAGIC number on each chart you are working with.

Regards,

Monu
 
LEHayes:

I had a thought about your closure and the idea of optimizing, see what you think of it. Instead of closing based on an optimization, what about comparing the two trades pip value and requiring an offset of pips to the positive...

TradeA (the positive trade) = +35 pips
TradeB (the negative trade) = -25 pips

If (MathABS(TradeA) >= (MathABS(TradeB) + DesiredProfitInPips))
{
      CloseAllTrades();
}
If (MathABS(TradeB) >= (MathABS(TradeA) + DesiredProfitInPips))
{
      CloseAllTrades();
}

1) what if we place stop lose at 3 levels for the losing order? instead of having same SL as the profit trade? We can have a better profit.

2) execute 2 pending order buy n sell 5pips up 5pips down, if one order trigger the other will expire and replace by a pending order at the price that trigger the 2 pending order, but at 1.5 time the lots size. All order will have 3 levels of stop loses.

Regards
Hans
ng_hans@yahoo.com.sg
 
Hello Monu,

Did not work ...

Chart EURUSD
# Define IDENT "mo_bidir_v0_1"
extern double MAGIC = 1234;
Result: OK, opened 2 positions.

Chart GBPUSD
# Define IDENT "mo_bidir_v0_1"
extern double MAGIC = 4321;
Result: Error, only opens 2 positions, when they close the 2 positions of the EURUSD.

Please help me.

Thanks,

Forexnet

monuogbe
wrote:
Hi Forexnet,

You could change the MAGIC from a constant to an external variable by changing this code:

#define MAGIC  1234
#define IDENT  "mo_bidir_v0_1"
 
extern double  lots           = 1;
extern double  stop_loss      = 80;   // (8 pips) optimise 50-2000
extern double  take_profit    = 750;  // (75 pips) optimise 50-2000
to:
#define IDENT  "mo_bidir_v0_1"
 
extern double  MAGIC          = 1234
extern double  lots           = 1;
extern double  stop_loss      = 80;   // (8 pips) optimise 50-2000
extern double  take_profit    = 750;  // (75 pips) optimise 50-2000
You would then be able to go into the "Expert Properties" and change the MAGIC number on each chart you are working with.

Regards,

Monu
 
Hi Forexnet,

I don't know why it didn't work!? :)

Did you optimise all the parameters? Maybe your broker only uses 4 digits? If so, the stop_loss and take_profit should be 8 and 75, not 80 and 750.

However, don't waste too much time on it, it is only an experiment to see how simple an EA can be, and still be successful. :) I don't think anybody would try to trade with it!

Regards,

Monu
 

Playing on your theory and having some fun with it, I implemented the code I described earlier, because this now served as a stop loss system, I removed the stop loss. Something interesting happened. The program ran until it hit what ever TakeProfit I provided on either one, but the other would remain open until it was also hit. Nice results, but as you can imagine that generated a drawdown risk. So I changed it to force a closure of the the counter trade whenever a TakeProfit was hit. This was done by checking the number of open trades, if it reached 1, then I would close all. This showed a really cool spiking chart with a gradual slope down.

The next thing I did was take away the TakeProfit, this forced the program to only close when the stop loss system invoked the closure, forcing the closure when one trades profit value was greater than the other plus the value of profit you desired. I didn't get any closure. I took it to $1 as the desired profit value, still no closed trades. This technique leaves me to believe that if you do not close the negative trade, you will never see a profit ina true hedge.

Next I am going to attempt to find a way to decide when to cut the loss on the losing trade so that the profiting trade can prevail.

 
LEHayes:

This technique leaves me to believe that if you do not close the negative trade, you will never see a profit in a true hedge.

Thats true :)

Next I am going to attempt to find a way to decide when to cut the loss on the losing trade so that the profiting trade can prevail.
Thats the really tricky bit :{
Thing is, are we really hedging here - I call this cover trading as there is only one commodity involved...
Reason: