IChartCustomDrawer Interface

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

IChartCustomDrawer Interface

Postby riverTrader » 04 Aug 2012

Okay this is a weekend question, but I'm having fun.

Looking into the IChartCustomDrawer interface I see that I am to provide a ChartPoint to specify the point on the chart to locate the rectangle/graphic.

How do I get the ChartPoint for a given bar /dateTime? And secondly, how do I get a chartpoint for a bar/dateTime if the object I am drawing is not on the chart itself, but on a second pane? (eg. a bar graph below the main chart).

given a bar chartpoint, is there a way I can find what the rectangle would be for the entire bar y-axis (ie. the width == barWidth, height == chartHeight).

no hurry on this one.

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

Re: IChartCustomDrawer Interface

Postby riverTrader » 05 Aug 2012

One more question: can I get the rectangle for the entire (inner) chart area?

I'm thinking I may want to just use the chart space altogether, and either place the graphic above or below the chart graphics.

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

Re: IChartCustomDrawer Interface

Postby bluejack » 06 Aug 2012

A ChartPoint is only a structure consisting of Price and Time.

You have to create a new ChartPoint structure and set the price and time fields e.g. with help of the Bars object.

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

Re: IChartCustomDrawer Interface

Postby riverTrader » 06 Aug 2012

Thanks. I spent some time looking through the code for Market_Depth_on_Chart_2_.Indicator.CS and got a lot of questions answered.

User avatar
Henry MultiСharts
Posts: 8471
Joined: 25 Aug 2011
Has thanked: 1210 times
Been thanked: 2717 times

Re: IChartCustomDrawer Interface

Postby Henry MultiСharts » 06 Aug 2012

Hello riverTrader,

When you are calling EventDraw you can send the DrawContext parameter. You can specify and convert regular coordinates into bar coordinates with it. Check "DrawContext Environment" in the help file for more information.

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

Re: IChartCustomDrawer Interface

Postby bluejack » 06 Aug 2012

Henry Multicharts wrote:When you are calling EventDraw you can send the DrawContext parameter.

You meant when you use the callback EventDraw you *get* a DrawContext object which in turn can be used to convert pixels to chart space and versa.

Traderji
Posts: 41
Joined: 08 Mar 2012
Has thanked: 6 times
Been thanked: 17 times

Re: IChartCustomDrawer Interface

Postby Traderji » 07 Aug 2012

@rivertrader please post some sample code when you get working! I am pretty new to programming so sample code really helps. I got my price and time values for the two rectangle coordinates but quite confused on how to proceed.

User avatar
JoshM
Posts: 2084
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1525 times
Been thanked: 1483 times
Contact:

Re: IChartCustomDrawer Interface

Postby JoshM » 13 Aug 2012

Can someone share a code example of using a DrawContext object, for example to draw a text box?

I couldn't find one included in the default indicators, and while the documentation is handy for referencing, it lacks an example how one should implement DrawContext from scratch.

Traderji
Posts: 41
Joined: 08 Mar 2012
Has thanked: 6 times
Been thanked: 17 times

Re: IChartCustomDrawer Interface

Postby Traderji » 13 Aug 2012

JoshM wrote:I couldn't find one included in the default indicators, and while the documentation is handy for referencing, it lacks an example how one should implement DrawContext from scratch.



I couldn't agree more. There needs to be plenty of examples in the documentation for people to work with.

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 485 times

Re: IChartCustomDrawer Interface

Postby Dave Masalov » 14 Aug 2012

We will provide you with the examples shortly.
These users thanked the author Dave Masalov for the post (total 4):
JoshMbluejackTraderjiTIKITRADER

User avatar
JoshM
Posts: 2084
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1525 times
Been thanked: 1483 times
Contact:

Re: IChartCustomDrawer Interface

Postby JoshM » 18 Aug 2012

Dave Masalov wrote:We will provide you with the examples shortly.

Could you also provide an example of how to loop through backtest trades done by a signal?

The documentation is for me as beginner not completely clear on this. Should I use ITradingData, since that's the 'trade data access interface', or the ITradeManager, but the IPositions is also described as something that holds positions data. The IOrders interface could also work, since that is an 'orders data' source interface. But clicking through these, I couldn't find a property that, say, returned the entry price.

Anyway, just to highlight that an example would be very much appreciated. :)

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 485 times

Re: IChartCustomDrawer Interface

Postby Dave Masalov » 30 Aug 2012

Could you also provide an example of how to loop through backtest trades done by a signal?


JoshM,

Do you mean you want to send orders in a loop on one bar in backtesting?

arjfca
Posts: 1273
Joined: 23 Nov 2010
Has thanked: 720 times
Been thanked: 222 times

Re: IChartCustomDrawer Interface

Postby arjfca » 08 May 2013

Dave Masalov wrote:We will provide you with the examples shortly.

Hello

An old post, Is an example of code has been published?

Martin

User avatar
Henry MultiСharts
Posts: 8471
Joined: 25 Aug 2011
Has thanked: 1210 times
Been thanked: 2717 times

Re: IChartCustomDrawer Interface

Postby Henry MultiСharts » 08 May 2013

arjfca wrote:
Dave Masalov wrote:We will provide you with the examples shortly.

Hello
An old post, Is an example of code has been published?
Martin

Hello Martin,

Here is an example how to plot candles with gradient colors in MC .Net using IChartCustomDrawer. There is also a prebuilt indicator called _Market_Depth_on_Chart_2_ that can be used for reference.
These users thanked the author Henry MultiСharts for the post:
arjfca


Return to “MultiCharts .NET”