Ver código fonte

few updates in the code

Uzair Tahir 1 ano atrás
pai
commit
a9b0e6fe62
2 arquivos alterados com 20 adições e 7 exclusões
  1. BIN
      CribMarketEA.ex5
  2. 20 7
      CribMarketEA.mq5

BIN
CribMarketEA.ex5


+ 20 - 7
CribMarketEA.mq5

@@ -13,9 +13,9 @@ CTrade  trade;
 
 input       string               Settings              = " ------------- General Settings ------------- ";   //_
 input       int                  magicNo               = 333;                 // Magic no
-input       double               lotSize               = 0.1;                 // Lot Size
-input       bool                 enableBasketTP        = false;               // Enable Basket TP
-input       double               basketTakeProfit      = 150.0;               // Basket Take Profit
+input       double               lotSize               = 0.01;                 // Lot Size
+input       bool                 enableBasketTP        = true;               // Enable Basket TP
+input       double               basketTakeProfit      = 1.0;               // Basket Take Profit
 
 
 string goldPairs[];
@@ -35,7 +35,8 @@ int OnInit()
    trade.SetAsyncMode(false);
 
    getGoldPairsFromMarketWatch();
-
+//--- create timer
+   EventSetMillisecondTimer(1000);
 
 //---
    return(INIT_SUCCEEDED);
@@ -46,6 +47,7 @@ int OnInit()
 void OnDeinit(const int reason)
   {
 //---
+   EventKillTimer();
 
   }
 //+------------------------------------------------------------------+
@@ -55,6 +57,15 @@ void OnTick()
   {
 //---
 
+
+
+  }
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+void OnTimer()
+  {
+//---
    if(enableBasketTP == true)
      {
       checkBasketTakeProfit();
@@ -79,7 +90,6 @@ void OnTick()
          placeSellTrade(symbolToSell);
         }
      }
-
   }
 //+------------------------------------------------------------------+
 //|                                                                  |
@@ -178,6 +188,8 @@ string getSymbolWithLowestAsk()
    for(int i = 0; i < totalGoldPairs; i++)
      {
       double currentAsk = SymbolInfoDouble(goldPairs[i], SYMBOL_ASK);
+      Print("Pair:",goldPairs[i]," Price Ask:",currentAsk);
+
       if(currentAsk < lowestAsk)
         {
          lowestAsk = currentAsk;
@@ -185,7 +197,7 @@ string getSymbolWithLowestAsk()
         }
      }
 
-//Print("Lowest Ask Pair: ", lowestSymbol, " Lowest Ask: ", lowestAsk);
+   Print("Lowest Ask Pair: ", lowestSymbol, " Lowest Ask: ", lowestAsk);
    return lowestSymbol;
   }
 
@@ -205,6 +217,7 @@ string getSymbolWithHighestBid()
    for(int i = 0; i < totalGoldPairs; i++)
      {
       double currentBid = SymbolInfoDouble(goldPairs[i], SYMBOL_BID);
+      Print("Pair:",goldPairs[i]," Price Bid:",currentBid);
       if(currentBid > highestBid)
         {
          highestBid = currentBid;
@@ -212,7 +225,7 @@ string getSymbolWithHighestBid()
         }
      }
 
-//Print("Highest Bid Pair: ", highestSymbol, " Highest Bid: ", highestBid);
+   Print("Highest Bid Pair: ", highestSymbol, " Highest Bid: ", highestBid);
    return highestSymbol;
   }
 //+------------------------------------------------------------------+