Error access price properties from IChartCustomDrawer.Draw  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
radekj
Posts: 113
Joined: 28 Apr 2008
Has thanked: 20 times
Been thanked: 1 time

Error access price properties from IChartCustomDrawer.Draw

Postby radekj » 25 Aug 2012

Each access of price properties like
Bars.Close[n], Bars.Time[n] inside IChartCustomDrawer.Draw method
cause a exception ! (n>0)

It seems that any access outside CalcBar() cause a exception.

ciao
radekj


Exampel:

Code: Select all

void IChartCustomDrawer.Draw(DrawContext context, EDrawPhases phase)
{
if (Bars.CurrentBar > 1) Output.WriteLine(Bars.Close[1].ToString()); // <- !!! aceess of Close[1] cause a exception !!!
}

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

Re: Error access price properties from IChartCustomDrawer.Dr  [SOLVED]

Postby Henry MultiСharts » 27 Aug 2012

Hello Radekj,

Draw method and regular calculations are done in separate threads.
You need to use "context.Environment.Bars" to achieve your goal.


Return to “MultiCharts .NET”