Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

no High Low of Custom candles in my Delta indicator

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

    no High Low of Custom candles in my Delta indicator

    Hello everyone, no High Low of Custom candles in my Delta indicator

    Created a Delta indicator, which should display delta bars in a new panel, everything works, bars are there, but there are no values ​​where the candle's delta was high and low.

    Help me figure it out, thanks

    code

    Code:
    
    private Brush barColorDown = Brushes.Red;
    private Brush barColorUp = Brushes.Lime;
    private Brush shadowColor = Brushes.Gray;
    private Pen shadowPen = null;
    private int shadowWidth = 1;
    
    AddPlot(Brushes.Gray, "HAOpen");
    AddPlot(Brushes.Gray, "HAHigh");
    AddPlot(Brushes.Gray, "HALow");
    AddPlot(Brushes.Gray, "HAClose");
    
    private void MyDelta //
    {
    double Vol = buys + sells;
    double Delta = buys - sells;
    
    if (CurrentBar == 0)
    {
    HAOpen[0] = Open[0];
    HAHigh[0] = High[0];
    HALow[0] = Low[0];
    HAClose[0] = Close[0];
    return;
    }
    
    HAClose[0] = Delta;// Calculate the close
    HAOpen[0] = 0; // Calculate the open
    
    HAHigh[0] = (Math.Max(Delta, HAOpen[0])); // Calculate the high
    HALow[0] = (Math.Min(Delta, HAOpen[0])); // Calculate the low
    
    }
    
    public override void OnCalculateMinMax()
    {
    base.OnCalculateMinMax();
    
    if (Bars == null || ChartControl == null)
    return;
    
    for (int idx = ChartBars.FromIndex; idx <= ChartBars.ToIndex; idx++)
    {
    double tmpHigh = HAHigh.GetValueAt(idx);
    double tmpLow = HALow.GetValueAt(idx);
    
    if (tmpHigh != 0 && tmpHigh > MaxValue)
    MaxValue = tmpHigh;
    if (tmpLow != 0 && tmpLow < MinValue)
    MinValue = tmpLow;
    }
    }
    
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    
    if (Bars == null || ChartControl == null)
    return;
    
    int barPaintWidth = Math.Max(3, 1 + 2 * ((int)ChartControl.BarWidth - 1) + 2 * shadowWidth);
    
    for (int idx = ChartBars.FromIndex; idx <= ChartBars.ToIndex; idx++)
    {
    if (idx - Displacement < 0 || idx - Displacement >= BarsArray[0].Count || (idx - Displacement < BarsRequiredToPlot))
    continue;
    
    double valH = HAHigh.GetValueAt(idx);
    double valL = HALow.GetValueAt(idx);
    double valC = HAClose.GetValueAt(idx);
    double valO = HAOpen.GetValueAt(idx);
    int x = chartControl.GetXByBarIndex(ChartBars, idx); //was chartControl.BarsArray[0]
    int y1 = chartScale.GetYByValue(valO);
    int y2 = chartScale.GetYByValue(valH);
    int y3 = chartScale.GetYByValue(valL);
    int y4 = chartScale.GetYByValue(valC);
    
    SharpDX.Direct2D1.Brush shadowColordx = shadowColor.ToDxBrush(RenderTarget); // prepare for the color to use
    var xy2 = new Vector2(x, y2);
    var xy3 = new Vector2(x, y3);
    RenderTarget.DrawLine(xy2, xy3, shadowColordx, shadowWidth);
    
    if (y4 == y1)
    RenderTarget.DrawLine(new Vector2(x - barPaintWidth / 2, y1), new Vector2(x + barPaintWidth / 2, y1), shadowColordx, shadowWidth);
    else
    {
    if (y4 > y1)
    {
    SharpDX.Direct2D1.Brush barColorDowndx = barColorDown.ToDxBrush(RenderTarget); // prepare for the color to use
    RenderTarget.FillRectangle(new RectangleF(x - barPaintWidth / 2, y1, barPaintWidth, y4 - y1), barColorDowndx);
    barColorDowndx.Dispose();
    }
    else
    {
    SharpDX.Direct2D1.Brush barColorUpdx = barColorUp.ToDxBrush(RenderTarget); // prepare for the color to use
    RenderTarget.FillRectangle(new RectangleF(x - barPaintWidth / 2, y4, barPaintWidth, y1 - y4), barColorUpdx);
    barColorUpdx.Dispose();
    }
    RenderTarget.DrawRectangle(new RectangleF(x - barPaintWidth / 2 + (float)shadowWidth / 2,
    Math.Min(y4, y1), barPaintWidth - (float)shadowWidth, Math.Abs(y4 - y1)), shadowColordx, shadowWidth);
    }
    shadowColordx.Dispose();
    }
    }
    my result now

    Click image for larger version  Name:	ResultMy.png Views:	0 Size:	5.3 KB ID:	1149905


    need to get

    Click image for larger version

