Skip to content

ColorTheme

Summary

Represents the color theme.

Signature

1
public enum ColorTheme

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
24
25
26
27
28
29
30
31
32
 using cAlgo.API;
 namespace cAlgo
 {
     // This sample indicator shows how to use ColorTheme Enum which is the color of platform theme on your indicators/cBots
     [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class ColorThemeSample : Indicator
     {
         protected override void Initialize()
         {
             ChangeChartBackgroundColorBasedOnTheme(Application.ColorTheme);
             Application.ColorThemeChanged += Application_ColorThemeChanged;
         }
         private void Application_ColorThemeChanged(ColorThemeChangeEventArgs obj)
         {
             ChangeChartBackgroundColorBasedOnTheme(obj.ColorTheme);
         }
         private void ChangeChartBackgroundColorBasedOnTheme(ColorTheme colorTheme)
         {
             if (colorTheme == ColorTheme.Dark)
             {
                 Chart.ColorSettings.BackgroundColor = Color.White;
             }
             else if (colorTheme == ColorTheme.Light)
             {
                 Chart.ColorSettings.BackgroundColor = Color.Black;
             }
         }
         public override void Calculate(int index)
         {
         }
     }
 }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
 import clr
 clr.AddReference("cAlgo.API")
 from cAlgo.API import *
 class Test():    
     def initialize(self):
         self.change_chart_background_color_based_on_theme(api.Application.ColorTheme)
         api.Application.ColorThemeChanged += self.on_color_theme_changed
     def change_chart_background_color_based_on_theme(self, colorTheme):
         if colorTheme == ColorTheme.Dark:
             api.Chart.ColorSettings.BackgroundColor = Color.White
         elif colorTheme == ColorTheme.Light:
             api.Chart.ColorSettings.BackgroundColor = Color.Black
     def on_color_theme_changed(self, args):
         self.change_chart_background_color_based_on_theme(args.ColorTheme)

See Also

Fields

Dark

Summary

The dark color theme.

Signature

1
ColorTheme.Dark;

Return Value

ColorTheme

Light

Summary

The light color theme.

Signature

1
ColorTheme.Light;

Return Value

ColorTheme