Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

FYI: Random [BarsAgo] indexing issue with Draw.Ray()

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

    FYI: Random [BarsAgo] indexing issue with Draw.Ray()

    Just giving you guys a heads up on this weird behavior I saw today. This indicator has always drawn the Rays correctly as far as I have seen.
    Here is the code used in the indicator.
    Code:
    Draw.Ray(this, "AskLine", false, [B][U]-2[/U][/B], dblAsk, [U][B]-3[/B][/U], dblAsk, bshAskLine, DashStyleHelper.Solid, 2);
    Draw.Ray(this, "BidLine", false, [U][B]-2[/B][/U], dblBid, [B]-3[/B], dblBid, bshBidLine, DashStyleHelper.Solid, 2);
    You'll notice this happened with data after the market closed on Friday, so maybe that's a clue as to why the bar index location on the chart was interpreted wrong.
    Click image for larger version

Name:	SNAGHTML3d0cf5bb.PNG
Views:	230
Size:	73.4 KB
ID:	1118917
    After reloading the chart the lines were drawn correctly. No need to reply back. I'm just passing this along to you guys.
    Thanks.
    Attached Files

    #2
    Hello zacharydw00,

    It appears you have some invalid code.

    Negative values are not allowed for barsAgo indexes.

    Draw.Ray(this, "AskLine", false, -2, dblAsk, -3, dblAsk, bshAskLine, DashStyleHelper.Solid, 2);

    You will need to change the code so that only positive values are used for barsAgo indexes with Draw methods.

    See the forum threads below which have details.
    Hey everyone, I have an indicator I am working on that has a plot that I want to see for 10 or so future bars so as the candles are developing I can see the candles relative to the indicator. I also want to use it as somewhat of a projection. I tried adding to my series using negative bars ago, like this DataToPlot[-1] =

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      It appears you have some invalid code.
      Negative values are not allowed for barsAgo indexes.
      Hi ChelseaB,
      As I stated in the first post the indicator works correctly except for that one incident. And, as these screenshots show negative values work just fine.

      Click image for larger version

Name:	Negative index works correctly 1.png
Views:	329
Size:	179.7 KB
ID:	1119147Click image for larger version

Name:	Negative index works correctly 2.png
Views:	326
Size:	182.9 KB
ID:	1119148Click image for larger version

Name:	Negative index works correctly 3.png
Views:	328
Size:	184.1 KB
ID:	1119146Click image for larger version

Name:	Negative index works correctly 4.png
Views:	369
Size:	187.3 KB
ID:	1119145
      Side note, I wanted to attach a video to show the indicator works fine using negative numbers, but the site didn't allow that. That would be helpful if this site would allow that in the future.

      Regards,
      Zac

      Comment


        #4
        Hello Zac,

        Using is negative indexes is not supported by NinjaTrader.

        I recommend you change the code and only use positive barsAgo values.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        44 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        54 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        34 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        95 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        57 views
        0 likes
        Last Post PaulMohn  
        Working...
        X