Skip to content

BarOpenedEventArgs

Summary

Provides data for the event when a new bar opened on the chart.

Signature

1
public class BarOpenedEventArgs

Namespace

cAlgo.API

Properties

Name Description
Bars { get; } Gets the bar data.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 using cAlgo.API;
 namespace cAlgo
 {
     // This example shows how to use the Bars object BarOpened event BarOpenedEventArgs
     [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class BarOpenedEventArgsSample : Indicator
     {
         protected override void Initialize()
         {
             Bars.BarOpened += Bars_BarOpened;
         }
         // This method will be called if a new bar opens
         // BarOpenedEventArgs has a Bars property the you can use to get Bars object
         private void Bars_BarOpened(BarOpenedEventArgs obj)
         {
             var newOpendBar = obj.Bars.LastBar; // Or you can use obj.Bars[Bars.Count - 1] or obj.Bars.Last(0)
             var closedBar = obj.Bars.Last(1); // Or you can use obj.Bars[Bars.Count - 2]
         }
         public override void Calculate(int index)
         {
         }
     }
 }

See Also


Last update: July 1, 2022

Comments