milsenace
milsenace 27 Jan 2023, 14:56 ( Updated at: 27 Jan 2023, 14:57 )
I could build it now without any warnings or Failures with this version:
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class DrawdownRecorder : Robot { [Parameter(DefaultValue = 24)] public int RecordingInterval { get; set; } private double _previousHighWaterMark; private DateTime _lastRecordTime; private string _drawdownLabel; protected override void OnStart() { _previousHighWaterMark = Account.Equity; _lastRecordTime = Server.Time; _drawdownLabel = "Drawdown"; } protected override void OnTick() { if (Server.Time.Hour == 0 && Server.Time.Minute == 0 && Server.Time.Second == 0) { _lastRecordTime = Server.Time; _previousHighWaterMark = Account.Equity; } else if ((Server.Time - _lastRecordTime).TotalHours >= RecordingInterval) { double currentEquity = Account.Equity; double drawdown = _previousHighWaterMark - currentEquity; _previousHighWaterMark = Math.Max(_previousHighWaterMark, currentEquity); Chart.RemoveObject(_drawdownLabel); Chart.DrawStaticText(_drawdownLabel, "24 hour Drawdown : " + drawdown, VerticalAlignment.Top, HorizontalAlignment.Right, Color.Yellow); _lastRecordTime = Server.Time; } } } }
But when I start it nothing is displayed on the Chart :(
milsenace
27 Jan 2023, 14:56 ( Updated at: 27 Jan 2023, 14:57 )
I could build it now without any warnings or Failures with this version:
But when I start it nothing is displayed on the Chart :(
@milsenace