PaintBar  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
riverTrader
Posts: 64
Joined: 15 Aug 2011
Has thanked: 3 times
Been thanked: 50 times

PaintBar

Postby riverTrader » 31 Jul 2012

..and so it begins

I've been reading through the classDocs. It does not appear mc.net has a PaintBar equivalent plot type. Is this correct? Sure would be nice.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: PaintBar

Postby Henry MultiСharts » 01 Aug 2012

Hello riverTrader,

There is no equivalent for PaintBar in MultiCharts .Net.
PaintBar is just a combination of four plots. The same functionality can be easily created in MultiCharts .Net using the following code:

Code: Select all

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{
public class PPB : IndicatorObject
{
public PPB(object _ctx):base(_ctx){}
private IPlotObject plot1;
private IPlotObject plot2;
private IPlotObject plot3;
private IPlotObject plot4;

protected override void Create()
{
plot1 = AddPlot(new PlotAttributes("Open", EPlotShapes.LeftTick, Color.Red));
plot2 = AddPlot(new PlotAttributes("High", EPlotShapes.BarHigh, Color.Red));
plot3 = AddPlot(new PlotAttributes("Low", EPlotShapes.BarLow, Color.Red));
plot4 = AddPlot(new PlotAttributes("Close", EPlotShapes.RightTick, Color.Red));
}
protected override void StartCalc() {
// assign inputs
}
protected override void CalcBar(){

plot1.Set(Bars.Open[0]);
plot2.Set(Bars.High[0]);
plot3.Set(Bars.Low[0]);
plot4.Set(Bars.Close[0]);
}
}
}
Attachments
PPB.zip
(1.22 KiB) Downloaded 680 times

riverTrader
Posts: 64
Joined: 15 Aug 2011
Has thanked: 3 times
Been thanked: 50 times

Re: PaintBar

Postby riverTrader » 04 Aug 2012

Thanks. The code you provided draws a standard bar.

Is there a way to use the plots to draw a candlestick?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: PaintBar

Postby Henry MultiСharts » 06 Aug 2012

Just change the chart style to candlestick in Format->Instrument tab->Style->Chart type to Candlestick and the indicator will change to Candlesticks as well.

bluejack
Posts: 42
Joined: 02 Aug 2012
Has thanked: 25 times
Been thanked: 27 times

Re: PaintBar

Postby bluejack » 06 Aug 2012

Could you provide an example which shows blue bars if Close > MA and red bars if Close < MA?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: PaintBar  [SOLVED]

Postby Henry MultiСharts » 07 Aug 2012

Could you provide an example which shows blue bars if Close > MA and red bars if Close < MA?
Please find the example attached.
Attachments
PPB_MA.pln
(1.42 KiB) Downloaded 1095 times

bluejack
Posts: 42
Joined: 02 Aug 2012
Has thanked: 25 times
Been thanked: 27 times

Re: PaintBar

Postby bluejack » 07 Aug 2012

Works nicely as indicator if its exactly overlayed over the standard barchart.

Is there a way to influence the drawing of a bar directly? That would be awesome. In other words is it possible to take full control over drawing a bar or candle?

Like drawing candles with gradient colors depending on indicators or whatever I would it to look like? Is it possible with IChartCustomDrawer?

Really if that functionality is possible then MC.Net will top everything.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: PaintBar

Postby Henry MultiСharts » 08 Aug 2012

Works nicely as indicator if its exactly overlayed over the standard barchart.

Is there a way to influence the drawing of a bar directly? That would be awesome. In other words is it possible to take full control over drawing a bar or candle?
Like drawing candles with gradient colors depending on indicators or whatever I would it to look like? Is it possible with IChartCustomDrawer?
Yes that is possible to plot candles with gradient colors.
Please find a sample attached.
Attachments
CustomDrawGradientBar.pln
(1.89 KiB) Downloaded 1048 times

bluejack
Posts: 42
Joined: 02 Aug 2012
Has thanked: 25 times
Been thanked: 27 times

Re: PaintBar

Postby bluejack » 08 Aug 2012

Really awesome! Very cool.

The only drawback it seems if its made as custom draw that its no real object (or plot) in the chart. So you can't click with mouse on it directly to select it and change input parameters.

Is it possible to make PlotObjects (like the PPB_MA above) the same way? Fully custom drawn like you have shown but selectable by mouse? Or is it impossible due to inability of Multicharts to determine the hitbox for a mouseclick if its completely custom drawn?

It would be enough in my opinion if the interface IChartCustomDrawer would have a function like IsHit(int x, int y) to be implemented by the custom drawer which returns true if the drawn stuff is hit by the mouse. The DrawContext could give a hint that the drawn object is currently selected so drawing could be made a bit different to reflect that fact.

Anyway, I'm already happy and impressed enough about what you have shown here :-)

riverTrader
Posts: 64
Joined: 15 Aug 2011
Has thanked: 3 times
Been thanked: 50 times

Re: PaintBar

Postby riverTrader » 08 Aug 2012

Excellent example! Thank you.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: PaintBar

Postby Henry MultiСharts » 09 Aug 2012

Really awesome! Very cool.

The only drawback it seems if its made as custom draw that its no real object (or plot) in the chart. So you can't click with mouse on it directly to select it and change input parameters.

Is it possible to make PlotObjects (like the PPB_MA above) the same way? Fully custom drawn like you have shown but selectable by mouse? Or is it impossible due to inability of Multicharts to determine the hitbox for a mouseclick if its completely custom drawn?

It would be enough in my opinion if the interface IChartCustomDrawer would have a function like IsHit(int x, int y) to be implemented by the custom drawer which returns true if the drawn stuff is hit by the mouse. The DrawContext could give a hint that the drawn object is currently selected so drawing could be made a bit different to reflect that fact.

Anyway, I'm already happy and impressed enough about what you have shown here :-)
This feature has not been implemented yet. You may want to submit a feature request to the Project Management of our web site so other users can vote for it: https://www.multicharts.com/pm/


Return to “MultiCharts .NET”