Selaa lähdekoodia

few updates in the code

Uzair Tahir 7 kuukautta sitten
vanhempi
commit
a9b0e6fe62
2 muutettua tiedostoa jossa 20 lisäystä ja 7 poistoa
  1. BIN
      CribMarketEA.ex5
  2. 20 7
      CribMarketEA.mq5

BIN
CribMarketEA.ex5


+ 20 - 7
CribMarketEA.mq5

@@ -13,9 +13,9 @@ CTrade  trade;
13
 
13
 
14
 input       string               Settings              = " ------------- General Settings ------------- ";   //_
14
 input       string               Settings              = " ------------- General Settings ------------- ";   //_
15
 input       int                  magicNo               = 333;                 // Magic no
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
 string goldPairs[];
21
 string goldPairs[];
@@ -35,7 +35,8 @@ int OnInit()
35
    trade.SetAsyncMode(false);
35
    trade.SetAsyncMode(false);
36
 
36
 
37
    getGoldPairsFromMarketWatch();
37
    getGoldPairsFromMarketWatch();
38
-
38
+//--- create timer
39
+   EventSetMillisecondTimer(1000);
39
 
40
 
40
 //---
41
 //---
41
    return(INIT_SUCCEEDED);
42
    return(INIT_SUCCEEDED);
@@ -46,6 +47,7 @@ int OnInit()
46
 void OnDeinit(const int reason)
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
    if(enableBasketTP == true)
69
    if(enableBasketTP == true)
59
      {
70
      {
60
       checkBasketTakeProfit();
71
       checkBasketTakeProfit();
@@ -79,7 +90,6 @@ void OnTick()
79
          placeSellTrade(symbolToSell);
90
          placeSellTrade(symbolToSell);
80
         }
91
         }
81
      }
92
      }
82
-
83
   }
93
   }
84
 //+------------------------------------------------------------------+
94
 //+------------------------------------------------------------------+
85
 //|                                                                  |
95
 //|                                                                  |
@@ -178,6 +188,8 @@ string getSymbolWithLowestAsk()
178
    for(int i = 0; i < totalGoldPairs; i++)
188
    for(int i = 0; i < totalGoldPairs; i++)
179
      {
189
      {
180
       double currentAsk = SymbolInfoDouble(goldPairs[i], SYMBOL_ASK);
190
       double currentAsk = SymbolInfoDouble(goldPairs[i], SYMBOL_ASK);
191
+      Print("Pair:",goldPairs[i]," Price Ask:",currentAsk);
192
+
181
       if(currentAsk < lowestAsk)
193
       if(currentAsk < lowestAsk)
182
         {
194
         {
183
          lowestAsk = currentAsk;
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
    return lowestSymbol;
201
    return lowestSymbol;
190
   }
202
   }
191
 
203
 
@@ -205,6 +217,7 @@ string getSymbolWithHighestBid()
205
    for(int i = 0; i < totalGoldPairs; i++)
217
    for(int i = 0; i < totalGoldPairs; i++)
206
      {
218
      {
207
       double currentBid = SymbolInfoDouble(goldPairs[i], SYMBOL_BID);
219
       double currentBid = SymbolInfoDouble(goldPairs[i], SYMBOL_BID);
220
+      Print("Pair:",goldPairs[i]," Price Bid:",currentBid);
208
       if(currentBid > highestBid)
221
       if(currentBid > highestBid)
209
         {
222
         {
210
          highestBid = currentBid;
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
    return highestSymbol;
229
    return highestSymbol;
217
   }
230
   }
218
 //+------------------------------------------------------------------+
231
 //+------------------------------------------------------------------+