Topics
03 Dec 2024, 19:17
108
2
19 Sep 2024, 23:40
192
1
30 Aug 2024, 11:09
0
181
0
25 Aug 2024, 22:18
221
2
20 Aug 2024, 00:57
358
5
15 Aug 2024, 13:12
0
183
0
15 Aug 2024, 00:14
209
2
28 Jul 2024, 21:14
203
0
23 Jul 2024, 17:30
0
256
0
02 Jun 2024, 00:49
2
388
3
23 May 2024, 06:56
278
0
17 May 2024, 22:47
322
0
14 Apr 2024, 00:05
388
4
15 Jan 2024, 06:08
510
3
20 Sep 2023, 04:43
560
3
20 Jul 2023, 22:34
711
2
12 Jun 2023, 12:06
592
3
08 Jun 2023, 09:44
645
2
08 Jun 2023, 09:00
568
1
23 Mar 2023, 05:13
732
1
Replies
Waxy
23 Feb 2016, 00:39
// For positions if (Positions != null) { foreach (var pos in Positions) { if (_pos.SymbolCode == "EURUSD") { //do stuff here } } } //----------------- // For pending orders if (PendingOrders != null) { foreach (var pending in PendingOrders) { if (pending.SymbolCode == "EURUSD") { //Do stuff here } } }
@Waxy
Waxy
13 May 2015, 03:39
Here's the code, please notice, you didn't say anything about the 1st position being closed.
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class XROpenPositionsinOpposed : Robot { [Parameter("Label", DefaultValue = "MyLabel")] public string MyLabel { get; set; } bool _isSent; protected override void OnStart() { ExecuteMarketOrder(TradeType.Buy, Symbol, 10000, MyLabel); } protected override void OnTick() { var x = Positions.Find(MyLabel); if (x != null && !_isSent) { if (x.TradeType == TradeType.Buy) { PlaceStopOrder(TradeType.Sell, Symbol, (x.Volume * 2), x.EntryPrice - 20 * Symbol.PipSize); _isSent = !_isSent; } else { PlaceStopOrder(TradeType.Buy, Symbol, (x.Volume * 2), x.EntryPrice + 20 * Symbol.PipSize); _isSent = !_isSent; } } } } }
@Waxy
Waxy
01 Mar 2016, 22:37
Thank you guys, I hope they add this functionality in the future soon.
Also croucrou that's a GUI extension and not sure how to do it.
@Waxy