WA
Topics
03 Dec 2024, 19:17
194
2
19 Sep 2024, 23:40
262
1
30 Aug 2024, 11:09
0
224
0
25 Aug 2024, 22:18
302
2
20 Aug 2024, 00:57
407
5
15 Aug 2024, 13:12
0
225
0
15 Aug 2024, 00:14
278
2
28 Jul 2024, 21:14
283
0
23 Jul 2024, 17:30
0
310
0
02 Jun 2024, 00:49
2
464
3
23 May 2024, 06:56
335
0
17 May 2024, 22:47
393
0
14 Apr 2024, 00:05
457
4
15 Jan 2024, 06:08
577
3
20 Sep 2023, 04:43
639
3
20 Jul 2023, 22:34
778
2
12 Jun 2023, 12:06
649
3
08 Jun 2023, 09:44
707
2
08 Jun 2023, 09:00
622
1
23 Mar 2023, 05:13
790
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