|
@@ -33,12 +33,12 @@ input int magicNo = 333; //
|
|
|
input double lotSize = 0.01; // Lot Size
|
|
input double lotSize = 0.01; // Lot Size
|
|
|
input bool enableBasketTP = true; // Enable Basket TP
|
|
input bool enableBasketTP = true; // Enable Basket TP
|
|
|
input double basketTakeProfit = 1.0; // Basket Take Profit
|
|
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[];
|
|
string goldPairs[];
|
|
|
int totalGoldPairs = 0;
|
|
int totalGoldPairs = 0;
|
|
|
-
|
|
|
|
|
|
|
+int timmer = 0;
|
|
|
//+------------------------------------------------------------------+
|
|
//+------------------------------------------------------------------+
|
|
|
//| Expert initialization function |
|
|
//| Expert initialization function |
|
|
|
//+------------------------------------------------------------------+
|
|
//+------------------------------------------------------------------+
|
|
@@ -88,6 +88,8 @@ void OnTick()
|
|
|
void OnTimer()
|
|
void OnTimer()
|
|
|
{
|
|
{
|
|
|
//---
|
|
//---
|
|
|
|
|
+ timmer++;
|
|
|
|
|
+ Print("<><><><><><><> Timer Start: ",timmer," <><><><><><><>");
|
|
|
|
|
|
|
|
removeFromStruct();
|
|
removeFromStruct();
|
|
|
|
|
|
|
@@ -124,6 +126,9 @@ void OnTimer()
|
|
|
{
|
|
{
|
|
|
addToStructure(buyTickett, sellTickett, symbolToBuy, symbolToSell);
|
|
addToStructure(buyTickett, sellTickett, symbolToBuy, symbolToSell);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ Print("<><><><><><><> Timer End: ",timmer," <><><><><><><>");
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
//+------------------------------------------------------------------+
|
|
//+------------------------------------------------------------------+
|
|
|
//| |
|
|
//| |
|
|
@@ -228,7 +233,7 @@ string getSymbolWithLowestAsk()
|
|
|
for(int i = 0; i < totalGoldPairs; i++)
|
|
for(int i = 0; i < totalGoldPairs; i++)
|
|
|
{
|
|
{
|
|
|
double currentAsk = SymbolInfoDouble(goldPairs[i], SYMBOL_ASK);
|
|
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)
|
|
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;
|
|
return lowestSymbol;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -257,7 +262,7 @@ string getSymbolWithHighestBid()
|
|
|
for(int i = 0; i < totalGoldPairs; i++)
|
|
for(int i = 0; i < totalGoldPairs; i++)
|
|
|
{
|
|
{
|
|
|
double currentBid = SymbolInfoDouble(goldPairs[i], SYMBOL_BID);
|
|
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)
|
|
if(currentBid > highestBid)
|
|
|
{
|
|
{
|
|
|
highestBid = currentBid;
|
|
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;
|
|
return highestSymbol;
|
|
|
}
|
|
}
|
|
|
//+------------------------------------------------------------------+
|
|
//+------------------------------------------------------------------+
|
|
@@ -303,15 +308,24 @@ void checkBasketTakeProfit()
|
|
|
{
|
|
{
|
|
|
combinationProfit += PositionGetDouble(POSITION_PROFIT) + PositionGetDouble(POSITION_SWAP);
|
|
combinationProfit += PositionGetDouble(POSITION_PROFIT) + PositionGetDouble(POSITION_SWAP);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if(combinationProfit >= basketTakeProfit)
|
|
if(combinationProfit >= basketTakeProfit)
|
|
|
{
|
|
{
|
|
|
Print("Combination TP hit: Closing trades. Profit = ", combinationProfit);
|
|
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);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|