Explorar el Código

Printing improved

WajeehSaqib-MQL hace 1 año
padre
commit
1318839b09
Se han modificado 2 ficheros con 25 adiciones y 11 borrados
  1. BIN
      V2/CribMarketEAV2.ex5
  2. 25 11
      V2/CribMarketEAV2.mq5

BIN
V2/CribMarketEAV2.ex5


+ 25 - 11
V2/CribMarketEAV2.mq5

@@ -33,12 +33,12 @@ input       int                  magicNo               = 333;                 //
 input       double               lotSize               = 0.01;                 // Lot Size
 input       bool                 enableBasketTP        = true;               // Enable Basket TP
 input       double               basketTakeProfit      = 1.0;               // Basket Take Profit
-input       int                  maxOpenPositions      = 3;                // Maximum number of open positions
+input       int                  maxOpenPositions      = 3;                // Maximum number of Combinations
 
 
 string goldPairs[];
 int totalGoldPairs = 0;
-
+int timmer = 0;
 //+------------------------------------------------------------------+
 //| Expert initialization function                                   |
 //+------------------------------------------------------------------+
@@ -88,6 +88,8 @@ void OnTick()
 void OnTimer()
   {
 //---
+   timmer++;
+   Print("<><><><><><><> Timer Start: ",timmer," <><><><><><><>");
 
    removeFromStruct();
 
@@ -124,6 +126,9 @@ void OnTimer()
      {
       addToStructure(buyTickett, sellTickett, symbolToBuy, symbolToSell);
      }
+
+   Print("<><><><><><><> Timer End: ",timmer," <><><><><><><>");
+
   }
 //+------------------------------------------------------------------+
 //|                                                                  |
@@ -228,7 +233,7 @@ string getSymbolWithLowestAsk()
    for(int i = 0; i < totalGoldPairs; i++)
      {
       double currentAsk = SymbolInfoDouble(goldPairs[i], SYMBOL_ASK);
-      Print("Pair:",goldPairs[i]," Price Ask:",currentAsk);
+      Print(" Ask Price: ",currentAsk," || on Pair: ",goldPairs[i]);
 
       if(currentAsk < lowestAsk)
         {
@@ -237,7 +242,7 @@ string getSymbolWithLowestAsk()
         }
      }
 
-   Print("Lowest Ask Pair: ", lowestSymbol, " Lowest Ask: ", lowestAsk);
+   Print("Lowest Ask Pair: ", lowestSymbol, " || Lowest Ask: ", lowestAsk);
    return lowestSymbol;
   }
 
@@ -257,7 +262,7 @@ string getSymbolWithHighestBid()
    for(int i = 0; i < totalGoldPairs; i++)
      {
       double currentBid = SymbolInfoDouble(goldPairs[i], SYMBOL_BID);
-      Print("Pair:",goldPairs[i]," Price Bid:",currentBid);
+      Print(" Bid Price: ",currentBid," || on Pair: ",goldPairs[i]);
       if(currentBid > highestBid)
         {
          highestBid = currentBid;
@@ -265,7 +270,7 @@ string getSymbolWithHighestBid()
         }
      }
 
-   Print("Highest Bid Pair: ", highestSymbol, " Highest Bid: ", highestBid);
+   Print("Highest Bid Pair: ", highestSymbol, " || Highest Bid: ", highestBid);
    return highestSymbol;
   }
 //+------------------------------------------------------------------+
@@ -303,15 +308,24 @@ void checkBasketTakeProfit()
            {
             combinationProfit += PositionGetDouble(POSITION_PROFIT) + PositionGetDouble(POSITION_SWAP);
            }
-
+           
          if(combinationProfit >= basketTakeProfit)
            {
             Print("Combination TP hit: Closing trades. Profit = ", combinationProfit);
 
-            trade.PositionClose(newTradeStore[i].buyTicket);
-            Print("Buy Trade Closed: ", newTradeStore[i].buyTicket);
-            trade.PositionClose(newTradeStore[i].sellTicket);
-            Print("Sell Trade Closed: ", newTradeStore[i].sellTicket);
+            if(!trade.PositionClose(newTradeStore[i].buyTicket))
+              {
+               Print(" Error Closing Buy Trade : ", newTradeStore[i].buyTicket," ",GetLastError());
+              }
+            else
+               Print("Buy Trade Closed: ", newTradeStore[i].buyTicket);
+
+            if(!trade.PositionClose(newTradeStore[i].sellTicket))
+              {
+               Print(" Error Closing Sell Trade : ", newTradeStore[i].sellTicket," ",GetLastError());
+              }
+            else
+               Print("Sell Trade Closed: ", newTradeStore[i].sellTicket);
            }
         }
      }