Asynchronous closing of positions
Created at 29 Nov 2017, 11:48
ST
Asynchronous closing of positions
29 Nov 2017, 11:48
Can someone please advise how I amend the following code to close all positions at once using the asynchronous method?
Thanks.
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot()] public class PCAccountStophit : Robot { [Parameter(DefaultValue = "Account Stop Hit cBot")] public string cBotLabel { get; set; } [Parameter()] public DataSeries SourceSeries { get; set; } [Parameter("TargetBalance", DefaultValue = 10000)] public double TargetBalance { get; set; } protected override void OnStart() { } protected override void OnBar() { // Some condition to close all positions if (Account.Equity <= TargetBalance) foreach (var position in Positions) ClosePosition(position); } } }
PanagiotisCharalampous
29 Nov 2017, 11:57
Dear Trader,
You can use the ClosePositionAsync method. See below
Let me know if this helps you.
Best Regards,
Panagiotis
@PanagiotisCharalampous