|
|
@@ -33,12 +33,12 @@ input int magicNo = 333; //
|
|
33
|
33
|
input double lotSize = 0.01; // Lot Size
|
|
34
|
34
|
input bool enableBasketTP = true; // Enable Basket TP
|
|
35
|
35
|
input double basketTakeProfit = 1.0; // Basket Take Profit
|
|
36
|
|
-input int maxOpenPositions = 3; // Maximum number of open positions
|
|
|
36
|
+input int maxOpenPositions = 3; // Maximum number of Combinations
|
|
37
|
37
|
|
|
38
|
38
|
|
|
39
|
39
|
string goldPairs[];
|
|
40
|
40
|
int totalGoldPairs = 0;
|
|
41
|
|
-
|
|
|
41
|
+int timmer = 0;
|
|
42
|
42
|
//+------------------------------------------------------------------+
|
|
43
|
43
|
//| Expert initialization function |
|
|
44
|
44
|
//+------------------------------------------------------------------+
|
|
|
@@ -88,6 +88,8 @@ void OnTick()
|
|
88
|
88
|
void OnTimer()
|
|
89
|
89
|
{
|
|
90
|
90
|
//---
|
|
|
91
|
+ timmer++;
|
|
|
92
|
+ Print("<><><><><><><> Timer Start: ",timmer," <><><><><><><>");
|
|
91
|
93
|
|
|
92
|
94
|
removeFromStruct();
|
|
93
|
95
|
|
|
|
@@ -124,6 +126,9 @@ void OnTimer()
|
|
124
|
126
|
{
|
|
125
|
127
|
addToStructure(buyTickett, sellTickett, symbolToBuy, symbolToSell);
|
|
126
|
128
|
}
|
|
|
129
|
+
|
|
|
130
|
+ Print("<><><><><><><> Timer End: ",timmer," <><><><><><><>");
|
|
|
131
|
+
|
|
127
|
132
|
}
|
|
128
|
133
|
//+------------------------------------------------------------------+
|
|
129
|
134
|
//| |
|
|
|
@@ -228,7 +233,7 @@ string getSymbolWithLowestAsk()
|
|
228
|
233
|
for(int i = 0; i < totalGoldPairs; i++)
|
|
229
|
234
|
{
|
|
230
|
235
|
double currentAsk = SymbolInfoDouble(goldPairs[i], SYMBOL_ASK);
|
|
231
|
|
- Print("Pair:",goldPairs[i]," Price Ask:",currentAsk);
|
|
|
236
|
+ Print(" Ask Price: ",currentAsk," || on Pair: ",goldPairs[i]);
|
|
232
|
237
|
|
|
233
|
238
|
if(currentAsk < lowestAsk)
|
|
234
|
239
|
{
|
|
|
@@ -237,7 +242,7 @@ string getSymbolWithLowestAsk()
|
|
237
|
242
|
}
|
|
238
|
243
|
}
|
|
239
|
244
|
|
|
240
|
|
- Print("Lowest Ask Pair: ", lowestSymbol, " Lowest Ask: ", lowestAsk);
|
|
|
245
|
+ Print("Lowest Ask Pair: ", lowestSymbol, " || Lowest Ask: ", lowestAsk);
|
|
241
|
246
|
return lowestSymbol;
|
|
242
|
247
|
}
|
|
243
|
248
|
|
|
|
@@ -257,7 +262,7 @@ string getSymbolWithHighestBid()
|
|
257
|
262
|
for(int i = 0; i < totalGoldPairs; i++)
|
|
258
|
263
|
{
|
|
259
|
264
|
double currentBid = SymbolInfoDouble(goldPairs[i], SYMBOL_BID);
|
|
260
|
|
- Print("Pair:",goldPairs[i]," Price Bid:",currentBid);
|
|
|
265
|
+ Print(" Bid Price: ",currentBid," || on Pair: ",goldPairs[i]);
|
|
261
|
266
|
if(currentBid > highestBid)
|
|
262
|
267
|
{
|
|
263
|
268
|
highestBid = currentBid;
|
|
|
@@ -265,7 +270,7 @@ string getSymbolWithHighestBid()
|
|
265
|
270
|
}
|
|
266
|
271
|
}
|
|
267
|
272
|
|
|
268
|
|
- Print("Highest Bid Pair: ", highestSymbol, " Highest Bid: ", highestBid);
|
|
|
273
|
+ Print("Highest Bid Pair: ", highestSymbol, " || Highest Bid: ", highestBid);
|
|
269
|
274
|
return highestSymbol;
|
|
270
|
275
|
}
|
|
271
|
276
|
//+------------------------------------------------------------------+
|
|
|
@@ -303,15 +308,24 @@ void checkBasketTakeProfit()
|
|
303
|
308
|
{
|
|
304
|
309
|
combinationProfit += PositionGetDouble(POSITION_PROFIT) + PositionGetDouble(POSITION_SWAP);
|
|
305
|
310
|
}
|
|
306
|
|
-
|
|
|
311
|
+
|
|
307
|
312
|
if(combinationProfit >= basketTakeProfit)
|
|
308
|
313
|
{
|
|
309
|
314
|
Print("Combination TP hit: Closing trades. Profit = ", combinationProfit);
|
|
310
|
315
|
|
|
311
|
|
- trade.PositionClose(newTradeStore[i].buyTicket);
|
|
312
|
|
- Print("Buy Trade Closed: ", newTradeStore[i].buyTicket);
|
|
313
|
|
- trade.PositionClose(newTradeStore[i].sellTicket);
|
|
314
|
|
- Print("Sell Trade Closed: ", newTradeStore[i].sellTicket);
|
|
|
316
|
+ if(!trade.PositionClose(newTradeStore[i].buyTicket))
|
|
|
317
|
+ {
|
|
|
318
|
+ Print(" Error Closing Buy Trade : ", newTradeStore[i].buyTicket," ",GetLastError());
|
|
|
319
|
+ }
|
|
|
320
|
+ else
|
|
|
321
|
+ Print("Buy Trade Closed: ", newTradeStore[i].buyTicket);
|
|
|
322
|
+
|
|
|
323
|
+ if(!trade.PositionClose(newTradeStore[i].sellTicket))
|
|
|
324
|
+ {
|
|
|
325
|
+ Print(" Error Closing Sell Trade : ", newTradeStore[i].sellTicket," ",GetLastError());
|
|
|
326
|
+ }
|
|
|
327
|
+ else
|
|
|
328
|
+ Print("Sell Trade Closed: ", newTradeStore[i].sellTicket);
|
|
315
|
329
|
}
|
|
316
|
330
|
}
|
|
317
|
331
|
}
|