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

Prevent drawings from displaying in right margin

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

    Prevent drawings from displaying in right margin

    Is it possible to prevent drawings from displaying in the right margin? When I am scrolling through price action, I don't want to see any drawings until the bar is displayed. In the example I am using DrawDots().
    Attached Files

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

    If you use the overload for DrawDot that uses a BarsAgo parameter, that is

    DrawDot(string tag, bool autoScale, int barsAgo, double y, Color color)


    This will prevent you from drawing past the current bar. Here is the documentation for DrawDot for more information.






    Please let us know if there is any other way we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Jessica,
      I am using the BarsAgo overload, which works if you are at the far left of the time frame you are looking at and step forward, but if you back up the Dots will still print in the right margin where Plots do not. Or more typically if the data is loaded and you look back in time you would have to reload the Ninjascript (F5) everytime you scroll back in time.

      i.e in the example the Fuchia lines are a Plot and the Dots are from
      DrawDot("Dot"+CurrentBar.ToString(), true, 0, High[0]+(TickSize*offset), Color.Cyan);

      When you back up the chart the Plots will hide while the Dots (or any other drawings) remain.
      Attached Files

      Comment


        #4
        Hello again tjw0001,

        While the functionality you would need to accomplish this is not documented, the examples in these threads should give you all you need to accomplish this goal. You will need three pieces of information :

        This code snippet should help get you started.


        Code:
        [FONT=Courier New]            if (ChartControl.GetXByBarIdx(Bars, 0) < ChartControl.CanvasRight - ChartControl.BarMarginRight)
                    {
                        Print("On screen");
                    }
                    else
                    {
                        Print("Off screen");
                    }[/FONT]
        The preceding code is meant to work from OnBarUpdate. Alternatively, it may be possible to override the Plot() method, and use its pixel coordinates. Here is some more information on Plot() .





        Please let us know if there are any other ways we can help.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Can Ninja Devs implement what is being requested? The behaviour of the right hand margin is inconsistent. For histograms the right hand margin persists when scrolling left. For the chart price panel it does not persist when scrolling left. This really looks like a bug that has been overlooked. Can the Ninja devs at least provide a full code snippet to solve this problem or a custom ninja script indicator that can be loaded to solve this issue? Thank you.

          Comment


            #6
            Thank you for your question zextra.

            NinjaTrader 7 is no longer under active development, and if a bug is discovered any fixes are going to have to be implemented at the user NinjaScript level.

            I have used the code snippet I posted in July to create an indicator which moves a drawn object behind a margin. I recommend using 5 second bars to see it in action. Code samples we provide are for educational purposes, and are not intended for live trading, and are not guaranteed to accomplish any user goal or to be maintained.

            Please let us know if there are any other ways we can help.
            Attached Files
            Last edited by NinjaTrader_JessicaP; 04-24-2017, 10:05 AM.
            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              THanks for the reply. I didn't know this post was for NT7. This is happening on NT8.

              The problem is that the indicators keep drawing past the right margin
              Last edited by zextra; 04-24-2017, 02:20 PM.

              Comment


                #8
                Thank you for this additional information. The capability to draw objects past the right margin must be granted to programmers for several existing tools to continue working. ChartControl and ChartScale are now documented in NinjaTrader 8, with code samples available in the help guide.




                If a user desires drawing objects always be placed within margins, they will need to use a filter similar to the one that exists in the script example I posted in post #6. In anticipation of the possibility that you were asking a NinjaTrader 8 question, the script example was created with NinjaTrader 8 in mind, and in your code the NT7 Plot code should work as-is in NT8 OnRender with minor modifications (such as using Draw.Rectangle instead of DrawRectangle). CurrentBar not being guaranteed is a limitation new to NinjaTrader 8, however this has already been accounted for in the NT7 code sample.

                We will be happy to help with any specific questions that come up during the process of implementing the advice in this thread.
                Jessica P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Perr0Grande, Today, 08:16 PM
                0 responses
                2 views
                0 likes
                Last Post Perr0Grande  
                Started by elderan, Today, 08:03 PM
                0 responses
                5 views
                0 likes
                Last Post elderan
                by elderan
                 
                Started by algospoke, Today, 06:40 PM
                0 responses
                10 views
                0 likes
                Last Post algospoke  
                Started by maybeimnotrader, Today, 05:46 PM
                0 responses
                12 views
                0 likes
                Last Post maybeimnotrader  
                Started by quantismo, Today, 05:13 PM
                0 responses
                7 views
                0 likes
                Last Post quantismo  
                Working...
                X