if (line1 == null)
line1 = DrawHorizontalLine("line1", false, 1000.25, Color.Red, DashStyle.Solid, 1);
if (line1 == null)
Print("line 1 shouldn't be null...");
The problem is that line1 DOES get drawn (and the above code is the ONLY place where I actually draw line1), I can see it on the chart at 1000.25, but the Print statement "line1 shouldn't be null..." still gets written to the output window on each tick. I guess I don't understand why this would be happening. Any ideas?
EDIT: OK, I've tested this some more, and it looks like this doesn't happen when the indicator is manually added to a chart. In that scenario, everything works as expected. But when the indicator is called from a chart (i.e. 'Add(indicator());'), that's when this all happens.
EDIT #2: Another thing I've noticed is that when I call properties of the indicator from the strategy I've added it to, the properties are ALL either null, or at their default value. For example, I've placed the following line in the indicator's OnBarUpdate:
double price = Close[0];
I've then made the variable 'price' publicly accessible (as 'Price'), and when I add the following line to the strategy's OnBarUpdate:
Print(indicator().Price.ToString());
Zero is always the value that gets printed, even though it shouldn't be zero.
EDIT #3: So it looks like this is a problem with my strategy and not with my indicator. I've added other working indicators to this strategy, and the same problem occurs with them -- all properties are at their default values. It's as if the strategy isn't adding the indicator correctly, something like that. I'm not getting any errors at runtime though, and the strategy doesn't disable itself or anything, so I'm not sure how to debug this.
Comment