usingcAlgo.API;namespacecAlgo{// This sample indicator shows how to use IndicatorArea[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]publicclassIndicatorAreaSample:Indicator{privateTextBlock_indicatorAreaNumberTextBlock;protectedoverridevoidInitialize(){vargrid=newGrid(1,2){HorizontalAlignment=HorizontalAlignment.Center,VerticalAlignment=VerticalAlignment.Center,BackgroundColor=Color.Gold,Opacity=0.7,Width=200};grid.AddChild(newTextBlock{Text="Indicator Area #",Margin=5,FontWeight=FontWeight.ExtraBold,ForegroundColor=Color.Black},0,0);_indicatorAreaNumberTextBlock=newTextBlock{Margin=5,Text=Chart.IndicatorAreas.Count.ToString(),FontWeight=FontWeight.ExtraBold,ForegroundColor=Color.Black};grid.AddChild(_indicatorAreaNumberTextBlock,0,1);IndicatorArea.AddControl(grid);Chart.IndicatorAreaAdded+=Chart_IndicatorAreaAdded;Chart.IndicatorAreaRemoved+=Chart_IndicatorAreaRemoved;}privatevoidChart_IndicatorAreaRemoved(IndicatorAreaRemovedEventArgsobj){_indicatorAreaNumberTextBlock.Text=Chart.IndicatorAreas.Count.ToString();}privatevoidChart_IndicatorAreaAdded(IndicatorAreaAddedEventArgsobj){_indicatorAreaNumberTextBlock.Text=Chart.IndicatorAreas.Count.ToString();}publicoverridevoidCalculate(intindex){}}}
importclrclr.AddReference("cAlgo.API")fromcAlgo.APIimport*classTest():defget_text_block(self,text):textBlock=TextBlock()textBlock.Margin=Thickness(5)textBlock.Text=texttextBlock.FontWeight=FontWeight.ExtraBoldtextBlock.ForegroundColor=Color.BlackreturntextBlockdefupdate_indicators_area_count(self):self.indicatorAreaNumberTextBlock.Text=str(api.Chart.IndicatorAreas.Count)definitialize(self):grid=Grid(1,2)grid.HorizontalAlignment=HorizontalAlignment.Centergrid.VerticalAlignment=VerticalAlignment.Centergrid.BackgroundColor=Color.Goldgrid.Opacity=0.7grid.Width=200grid.AddChild(self.get_text_block("Indicator Area #"),0,0)self.indicatorAreaNumberTextBlock=self.get_text_block(str(api.Chart.IndicatorAreas.Count))grid.AddChild(self.indicatorAreaNumberTextBlock,0,1)api.IndicatorArea.AddControl(grid)api.Chart.IndicatorAreaAdded+=lambda_:self.update_indicators_area_count()api.Chart.IndicatorAreaRemoved+=lambda_:self.update_indicators_area_count()