1 /*=============================================================
\r
2 Info: Godbot EA // Timeframe M5 EURUSD
\r
4 Author: Erich Pribitzer
\r
7 Notes: Mulit Order added
\r
12 Copyright (C) 2011 Erich Pribitzer
\r
14 =============================================================*/
\r
16 #property copyright "Copyright © 2011, Erich Pribitzer"
\r
17 #property link "http://www.wartris.com"
\r
20 #include <BasicH.mqh>
\r
21 #include <OrderLibE.mqh>
\r
22 #include <OrderLibH.mqh>
\r
25 // Godbot EA timeframe M5
\r
27 extern string GB_SETTINGS = "==== GODBOT EA V1.1/M5 SETTINGS ===="; //
\r
28 extern int GB_BANDS_PERIOD = 23;
\r
29 extern int GB_BANDS_DEVIA = 2;
\r
30 extern int GB_BANDS_SHIFT = 0;
\r
31 extern int GB_MA = 178;
\r
32 extern int GB_BANDS_TF = PERIOD_M30;
\r
34 extern int GB_DEMA_PERIOD = 56;
\r
35 extern int GB_DEMA_TF = PERIOD_D1;
\r
36 // extern bool GB_TIMEFILTER = true;
\r
46 OL_Init(OL_ALLOW_ORDER,OL_RISK_PERC,OL_RISK_PIPS,OL_PROFIT_PIPS,OL_TRAILING_STOP,OL_LOT_SIZE,OL_INITIAL_LOT,OL_CUSTOM_TICKVALUE,OL_SLIP_PAGE,OL_STOPSBYMODIFY,OL_MAX_LOT,OL_MAX_ORDERS,OL_MAGIC,OL_ORDER_DUPCHECK,OL_OPPOSITE_CLOSE, OL_ORDER_COLOR, OL_MYSQL_LOG);
\r
47 ArrayResize(GB_dema,BA_INIT_BARS);
\r
63 if(GB_oldBar!=Bars) //
\r
68 if(GB_oldBar<BA_INIT_BARS) return;
\r
70 double bandHi=iBands(NULL,GB_BANDS_TF,GB_BANDS_PERIOD, GB_BANDS_DEVIA,GB_BANDS_SHIFT,PRICE_CLOSE,1,1);
\r
71 double bandLow=iBands(NULL,GB_BANDS_TF,GB_BANDS_PERIOD, GB_BANDS_DEVIA,GB_BANDS_SHIFT,PRICE_CLOSE,2,1);
\r
72 GB_DEMA(Symbol(),GB_DEMA_TF,GB_DEMA_PERIOD,PRICE_CLOSE,GB_dema);
\r
74 double open=iOpen(NULL,GB_BANDS_TF,1);
\r
75 double close=iClose(NULL,GB_BANDS_TF,1);
\r
76 double ma1 = iMA(NULL,GB_BANDS_TF,GB_MA,0,MODE_EMA,PRICE_CLOSE,1);
\r
77 double ma2 = iMA(NULL,GB_BANDS_TF,GB_MA,0,MODE_EMA,PRICE_CLOSE,2);
\r
80 bool buyClose=(close < bandHi && open > bandHi);
\r
81 bool sellClose=(close > bandLow && open < bandLow);
\r
82 bool buy =(close > bandLow && open < bandLow && GB_dema[0] > GB_dema[1] && GB_dema[1] > GB_dema[2] && ma2 < ma1);
\r
83 bool sell = (close < bandHi && open > bandHi && GB_dema[0] < GB_dema[1] && GB_dema[1] < GB_dema[2] && ma2 > ma1);
\r
94 binx=OL_enumOrderList(binx,OP_SELL);
\r
96 OL_setOrderProperty(binx,OL_FLAG,OL_FL_CLOSE);
\r
97 Print("CLOSE....SELL");
\r
109 binx=OL_enumOrderList(binx,OP_BUY);
\r
111 OL_setOrderProperty(binx,OL_FLAG,OL_FL_CLOSE);
\r
112 Print("CLOSE....BUY");
\r
121 Print("ORDER....BUY");
\r
122 OL_addOrderProperty(OL_TYPE,OP_BUY);
\r
123 //OL_addOrderProperty(OL_OPRICE,Ask);
\r
124 OL_addOrderProperty(OL_RISKPERC,0);
\r
125 OL_addOrderDescription(OP_BUY);
\r
126 if(OL_registerOrder()==-1)
\r
127 Print("OL_registerOrder failed!!!");
\r
133 Print("ORDER....SELL");
\r
134 OL_addOrderProperty(OL_TYPE,OP_SELL);
\r
135 //OL_addOrderProperty(OL_OPRICE,Bid);
\r
136 OL_addOrderProperty(OL_RISKPERC,0);
\r
137 OL_addOrderDescription(OP_SELL);
\r
138 if(OL_registerOrder()==-1)
\r
139 Print("OL_registerOrder failed!!!");
\r
143 OL_processOrder(); // Close/Modify or Open order(s)
\r
150 void GB_DEMA(string symbol, int timeframe, int dema_period, int applied_price,double &buffer[])
\r
152 static double lastEMA, lastEMA_of_EMA;
\r
153 double weight=2.0/(1.0+dema_period);
\r
155 int limit=BA_INIT_BARS;
\r
158 lastEMA = iClose(symbol, timeframe, limit);
\r
159 lastEMA_of_EMA = iClose(symbol, timeframe, limit);
\r
163 for(int i=limit; i >= 0; i--)
\r
165 lastEMA =weight*iClose(symbol, timeframe,i) + (1.0-weight)*lastEMA;
\r
166 lastEMA_of_EMA =weight*lastEMA + (1.0-weight)*lastEMA_of_EMA;
\r
167 buffer[i]=(2.0*lastEMA - lastEMA_of_EMA);
\r