usingcAlgo.API;namespacecAlgo{// This indicator allows you to change chart colors via chart controls[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]publicclassChartColorSettingsSample:Indicator{privateTextBox_askPriceLineColorTextBox;privateTextBox_bidPriceLineColorTextBox;privateTextBox_backgroundColorTextBox;protectedoverridevoidInitialize(){vargrid=newGrid(10,2){BackgroundColor=Color.Gold,Opacity=0.6,HorizontalAlignment=HorizontalAlignment.Left,VerticalAlignment=VerticalAlignment.Bottom};varstyle=newStyle();style.Set(ControlProperty.Margin,5);style.Set(ControlProperty.FontWeight,FontWeight.ExtraBold);style.Set(ControlProperty.ForegroundColor,Color.Red);style.Set(ControlProperty.MinWidth,100);grid.AddChild(newTextBlock{Text="Ask Price Line Color",Style=style},0,0);_askPriceLineColorTextBox=newTextBox{Text=Chart.ColorSettings.AskPriceLineColor.ToString(),Style=style};grid.AddChild(_askPriceLineColorTextBox,0,1);grid.AddChild(newTextBlock{Text="Bid Price Line Color",Style=style},1,0);_bidPriceLineColorTextBox=newTextBox{Text=Chart.ColorSettings.BidPriceLineColor.ToString(),Style=style};grid.AddChild(_bidPriceLineColorTextBox,1,1);grid.AddChild(newTextBlock{Text="Background Color",Style=style},2,0);_backgroundColorTextBox=newTextBox{Text=Chart.ColorSettings.BackgroundColor.ToString(),Style=style};grid.AddChild(_backgroundColorTextBox,2,1);varchangeButton=newButton{Text="Change",Style=style};changeButton.Click+=ChangeButton_Click;grid.AddChild(changeButton,9,0);Chart.AddControl(grid);}privatevoidChangeButton_Click(ButtonClickEventArgsobj){Chart.ColorSettings.AskPriceLineColor=GetColor(_askPriceLineColorTextBox.Text);Chart.ColorSettings.BidPriceLineColor=GetColor(_bidPriceLineColorTextBox.Text);Chart.ColorSettings.BackgroundColor=GetColor(_backgroundColorTextBox.Text);}privateColorGetColor(stringcolorString,intalpha=255){varcolor=colorString[0]=='#'?Color.FromHex(colorString):Color.FromName(colorString);returnColor.FromArgb(alpha,color);}publicoverridevoidCalculate(intindex){}}}
importclrclr.AddReference("cAlgo.API")fromcAlgo.APIimport*classTest():defget_text_block(self,text):textBlock=TextBlock()textBlock.Text=texttextBlock.Style=self.stylereturntextBlockdefget_color(self,colorString,alpha=255):color=Color.FromHex(colorString)ifcolorString[0]=='#'elseColor.FromName(colorString)returnColor.FromArgb(alpha,color)defon_change_button_clicked(self,args):api.Chart.ColorSettings.AskPriceLineColor=self.get_color(self.askPriceLineColorTextBox.Text)api.Chart.ColorSettings.BidPriceLineColor=self.get_color(self.bidPriceLineColorTextBox.Text)api.Chart.ColorSettings.BackgroundColor=self.get_color(self.backgroundColorTextBox.Text)definitialize(self):grid=Grid(10,2)grid.BackgroundColor=Color.Goldgrid.Opacity=0.6grid.HorizontalAlignment=HorizontalAlignment.Leftgrid.VerticalAlignment=VerticalAlignment.Bottomself.style=Style()self.style.Set(ControlProperty.Margin,5)self.style.Set(ControlProperty.FontWeight,FontWeight.ExtraBold)self.style.Set(ControlProperty.ForegroundColor,Color.Red)self.style.Set(ControlProperty.MinWidth,100)grid.AddChild(self.get_text_block("Ask Price Line Color"),0,0)self.askPriceLineColorTextBox=self.get_text_block(str(api.Chart.ColorSettings.AskPriceLineColor))grid.AddChild(self.askPriceLineColorTextBox,0,1)grid.AddChild(self.get_text_block("Bid Price Line Color"),1,0)self.bidPriceLineColorTextBox=self.get_text_block(str(api.Chart.ColorSettings.BidPriceLineColor))grid.AddChild(self.bidPriceLineColorTextBox,1,1)grid.AddChild(self.get_text_block("Background Color"),2,0)self.backgroundColorTextBox=self.get_text_block(str(api.Chart.ColorSettings.BackgroundColor))grid.AddChild(self.backgroundColorTextBox,2,1)changeButton=Button()changeButton.Text="Change"changeButton.Style=self.stylechangeButton.Click+=self.on_change_button_clickedgrid.AddChild(changeButton,9,0)api.Chart.AddControl(grid)
Properties
BackgroundColor
Summary
Gets or sets the color of the chart background.
Signature
1
publicabstractColorBackgroundColor{get;set;}
Return Value
Color
ForegroundColor
Summary
Gets or sets the color of the chart foreground.
Signature
1
publicabstractColorForegroundColor{get;set;}
Return Value
Color
GridLinesColor
Summary
Gets or sets the color of the grid lines.
Signature
1
publicabstractColorGridLinesColor{get;set;}
Return Value
Color
PeriodSeparatorColor
Summary
Gets or sets the color of the period separator.
Signature
1
publicabstractColorPeriodSeparatorColor{get;set;}
Return Value
Color
BullOutlineColor
Summary
Gets or sets the color of the bull candle or bar outline.
Signature
1
publicabstractColorBullOutlineColor{get;set;}
Return Value
Color
BearOutlineColor
Summary
Gets or sets the color of the bear candle or bar outline.
Signature
1
publicabstractColorBearOutlineColor{get;set;}
Return Value
Color
BullFillColor
Summary
Gets or sets the color of the bull candle fill.
Signature
1
publicabstractColorBullFillColor{get;set;}
Return Value
Color
BearFillColor
Summary
Gets or sets the color of the bear candle fill.
Signature
1
publicabstractColorBearFillColor{get;set;}
Return Value
Color
TickVolumeColor
Summary
Gets or sets the color of the tick volume.
Signature
1
publicabstractColorTickVolumeColor{get;set;}
Return Value
Color
WinningDealColor
Summary
Gets or sets the color of the winning deal.
Signature
1
publicabstractColorWinningDealColor{get;set;}
Return Value
Color
LosingDealColor
Summary
Gets or sets the color of the losing deal.
Signature
1
publicabstractColorLosingDealColor{get;set;}
Return Value
Color
AskPriceLineColor
Summary
Gets or sets the color of the ask price line.
Signature
1
publicabstractColorAskPriceLineColor{get;set;}
Return Value
Color
BidPriceLineColor
Summary
Gets or sets the color of the bid price line.
Signature
1
publicabstractColorBidPriceLineColor{get;set;}
Return Value
Color
BuyColor
Summary
Gets or sets the color of Buy positions and orders.
Signature
1
publicabstractColorBuyColor{get;set;}
Return Value
Color
SellColor
Summary
Gets or sets the color of Sell order positions and orders.