I have this indicator that I downloaded from Ninjatrader ecosystem/Trader app share and other than a fancy volume histogram at the bottom, it draws various graphic symbols on the chart (such as a Blue Square, Yellow Up Triangle, Green Diamond etc etc right under (or above) the candlestick price bars).
I wish to use this indicator in a Strategy and I have been thinking "How do I get the strategy to be able to see the drawing symbols?"
My first thought was that I need to modify the indicator and add this code so that a strategy would just use the numeric value of the new Plot histogram to decode the graphic symbols painted::
private int symbol;
AddPlot(new Stroke(Brushes.Orange, 3), PlotStyle.Bar, "SymbolCode");
then later:
symbol = 0 ; // initialise to zero i.e. NO condition i.e. no VSA Symbol painted
if (isUpThrustBar[0] && !isNewConfirmedUpThrustBar[0])
{
Draw.Square(this, "MySquare" + CurrentBar, true, 0, High[0] + 6 * TickSize, Brushes.Red);
symbol= symbol | 0x01 ; // Set bit 1 by ORing with 01
}
if (reversalLikelyBar)
{
Draw.Diamond(this, "MyDiamond" + CurrentBar, true, 0, High[0] + 6 * TickSize, Brushes.Blue);
symbol = symbol | 0x02 ; // Set bit 2
}
if (isNewConfirmedUpThrustBar[0])
{
Draw.TriangleDown(this, "MyTriangleDown" + CurrentBar, true, 0, High[0] + 6 * TickSize, Brushes.Red);
symbol = symbol | 0x04 ; // Set bit 3
}
if (strenghtInDownTrend)
{
Draw.Square(this, "MySquare" + CurrentBar, true, 0, Low[0] - 6 * TickSize, Brushes.Lime);
symbol = symbol | 0x08 ; // Set bit 4
}
etc etc for the other graphic symbols - there are 14 in total
and so on .. and then:
Values[4] = (double) symbol; // assign value for (plotting) but especially for use by Strategies
But the NT compiler throws a wobbly saying it can't do the cast.
(I only added the cast after it gave an error initially, and I thought "Of course Mark, the plotting uses "double"s and you have Integer")
But it keeps not wanting to compile
(By the way I did add the other bit to 'properties'
[Browsable(false)]
[XmlIgnore]
public Series<double> SymbolCode
{
get { return Values[4]; }
}
************************************************** *
So that was attempt/approach #1 and maybe that could be fruitful or maybe not.
So I searched in your forums and the NT documentation and I wonder whether I should
be using the function/method DrawObjects.ToList() in my (yet to write) strategy and iterate thru
the graphics objects list using this method (approach #2) to find out if the indicator has painted any of those graphics objects (i.e. to retrieve the graphics)
Can a clever Ninja person suggest the best approach please?
Thanks, Mark.
Comment