Name:	2.png
Views:	240
Size:	9.3 KB
ID:	1149907
    Last edited by memonolog; 04-03-2021, 11:34 AM.

    #2
    Hello memonolog,

    Unfortunately, plot series do not have an open, high, low, close and do not appear the same as candle sticks for bar data.

    This would have to be custom rendered similar to the heiken ashi indicator.
    NinjaTrader 8 natively provides Heiken Ashi as a bar type for most common bar types (minute, tick, volume, second, day, week, month, year). This Heiken Ashi indicator is provided for the Range, Renko and any custom bar types that may be added. The indicator performs in the same manner as the NinjaTrader 7 version. 4-27-18 [&#8230;]
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello memonolog,

      Unfortunately, plot series do not have an open, high, low, close and do not appear the same as candle sticks for bar data.

      This would have to be custom rendered similar to the heiken ashi indicator.
      https://ninjatraderecosystem.com/use...heiken-ashi-8/
      where is plot? I don’t use Plot series

      if you read it again and look at my code, you will probably understand that there is a custom bars and it is from the indicator to which you have dropped the link

      Comment


        #4
        if I understand correctly

        Here

        Code:
        HAHigh[0] = (Math.Max(Delta, HAOpen[0])); // Calculate the high
        HALow[0] = (Math.Min(Delta, HAOpen[0])); // Calculate the low
        I need to somehow get the maximum value that was in the delta

        I don’t know how to do it

        Comment


          #5
          Hello memonolog,

          To confirm, you are only asking about a single line of code and you are not referring to the series added with AddPlot() shown in your first post?

          Use the MAX() method to get the largest value in a series for a period.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_ChelseaB View Post
            Hello memonolog,

            To confirm, you are only asking about a single line of code and you are not referring to the series added with AddPlot() shown in your first post?

            Use the MAX() method to get the largest value in a series for a period.
            https://ninjatrader.com/support/help...aximum_max.htm
            the question of how to get the maximum delta value in a bar, not the last value that is displayed by the Delta variable, but the maximum that would be in the bar

            double Delta = buys - sells;


            HAClose[0] = Delta;// Calculate the close
            HAOpen[0] = 0; // Calculate the open

            HAHigh[0] = buys; // Calculate the high
            HALow[0] = sells; // Calculate the low

            how to get it using the the MAX () method?
            What's the correct syntax?

            Comment


              #7
              Hello memonolog,

              I'm sure that I understand. I was previously thinking you want the largest delta value in a series of bars.. but this is not what you want.

              The buys - sells is not the maximum delta?

              What is the maximum delta that you are looking for?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_ChelseaB View Post
                Hello memonolog,

                I'm sure that I understand. I was previously thinking you want the largest delta value in a series of bars.. but this is not what you want.

                The buys - sells is not the maximum delta?

                What is the maximum delta that you are looking for?
                buys - sells ( Delta)
                it turns out that this is the maximum delta when the bar is closed, last delta, final delta in the bar (in my code it is HAClose [0] = Delta; // Calculate the close delta)

                but I need to get at the moment the maximum delta that was in the bar, in general - in your indicator (Order Flow Cumulative Delta, delta type BAR 'second picture in my post') this is just a candle wick - which I am trying to implement in my indicator

                Comment


                  #9
                  Hello memonolog,

                  So you want to process each tick as a bar is built, and if the buys - sells is greater than the value saved to a variable, save the larger value to a variable, is this correct?

                  private double maxDelta;

                  if (IsFirstTickOfBar)
                  maxDelta = 0;

                  maxDelta = Math.Max(maxDelta, buys - sells);
                  Last edited by NinjaTrader_ChelseaB; 04-05-2021, 03:14 PM.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_ChelseaB View Post
                    Hello memonolog,

                    So you want to process each tick as a bar is built, and if the buys - sells is greater than the value saved to a variable, save the larger value to a variable, is this correct?

                    if (IsFirstTickOfBar)
                    int maxDelta = 0;

                    maxDelta = Math.Max(maxDelta, buys - sells);
                    maxDelta int???

                    or

                    double maxDelta = 0;
                    if (IsFirstTickOfBar)
                    {
                    maxDelta = 0;
                    }
                    maxDelta = Math.Max(maxDelta, buys - sells);z

                    Comment


                      #11
                      Hello memonolog,

                      double would be correct for decimal values.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        if I did it right, I still get the final bar delta to the maximum location, that is, wick draws me the same value as the Delta variable in my code, compared with your indicator

                        Code:
                        double maxDelta = 0;
                        double minDelta = 0;
                        
                        if (IsFirstTickOfBar)
                        {
                        maxDelta = 0;
                        minDelta = 0;
                        }
                        
                        maxDelta = Math.Max(maxDelta, buys - sells);
                        minDelta = Math.Min(minDelta, buys - sells);
                        
                        
                        if (CurrentBar == 0)
                        {
                        HAOpen[0] = Open[0];
                        HAHigh[0] = High[0];
                        HALow[0] = Low[0];
                        HAClose[0] = Close[0];
                        return;
                        }
                        
                        //HAClose[0] = Delta;// Calculate the close
                        HAOpen[0] = 0; // Calculate the open
                        HAHigh[0] = maxDelta; // Calculate the high
                        HALow[0] = minDelta; // Calculate the low
                        Click image for larger version

Name:	33.png
Views:	254
Size:	17.2 KB
ID:	1150163

                        Comment


                          #13
                          Originally posted by NinjaTrader_ChelseaB View Post
                          Hello memonolog,

                          double would be correct for decimal values.
                          not working I get the same values ​​as the Delta variable

                          Comment


                            #14
                            Hello memonolog,

                            Are you viewing the prints of each tick update? Which delta calculation had the highest value?
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_ChelseaB View Post
                              Hello memonolog,

                              Are you viewing the prints of each tick update? Which delta calculation had the highest value?
                              no .., how to do this?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              571 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              331 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              549 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              550 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X