I am trying to get a circle to be drawn through on render but no circles were drawn. Or is the code disposing of the circles?
I would like to circles to stay drawn.
I have created a few series to store relevant data.
No errors are popping up on Log.
I wasn't sure if the issue was the for loop but I added a print inside and it printed so I don't believe that is the issue.
Here's the code:
else if (State == State.Configure)
{
AddVolumetric("ES 03-22", BarsPeriodType.Tick, 5, VolumetricDeltaType.BidAsk, 1);
}
else if (State == State.DataLoaded)
{
rVol = new Series<float>(BarsArray[1]);
barVol = new Series<float>(BarsArray[1]);
sizeVol = new Series<double>(BarsArray[1]);
dPer = new Series<float>(BarsArray[1]);
mid = new Series<float>(BarsArray[1]);
}
}
private Series<float> rVol;
private Series<float> barVol;
private Series<double> sizeVol;
private Series<float> dPer;
private Series<float> mid;
protected override void OnBarUpdate()
{
if (CurrentBars[1] < 2500)
return;
if (Bars == null)
return;
NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = BarsArray[1].BarsType as
NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
if (barsType == null)
return;
if(BarsInProgress != 1)
return;
if (CurrentBars[1] > 5005)
{
barVol[0] = barsType.Volumes[CurrentBars[1]].TotalVolume;
sizeVol[0] = barVol[0] / (barsType.Volumes[CurrentBars[1]].Trades+1);
//rVol[0] = ((barVol[0]/((SUM(barVol, 30)[0])/30))+(sizeVol[0]/((SUM(sizeVol, 1200)[0])/1200)))/2;
rVol[0] = Convert.ToSingle(sizeVol[0]/((SUM(sizeVol, 5000)[0])/5000));
dPer[0] = barsType.Volumes[CurrentBars[1]].BarDelta / barVol[0];
mid[0] = Convert.ToSingle((Highs[1][0] + Lows[1][0])/2);
}
}
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
for (int idx = ChartBars.FromIndex; idx <= ChartBars.ToIndex; idx++)
{
if(mid.IsValidDataPointAt(idx))
{
float x = chartControl.GetXByBarIndex(ChartBars, idx);
float y = chartScale.GetYByValue(mid.GetValueAt(idx));
// create two vectors to position the ellipse
SharpDX.Vector2 startPoint = new SharpDX.Vector2(x, y);
SharpDX.Vector2 endPoint = new SharpDX.Vector2(x, y);
// calculate the center point of the ellipse from start/end points
SharpDX.Vector2 centerPoint = (startPoint + endPoint) / 2;
// set the radius of the ellipse
float radiusX = rVol[0];
float radiusY = rVol[0];
// construct the rectangleF struct to describe the position and size the drawing
SharpDX.Direct2D1.Ellipse ellipse = new SharpDX.Direct2D1.Ellipse(centerPoint, radiusX, radiusY);
// define the brush used in the rectangle
SharpDX.Direct2D1.SolidColorBrush customDXBrush = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, SharpDX.Color.DodgerBlue);
// execute the render target fill ellipse with desired values
RenderTarget.FillEllipse(ellipse, customDXBrush);
// always dispose of a brush when finished
customDXBrush.Dispose();
}
}

Comment