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

DrawLine in a multi-insrument strategy

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

    DrawLine in a multi-insrument strategy

    Hello- I'm having problems getting the DrawHorizontalLine statement to work. It's a multi-instrument strategy. Here's the statement with the associated overloads I'm using: DrawHorizontalLine("tag1", Closes[0][0], Color.Black); The chart that is plotted is the primary instrument but I don't see any lines.

    #2
    Hello ciro1963,

    Thank you for your note.

    May I confirm the strategy was compiled after adding the code and the strategy is enabled on the chart?

    Have you used prints to determine on which bar times an object should be appearing? (prints appear in the output window)

    If you right-click the chart, select Drawing Tools > select Remove Drawing Objects, do you find that Horizontal lines is appearing?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi ChelseaB- Yes I am using print statements. I'm trying to get the lines printed in the strategy analyzer chart. I'll try your suggestions. Thank you.

      Comment


        #4
        Hello ciro1963,

        May we see the output from your prints and the code of the print?

        Is this being printed in the action block of the condition set or outside of it?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          The statement: DrawHorizontalLine("tag1", Closes[0][0], Color.Black) doesn't appear to wok by itself. The statement is located under a buy condition block I wrote in my strategy. I'm trying to get it to plot in the strategy chart in strategy analyzer (backtester). I'm not sure if I need to initialize anything for this particular statement. Maybe "ADD plot" function in the Initialize section? Th print statements do prove that I'm entering the condition block at various points in time.In fact, I am able to draw a backround color if I enter the condition using the BackColorAll = Color.Green statement.So some of the drawing snippets work properly.

          Comment


            #6
            Hello ciro1963,

            I am not able to reproduce this behavior where the line does not appear.

            I have copied and pasted your line of code into a strategy and I am finding when the strategy is enabled this is drawing on the last bar without issue as expected.

            Screenshot and test script attached.

            On your end, please test this script. When setting Enabled to true and clicking OK do you see a line appear on your chart?

            If not, may I have a screenshot of your chart so I may confirm there is data on the chart and that the strategy is enabled?
            Attached Files
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi ChelseaB- I ran your script it works. I see what's happening now. The line that is drawn is the most recent closing price of the instrument in question. It does not dynamically change as the price of the stock changes. It just draws the most recent price. How can I get this line to update through time so I can scroll back to see historical level. Ultimately I want this line not to be the closing price but rather some factor of the closing price.

              Comment


                #8
                Hello ciro1963,

                I'm not understanding.

                You want one horizontal line drawn at multiple price levels?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I would like the horizontal line to update to the new level every time I enter my condition. So I guess it’s no longer a horizontal line but a data series.

                  Comment


                    #10
                    Hello ciro1963,

                    You want one line that moves to different prices?

                    That's fine to do.

                    I have demonstrated the issue is not calling DrawHorizontalLine(). This works fine.

                    The issue is with the logic in your script.

                    This brings us back to post #4.

                    May we see the output from your prints and the code of the print?

                    Is this being printed in the action block of the condition set or outside of it?
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by judysamnt7, 03-13-2023, 09:11 AM
                    4 responses
                    55 views
                    0 likes
                    Last Post DynamicTest  
                    Started by ScottWalsh, Today, 06:52 PM
                    4 responses
                    35 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
                    19 views
                    0 likes
                    Last Post helpwanted  
                    Started by cre8able, Today, 07:24 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post cre8able  
                    Working...
                    X