identify that the user place a ChartTrendLine on the chart
Created at 22 Jul 2021, 09:06
identify that the user place a ChartTrendLine on the chart
22 Jul 2021, 09:06
Is there an event or any other way to identify that the user place a ChartTrendLine on the chart?
Thanks
amusleh
22 Jul 2021, 10:09
Hi,
Yes, you can use the Chart.ObjectAdded event and then check the type of added object if it's a trend line or not.
using cAlgo.API; using System.Linq; namespace cAlgo { [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class Test : Indicator { protected override void Initialize() { Chart.ObjectsAdded += Chart_ObjectsAdded; } private void Chart_ObjectsAdded(ChartObjectsAddedEventArgs obj) { if (obj.ChartObjects.All(chartObject => chartObject.ObjectType == ChartObjectType.TrendLine)) { // If all of the new added objects were trend line the code here will be executed } } public override void Calculate(int index) { } } }
@amusleh