浏览代码

few updates in the code

Uzair Tahir 7 月之前
父节点
当前提交
a9b0e6fe62
共有 2 个文件被更改,包括 20 次插入7 次删除
  1. 二进制
      CribMarketEA.ex5
  2. 20 7
      CribMarketEA.mq5

二进制
CribMarketEA.ex5


+ 20 - 7
CribMarketEA.mq5

@@ -13,9 +13,9 @@ CTrade  trade;
13 13
 
14 14
 input       string               Settings              = " ------------- General Settings ------------- ";   //_
15 15
 input       int                  magicNo               = 333;                 // Magic no
16
-input       double               lotSize               = 0.1;                 // Lot Size
17
-input       bool                 enableBasketTP        = false;               // Enable Basket TP
18
-input       double               basketTakeProfit      = 150.0;               // Basket Take Profit
16
+input       double               lotSize               = 0.01;                 // Lot Size
17
+input       bool                 enableBasketTP        = true;               // Enable Basket TP
18
+input       double               basketTakeProfit      = 1.0;               // Basket Take Profit
19 19
 
20 20
 
21 21
 string goldPairs[];
@@ -35,7 +35,8 @@ int OnInit()
35 35
    trade.SetAsyncMode(false);
36 36
 
37 37
    getGoldPairsFromMarketWatch();
38
-
38
+//--- create timer
39
+   EventSetMillisecondTimer(1000);
39 40
 
40 41
 //---
41 42
    return(INIT_SUCCEEDED);
@@ -46,6 +47,7 @@ int OnInit()
46 47
 void OnDeinit(const int reason)
47 48
   {
48 49
 //---
50
+   EventKillTimer();
49 51
 
50 52
   }
51 53
 //+------------------------------------------------------------------+
@@ -55,6 +57,15 @@ void OnTick()
55 57
   {
56 58
 //---
57 59
 
60
+
61
+
62
+  }
63
+//+------------------------------------------------------------------+
64
+//|                                                                  |
65
+//+------------------------------------------------------------------+
66
+void OnTimer()
67
+  {
68
+//---
58 69
    if(enableBasketTP == true)
59 70
      {
60 71
       checkBasketTakeProfit();
@@ -79,7 +90,6 @@ void OnTick()
79 90
          placeSellTrade(symbolToSell);
80 91
         }
81 92
      }
82
-
83 93
   }
84 94
 //+------------------------------------------------------------------+
85 95
 //|                                                                  |
@@ -178,6 +188,8 @@ string getSymbolWithLowestAsk()
178 188
    for(int i = 0; i < totalGoldPairs; i++)
179 189
      {
180 190
       double currentAsk = SymbolInfoDouble(goldPairs[i], SYMBOL_ASK);
191
+      Print("Pair:",goldPairs[i]," Price Ask:",currentAsk);
192
+
181 193
       if(currentAsk < lowestAsk)
182 194
         {
183 195
          lowestAsk = currentAsk;
@@ -185,7 +197,7 @@ string getSymbolWithLowestAsk()
185 197
         }
186 198
      }
187 199
 
188
-//Print("Lowest Ask Pair: ", lowestSymbol, " Lowest Ask: ", lowestAsk);
200
+   Print("Lowest Ask Pair: ", lowestSymbol, " Lowest Ask: ", lowestAsk);
189 201
    return lowestSymbol;
190 202
   }
191 203
 
@@ -205,6 +217,7 @@ string getSymbolWithHighestBid()
205 217
    for(int i = 0; i < totalGoldPairs; i++)
206 218
      {
207 219
       double currentBid = SymbolInfoDouble(goldPairs[i], SYMBOL_BID);
220
+      Print("Pair:",goldPairs[i]," Price Bid:",currentBid);
208 221
       if(currentBid > highestBid)
209 222
         {
210 223
          highestBid = currentBid;
@@ -212,7 +225,7 @@ string getSymbolWithHighestBid()
212 225
         }
213 226
      }
214 227
 
215
-//Print("Highest Bid Pair: ", highestSymbol, " Highest Bid: ", highestBid);
228
+   Print("Highest Bid Pair: ", highestSymbol, " Highest Bid: ", highestBid);
216 229
    return highestSymbol;
217 230
   }
218 231
 //+------------------------------------------------------------------+