Fill colors
27 Nov 2018, 07:18
Dear Panagiotis, hi!
How do you fill , let us say, rectangle with color?
Regards,
Sasha
Replies
ctid+customer-374624
14 Dec 2019, 22:17
RE:
Thank you very much for the very helpfull example! For a beginner like myself, it is sometimes quite impossible to figure out the actual code from API reference.
Could any tell how can I draw histograms with opacity? I have :
[Output("Histogram Down", PlotType = PlotType.Histogram, LineColor = "Red")]
public IndicatorDataSeries HistogramNegative { get; set; }
How can I use in this public output parameter definition the below opacity setting?:
Color color = Color.FromArgb(50, Color.Red);
@ctid+customer-374624
PanagiotisCharalampous
16 Dec 2019, 09:01
RE:
Hi Jan,
You cannot apply a color for an indicator series on runtime. You can only apply it on declaration. To apply opacity, you can set a HEX code as a color. See below
[Output("Histogram Down", PlotType = PlotType.Histogram, LineColor = "#32FF0000")]
Best Regards,
Panagiotis
@PanagiotisCharalampous

afhacker
27 Nov 2018, 08:35
Hi Alexander,
Anytime you call chart class "Draw***" methods the method returns back the object, so suppose you have called the "DrawRectangle" method and you want to make it filled or interactive:
public override void Calculate(int index) { if (IsLastBar) { // Here we are making the color transparent Color color = Color.FromArgb(50, Color.Blue); // you can use var instead of class name ChartRectangle rectangle = Chart.DrawRectangle("rectangle", index - 40, MarketSeries.Low[index - 40], index, MarketSeries.High[index - 40], color, 1, LineStyle.Dots); // This will fill the object rectangle.IsFilled = true; // This will allow the user to modify the object rectangle.IsInteractive = true; } }The above code only works on cTrader 3.3 or above.
The way Spotware is designed the new chart drawing isn't good enough or at least that's how I think, I liked it to be like this:
public override void Calculate(int index) { if (IsLastBar) { ChartRectangle rectangle = new ChartRectangle { Name = "rectangle", FirstBarIndex = index - 40, SecondBarIndex = index, High = MarketSeries.High[index - 40], Low = MarketSeries.Low[index - 40], Color = Color.FromArgb(50, Color.Blue), Thickness = 1, LineStyle = LineStyle.Dots, IsFilled = true, IsInteractive = true }; Chart.Objects.Add(rectangle); } }That way we were able to create our own chart object classes by inheriting from current object classes and it was opening the door for more creative ideas.
@afhacker