I have a question concerning the exchange of data between two indicators.
I have an indicator that have a list of price levels that I would like to use to draw in another chart with another indicator.
In my first indicator ( the one that owns the list of double) I have exposed the list like that :
[Browsable(false)]
[XmlIgnore()]
public List<double> Zone
{
get { Update(); return zone; }
}
In my second indicator ( the one that receives the list and use it to draw lines and rectangles I have the following structure :
First in my Variables region I have created a list :
#region Variables
List<double> zone = new List<double>();
#endregion
Second in my OnBarUpdate() method I initialize my list to the list of my first indicator and draw some stuff :
protected override void OnBarUpdate()
{
int count = 0;
double temp = 0;
if(Bars.FirstBarOfSession){
zone = MyfirstIndicator().Zone;
}
foreach(double item in zone){
count +=1;
if(count % 2 != 0)
temp = item;
else
DrawRectangle("Zone"+item, false, Bars.BarsSinceSession, temp, 0, item, Color.Bisque, Color.Bisque, 3);
}
I get the following error :
Error on calling 'OnBarUpdate' method on bar1 : Object reference not set to an instance of an object.
What is wrong with my code ?
Thanks
Bernard
Comment