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

xvalue error

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

    xvalue error

    The following line of code is producing a negative value of xvalue is this possible or an error?

    double xvalue = chartControl.GetXByBarIndex(ChartBars, idx);

    So for example
    int idx = 22861
    double xvalue = -15929


    #2
    Hello, thanks for writing in.

    You must make sure the index is displayed on the render view. Most will use the FromIndex and ToIndex to iterate through all the visible bars:
    https://ninjatrader.com/support/help..._fromindex.htm

    It's returning a negative number because this bar index is lower on the X axis of the render view.

    Best regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hello, thanks for writing in.

      You must make sure the index is displayed on the render view. Most will use the FromIndex and ToIndex to iterate through all the visible bars:
      https://ninjatrader.com/support/help..._fromindex.htm

      It's returning a negative number because this bar index is lower on the X axis of the render view.

      Best regards,
      -ChrisL
      Thanks for your reply. The issue seems to occur when I add an additional timeframe to the strategy doing the rendering The additional timeframe is not used for plottting )

      else if (State == State.Configure)
      {
      Signals = new ConcurrentBag<Signal>();

      //three renko ES chart
      AddDataSeries("ES 06-21", new BarsPeriod() { BarsPeriodType = (BarsPeriodType)12345, Value = 3, Value2 = 1 });
      }

      Are there possible issues with OnRender() with multitimeframes? I wish to plot based on the base timeframe (BarsinProgress==0)



      Comment


        #4
        Hello, thanks for your reply.

        The ChartBars object is the primary bars series, so the second time frame should not have an effect on this. GetXByBarIndex will return negative values if the bar index is not visible on the chart at the time it is called.

        Best regards.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bortz, 11-06-2023, 08:04 AM
        47 responses
        1,611 views
        0 likes
        Last Post aligator  
        Started by jaybedreamin, Today, 05:56 PM
        0 responses
        9 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        19 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        6 views
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        22 views
        0 likes
        Last Post Javierw.ok  
        Working...
        X