C# - Where can we access the chart color preferences like Down Bar, Background, etc.?
Color myColor = ???
Thanks...
Color myColor = ???
Thanks...
Rename
Are you looking for ChartDisplaySettings? It's documented with examples in the QuickRef.
The ChartDisplaySettings class isn't easy to find in the QuickRef because it's described in SetChartDrawingOptions. We should probably break out that class and make a reference to SetChartDrawingOptions.
I don't see a way to access the preferences, but the above gives your strategy all the control to customize just about everything.
I don't see a way to access the preferences, but the above gives your strategy all the control to customize just about everything.
If you're looking for color names you can pass into your WL graphic calls, check out this website. https://www.w3schools.com/colors/colors_groups.asp For example, Color.Green and Color.OrangeRed below:
CODE:
PlotTimeSeriesLine(decorrelated, bars.Symbol + " decorrelated", "decorrelated", Color.Green, 2, LineStyles.Solid); DrawHeaderText("Buy " + bars.Synbol + (idx+1).ToString(" @bar 000: ") + topBuysString.ToString(), Color.OrangeRed, 10, "decorrelated");
Thanks Cone and Ticker... The goal is the apply colors from the preference rather than the current code... casting system colors... RJ
This will do it - some undocumented parts of the framework here, thanks for blazing this trail! We do have an internal task issue to document these :)
CODE:
using WealthLab.Backtest; using System.Drawing; using WealthLab.Core; using WealthLab.ChartWPF; using WealthLab.WPF; namespace WealthScript1 { public class MyStrategy : UserStrategyBase { //Initialize public override void Initialize(BarHistory bars) { //get the current ChartPreferences (theme) ChartPreferences cp = ChartThemeFactory.SelectedTheme; //they are WPF Colors, so use this extension method to convert them to System.Drawing Colors Color colorUpBars = cp.ColorUpBar.ToGdiColor(); Color colorDownBars = cp.ColorDownBar.ToGdiColor(); } //Execute public override void Execute(BarHistory bars, int idx) { if (OpenPositions.Count == 0) { } else { } } //private members } }
Your Response
Post
Edit Post
Login is required