Download MetaTrader 5

Experts: Simplest Hedging EA ever

To add comments, please log in or register
Sign up for MQL5.community to post your Forum topic
MetaQuotes Software Corp.
Moderator
181426
MetaQuotes Software Corp. 2010.04.06 16:32 

Simplest Hedging EA ever:

This EA simply opens two opposing positions at the beginning of the first new bar it comes across. Both positions can win lose or draw. Works best in 5M timeframe and can be optimised using "Open prices only".

Author: Monu Ogbe

MQL4 Comments
16319
MQL4 Comments 2010.04.06 23:49  
Very interesting concept-I have backtested and looks decent-what motivated this idea/strategy? Daniel
Monu Ogbe
19
Monu Ogbe 2010.04.07 09:00  
forexman05:
Very interesting concept-I have backtested and looks decent-what motivated this idea/strategy? Daniel

Thanks forexman.

The motivation? Well, according to secondary school statistics if you roll a dice you have a 1:6 chance of predicting the outcome. If, however you roll two dice, the odds are not 1:12, but 1:36. If you posit that each indicator has a specific statistical chance of predicting an outcome the more indicators you use, the worse the odds! Of course I'm being simplistic, but it has led me to start thinking very hard about finding a minimalist approach to trading - starting with no indicators at all!

As for the backtesting results, you will find that the EA works if the market is consistent; i.e., if optimised for a gentle or steep rising or falling market, it continues to work while the market retains that profile. I guess one could look for a long term trend, optimise for the last few days of that trend and set the robot off UNTIL the trend changes. Be careful! :)

Monu
zzuegg
1505
zzuegg 2010.04.07 09:13  
hi,
nice idea, but, you made a mistake reguarding the coding.

your code:
int start(){
   if (last_bar == Bars) return(0);
   last_bar = Bars;
   if (OrdersTotal() == 0){
         OrderSend(Symbol(), OP_BUY, lots ,Ask, 3, Ask - stop_loss * Point, Bid + take_profit * Point, IDENT, MAGIC, 0, Blue);
         OrderSend(Symbol(), OP_SELL, lots ,Bid, 3, Bid + take_profit * Point, Ask - take_profit * Point, IDENT, MAGIC, 0, Red);
   } 
   return(0);
}
as you can see you have not the same SL/TP levels for BUY and SELL.
i assume this was not meant.

try this code
int start(){
   if (last_bar == Bars) return(0);
   last_bar = Bars;
   if (OrdersTotal() == 0){
         OrderSend(Symbol(), OP_BUY, lots ,Ask, 3, Ask - stop_loss * Point, Bid + take_profit * Point, IDENT, MAGIC, 0, Blue);
         OrderSend(Symbol(), OP_SELL, lots ,Bid, 3, Bid + stop_loss * Point, Ask - take_profit * Point, IDENT, MAGIC, 0, Red);
   } 
   return(0);
}
and let me know your results.
michael
Monu Ogbe
19
Monu Ogbe 2010.04.07 11:23  
Thanks Michael, you're correct, and I have fixed this in mo_bidir_v0_1.mq4. It works better :)
whroeder1
14544
whroeder1 2010.04.07 15:39  
if (last_bar == Bars) return(0);
   last_bar = Bars;
This will stop working once you reach max bars on chart.
int start() {                    static Time0;
if (Time[0] == Time0) return(0); Time0 = Time[0];
MQL4 Comments
16319
MQL4 Comments 2010.04.07 16:59  

Hi can email me the updated EA? i like to try. Thanks

ng_hans@yahoo.com.sg

Regards
Hans Ng

Monu Ogbe
19
Monu Ogbe 2010.04.07 17:23  
Hi Hans, I've uploaded the bug-fix (mo_bidir_v0_1.mq4). I thought I did that this morning, but I guess I'm not too clever with these computer machines :)
Monu Ogbe
19
Monu Ogbe 2010.04.07 17:38  
BTW, click the russian language link and xerofforex has done a 10-year back test - very amusing :)

Monu Ogbe
19
Monu Ogbe 2010.04.08 09:31  
WHRoeder:
if (last_bar == Bars) return(0);
   last_bar = Bars;
This will stop working once you reach max bars on chart.
Hi WHR, maybe the variable name is unclear. By "last_bar" I really mean the last bar that has been processed... i.e., the most recent apart from the current one :). Thanks for the thought, though!
Brian Dee - Random Trader
1759
Brian Dee - Random Trader 2010.04.08 13:14  
I would certainly add a time-of-day filter and test trailing stops
1234
To add comments, please log in or register