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

Plot High/Low of bar on right scale

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

    Plot High/Low of bar on right scale

    Hi

    I like to plot the high and low of each bar on the right scale like the current price. I have written simple code to do that as below. It works fine, but the only way I am able to plot the high/low values on the right scale is by plotting a dot on the high and low of each bar. I'd prefer to just see the values on the right scale without having to plot dots on the chart as I find this distracting. Is there a way to do that? If I make the dots the same as the background color, it mask a little bit off the high and low of the bar since it is actually overlapping.

    -----------------------------------------------------------------
    namespace NinjaTrader.Indicator
    {
    /// <summary>
    /// Plot the High and Low of each bar on the right scale
    /// </summary>
    [Description("Plot the High and Low of each bar on the right scale")]
    public class FSIPlotHL : Indicator
    {
    #region Variables
    // Wizard generated variables
    private Color HighColor = Color.LimeGreen; // Default setting for HighColor
    private Color LowColor = Color.Red; // Default setting for LowColor
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.LimeGreen), PlotStyle.Dot, "HighPlot"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Dot, "LowPlot"));
    CalculateOnBarClose = false;
    Overlay = false;
    PriceTypeSupported = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    HighPlot.Set(High[0]);
    LowPlot.Set(Low[0]);
    }

    #region Properties
    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries HighPlot
    {
    get { return Values[0]; }
    }

    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries LowPlot
    {
    get { return Values[1]; }
    }

    [XmlIgnore()]
    [Description("High Color")]
    [Category("Parameters")]
    public Color highColor
    {
    get { return HighColor; }
    set { HighColor = value; }
    }

    // Serialize our Color object
    [Browsable(false)]
    public string noDemandColorSerialize
    {
    get { return NinjaTrader.Gui.Design.SerializableColor.ToString( HighColor); }
    set { HighColor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
    }

    [XmlIgnore()]
    [Description("Low Color")]
    [Category("Parameters")]
    public Color lowColor
    {
    get { return LowColor; }
    set { LowColor = value; }
    }

    // Serialize our Color object
    [Browsable(false)]
    public string LowColorSerialize
    {
    get { return NinjaTrader.Gui.Design.SerializableColor.ToString( LowColor); }
    set { LowColor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
    }

    #endregion
    }
    }

    --------------------------------------------------------------------------------

    #2
    fs, have you tried setting the dots to 'transparent'? This would still display the value on the right side scale...
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi

      Thank you for your suggestion. That almost worked. The dots don't show up when setting to transparent, but unfortunately the values on the right scale are also transparent and show up as "empty" price boxes.

      Comment


        #4
        Yes, that is correct - maybe you can can access the needed values also in the DataBox, or you plot them right to the currentbar on the chart with DrawText.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          You can always make the dot size zero, and set to the color you want in the mean time. Or even change to Hash style.
          eDanny
          NinjaTrader Ecosystem Vendor - Integrity Traders

          Comment


            #6
            Thanks again for the replies. What I have done now is setting the size to zero. I will look up how drawtext work to display that at the bottom of the screen like the time counter indicator do. Still feeling my way around in NT script.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by judysamnt7, 03-13-2023, 09:11 AM
            4 responses
            59 views
            0 likes
            Last Post DynamicTest  
            Started by ScottWalsh, Today, 06:52 PM
            4 responses
            36 views
            0 likes
            Last Post ScottWalsh  
            Started by olisav57, Today, 07:39 PM
            0 responses
            7 views
            0 likes
            Last Post olisav57  
            Started by trilliantrader, Today, 03:01 PM
            2 responses
            21 views
            0 likes
            Last Post helpwanted  
            Started by cre8able, Today, 07:24 PM
            0 responses
            10 views
            0 likes
            Last Post cre8able  
            Working...
            X