Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Double Bar Histogram Overlay - not sure how to do this.

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

    Double Bar Histogram Overlay - not sure how to do this.

    Basically I want to have a red bar histogram and a green bar histogram so they're overlaid.

    Example picture attached. Idea is from: https://github.com/jackiewoodall/tv-...readme-ov-file, which is for Tradovate but want to recreate it on NT.

    Any ideas how I would go about doing this? I was looking at the VOL indicator script to see but having trouble getting it to present both bars.

    Code that shows nothing:
    Code:
    protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"Enter the description for your new custom Indicator here.";
                    Name                                        = "BullsvsBears";
                    Calculate                                    = Calculate.OnEachTick;
                    IsOverlay                                    = false;
                    DisplayInDataBox                            = true;
                    DrawOnPricePanel                            = true;
                    DrawHorizontalGridLines                        = true;
                    DrawVerticalGridLines                        = true;
                    PaintPriceMarkers                            = true;
                    ScaleJustification                            = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                    //See Help Guide for additional information.
                    IsSuspendedWhileInactive                    = true;
                    
                    
                    //AddPlot(new Stroke(Brushes.DodgerBlue, 2),    PlotStyle.Bar,    Custom.Resource.VOLVolume);
                    //AddLine(Brushes.DarkGray, 0,            Custom.Resource.NinjaScriptIndicatorZeroLine);
                    
                    
                    AddPlot(new Stroke(Brushes.Green, 2),    PlotStyle.Bar,    "Bulls");
                    AddLine(Brushes.DarkGray, 0, "Bulls_" + Custom.Resource.NinjaScriptIndicatorZeroLine);
                    
                    
                    AddPlot(new Stroke(Brushes.Red, 2),    PlotStyle.Bar,    "Bears");
                    AddLine(Brushes.DarkGray, 0, "Bears_" + Custom.Resource.NinjaScriptIndicatorZeroLine);              
                    
                }
                else if (State == State.Configure)
                {
                }
            }
    
            protected override void OnBarUpdate()
            {
                //Add your custom indicator logic here.
                //Value[0] = Instrument.MasterInstrument.InstrumentType == InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume((long)Volume[0]) : Volume[0];
                
                double percent_bulls = ((Close[0] - Low[0]) / (High[0] - Low[0]));
                double percent_bears = (High[0] - Close[0]) / (High[0] - Low[0]);
                
                Value[0] = percent_bulls;    
                Value[1] = percent_bears;           
            }​

    #2
    Hello hunter2379,

    The BuySellVolume indicator included with NinjaTrader does something similar.

    The buys is buys + sells so that both plots are visible.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you so much!! Really appreciate it!

      One last question, any idea if there's an indicator that shows the current ATR(20) or ATR(20) * 2 or plots them? I'd like to easily use ATR to set a stop loss without calculating ATR(20) each time I open a new position.

      Comment


        #4
        Hello hunter2379,

        There is the ATR indicator included with NinjaTrader you can call, is this what you are looking for?
        You could call this indicator from a custom indicator and multiple the value by 2 and set this to a plot value.


        Below is a link to the ATRTrailing indicator which subtracts the ATR to the current price that can be used to set a stop loss.
        This is a conversion of the ATR Trailing Stop developed by Welles Wilder. Please contact the original author for any questions or comments. For more apps from this user check out the Renko Bar Type!
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Yea, I've looked into that. Just didn't see a clean way of adding it into my chart. I guess, if I have an indicator or strategy running, can I detect when an order is filled via the DOM and for that bar display the ATR ranges I want as dots?

          Comment


            #6
            Hello hunter2379,

            You can go to the indicators window and select the ATR indicator and click add to add this to a chart.
            You can call the ATR() indicator from a custom indicator and plot the value on a chart or plot a dot at the price value.

            You can use the Addon approach in an indicator to trigger an action like drawing a dot when an order fills on an account by adding an event handler method to the <Account>.ExecutionUpdate event.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Got it, thank you very much.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by fx.practic, 10-15-2013, 12:53 AM
              5 responses
              5,404 views
              0 likes
              Last Post Bidder
              by Bidder
               
              Started by Shai Samuel, 07-02-2022, 02:46 PM
              4 responses
              95 views
              0 likes
              Last Post Bidder
              by Bidder
               
              Started by DJ888, Yesterday, 10:57 PM
              0 responses
              8 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by MacDad, 02-25-2024, 11:48 PM
              7 responses
              159 views
              0 likes
              Last Post loganjarosz123  
              Started by Belfortbucks, Yesterday, 09:29 PM
              0 responses
              8 views
              0 likes
              Last Post Belfortbucks  
              Working...
              X