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

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 newOpenedBar = 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)
         {
         }
     }
 }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
 import clr
 clr.AddReference("cAlgo.API")
 from cAlgo.API import *
 class Test():    
     def initialize(self):
         api.Bars.BarOpened += self.on_bar_opened
     def on_bar_opened(self, args):
         # Or you can use args.Bars[Bars.Count - 1] or args.Bars.Last(0)
         newOpenedBar = args.Bars.LastBar
          # Or you can use args.Bars[Bars.Count - 2]
         closedBar = args.Bars.Last(1)

See Also

Properties

Bars

Summary

Gets the bar data.

Signature

1
public Bars Bars {get;}

Return Value

Bars

Related Tutorials