UM
Topics
15 May 2023, 10:25
505
2
15 May 2023, 10:17
516
1
27 Jan 2022, 20:00
1276
5
17 Jan 2022, 19:22
973
3
07 Oct 2021, 19:10
1445
4
18 Sep 2021, 18:40
877
2
Replies
umadrat2012
08 Oct 2021, 07:48
RE:
amusleh said:
Hi,
Try this sample cBot:
using System; using System.Linq; using cAlgo.API; using System.Globalization; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { private TimeSpan _closeTime; [Parameter("Close Time", DefaultValue = "17:00:00")] public string CloseTime { get; set; } [Parameter("Close Day", DefaultValue = DayOfWeek.Friday)] public DayOfWeek CloseDay { get; set; } protected override void OnStart() { if (TimeSpan.TryParse(CloseTime, CultureInfo.InvariantCulture, out _closeTime) == false) { Print("Incorrect close time value"); Stop(); } Timer.Start(1); } protected override void OnTimer() { if (Server.Time.DayOfWeek == CloseDay && Server.Time.TimeOfDay >= _closeTime) { var positionsCopy = Positions.ToArray(); foreach (var position in Positions) { ClosePosition(position); } } } } }
Thank you very much, implementing this into my cbot seems to be working
@umadrat2012
umadrat2012
28 Jan 2022, 11:05
RE: thank you, how would the code look like if my cbot trades multiple currencies at the same time?
amusleh said:
@umadrat2012