Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

On Render Elipse

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    On Render Elipse

    Good Evening,

    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:
    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();
    }
    }
    Thanks for any help
    Last edited by mlprice12; 02-01-2022, 06:02 PM.

    #2
    Looks like the problem is because my rVol[0] is printing as a value of 0 OnRender
    Do I need to create a similar for loop to get the correct value?

    Comment


      #3
      I was able to figure it out thank you

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X