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

drawing a vertial line the price assigned to a double

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

    drawing a vertial line the price assigned to a double

    Is it possible to draw a vertical line from the current bar to the price assigned to a double from another time frame using an indicator/strategy? If so, can you provide the syntax for this. I did not see it when I reviewed the support guide.

    #2
    Hello gordongekko,

    Thanks for opening the thread.

    It is possible to draw a line to any price level. The question would be how you plan on getting the data from another time frame. You could add an additional data series to get the price values from another instrument, and use those price values to dictate the price level your line's endpoints should be. This would be the supported way of accessing data from another time frame in a NinjaScript.

    Code:
    Draw.Line(this, "tag1", false, 0, [B]Closes[0][0][/B], 0, [B]Closes[1][0][/B], Brushes.LimeGreen, DashStyleHelper.Dot, 2);
    Please be sure to review the Multi Series NinjaScripts documentation as it covers all of the ins and outs of a Multi Series NinjaScript.

    Multi Series NinjaScripts (Important read!) - https://ninjatrader.com/support/help...nstruments.htm

    Please elt me know if you have any questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hi Jim,

      Thanks for the reply, When I use that syntax and plug in a double containing the closing price of a bar from a higher time frame I'm not seeing it on the chart.

      Draw.Line(this, "tag1", false, 0, Closes[0][0], 0, htfhigh, Brushes.LimeGreen, DashStyleHelper.Dot, 2);

      htfhigh is a double that contains a closing price from a bar obtained via a method using barsinprogress == 1 in the past that is far enough back to where the data is accessible from the primary data series so I'm not sure why its it not showing up on the chart.

      Comment


        #4
        Hello gordongekko,

        I can offer some advise to help you debug this. We should start by asking the following questions:
        1. When testing, were you able to see the Draw.Line() appear when using Closes[0][0] and Closes[1][0]? How about when using numbers as input?
        2. Are you able to see the line when you have the auto scale parameter set to true?
        3. Lastly, there could another issue where the NinjaScript errors out and no longer performs any action. Do you see any errors in the log tab of the Control Center?


        Adding prints for Closes[0][0] and htfhigh above the Draw.Line() can tell you:
        1. if the Draw.Line() is reached
        2. if the input going into the Draw.Line() is valid and what you should expect visually


        Please also note that DashStyleHelper.Dot would create a dotted line. DashStyleHelper.Line would create a solid line. I've included documentation links for Draw.Line() for reference as well as debugging tips that we have on our forums.

        Draw.Line() - https://ninjatrader.com/support/help.../draw_line.htm

        Debugging - https://ninjatrader.com/support/foru...ead.php?t=3418

        Making sure you have enough bars (See "Accessing Price data in a Multi Series NinjaScript" for MultiSeries application) - https://ninjatrader.com/support/foru...ead.php?t=3170

        Accessing Price data in a Multi Series NinjaScript - https://ninjatrader.com/support/help...arsninjascript

        Please let us know if you need further assistance.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jclose, Yesterday, 09:37 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by firefoxforum12, Yesterday, 08:53 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by kmunroe478, Yesterday, 05:39 PM
        2 responses
        15 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by kevinenergy, 02-17-2023, 12:42 PM
        115 responses
        2,700 views
        1 like
        Last Post kevinenergy  
        Started by prdecast, Today, 06:07 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Working...
        X