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

Plotting prices on y axis

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

    Plotting prices on y axis

    I have an indicator which I need to plot prices so I can easily see it on the y-axis like so ... https://gyazo.com/d9f73beae3239df45d3ad9c1b7bb8c7e

    I've tried adding plots to pull the data but I must be doing something wrong as its not even plotting a line. Is there an easier way to do this like..

    Plot resistance2.yaxis? Also possibly having a line if there is one be transparent, if not I can deal with it not being transparent.

    #2
    Hello clubfoot, and thank you for your question.

    In order to plot values on your chart, every plot you added must have its Values[BarsInProgress][0] member assigned to every time one of its candles closes. This example OnBarUpdate routine would assign values to 3 plots.

    Code:
    [FONT=Courier New]
    protected override void OnBarUpdate()
    {
        if (BarsInProgress == 0)
        {
            Values[0][0] = Closes[0][0];
        }
        if (BarsInProgress == 1)
        {
            Values[1][0] = Highs[1][0];
        }
        if (BarsInProgress == 2)
        {
            Values[2][0] = SMA(BarsArray[2], 14)[0];
        }
    }[/FONT]
    I am providing some documentation on the Values array. Please let us know if we can be of further assistance.

    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      So if we take a bollinger band for example, I would start off with an addplot

      AddPlot(Brushes.Blue, "BollingPlot");

      then using the following

      if (BarsInProgress == 0)
      {
      Values[0][0] = Bollinger(2, 14).Upper[0][0];
      }


      That would get me the current value to be displayed for the plot on the current bar?

      How would I then exactly post the plot though?

      Sorry I'm very confused

      Comment


        #4
        You are close, except that Bollinger(2, 14).Upper is a 1-D array, not a 2-D array, so you only need Bollinger(2, 14).Upper[0] , not Bollinger(2, 14).Upper[0][0] . If you wanted Bollinger values for higher data series, the format for that is Bollinger(BarsArray[1], 2, 14).Upper .

        Any value that is stored in Values[0][0] shows up on your first added plot. Any value stored in Values[1][0] shows up on your second added plot. Any value that is stored in Values[n][0] shows up in your (n-1)'th plot.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Jessica, if I could kiss you I would. That explanation worked perfectly!

          Comment


            #6
            I am really glad I was able to assist Please let us know if there are any other ways we can help.
            Jessica P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ghoul, Today, 06:02 PM
            3 responses
            14 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            44 views
            0 likes
            Last Post jeronymite  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            20 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by AttiM, 02-14-2024, 05:20 PM
            10 responses
            180 views
            0 likes
            Last Post jeronymite  
            Started by DanielSanMartin, Yesterday, 02:37 PM
            2 responses
            13 views
            0 likes
            Last Post DanielSanMartin  
            Working...
            X