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

How to LOCK drawing and indicators? How to plot a line but leave some margin?

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

    How to LOCK drawing and indicators? How to plot a line but leave some margin?

    Context:
    I created a double-click event that triggers my custom order with ninjascript. I set a margin on the right side of my chart where I do my clicks. Works great.

    For the next step, I've added some lines to my chart with Draw.Line(). The lines act as support and resistance so I want them extended to the right.

    So started drawing the lines at the originator event and extending them to the right by giving the endBars ago parameter a value of -400 (on a 2m chart). This makes them "extend right" but the chart margins are not respected.


    And as such the lines are interfering with my double-clicks and instead of triggering my code, it ends up just selecting the drawings...

    It is possible to lock down drawings and indicators so they don't get selected when clicking them?

    If not possible, how can I draw the lines (without having to redraw on each bar update) so that the margin on the right of the chart is respected and I can use that area to do my double clicks?

    EDIT: The green line towards the bottom is the OrderFlorVWAP plot... as you can see it ends in a way that respects the margins, this is exactly the behavior I'd like my lines to follow

    Click image for larger version  Name:	Capture.PNG Views:	6 Size:	63.1 KB ID:	1173561
    Last edited by focus333; 10-04-2021, 11:03 PM.

    #2
    Hello focus333,
    Instead of -400 use -2 or -4 as suitable. This will stop your lines 2 or 4 bars after last bar on chart & rest of your margin will remain free.
    Hope it helps!

    Comment


      #3
      s.kinra thanks but that doesn't work, that will produce a line 2 or 4 bars wide to the right and not extend all the way... appreciate the help anyways.
      Last edited by focus333; 10-04-2021, 09:41 PM.

      Comment


        #4
        Hello focus333,

        Thanks for your post.

        For drawing objects, you can consider setting the IgnoresUserInput property in NinjaScript if the objects are drawn from NinjaScript.

        Code:
        private Dot myDot;
        protected override void OnBarUpdate()
        {
            myDot = Draw.Dot(this, "tag", true, 0, Close[0] + 10 * TickSize, Brushes.White);
            myDot.IgnoresUserInput = true;
        }
        For plot lines you can call base.OnRender inside OnRender, only for if (!IsInHitTest) render passes, and this will only draw the plot lines outside of hit testing:

        Code:
        protected override void OnBarUpdate()
        {
            Value[0] = Close[0] + 10 * TickSize;
        }
        
        protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
        {
            if (!IsInHitTest)
                base.OnRender(chartControl, chartScale);
        }
        Custom rendering can also be done outside of IsInHitTest render passes in order to be un-clickable.
        JimNinjaTrader Customer Service

        Comment


          #5
          NinjaTrader_Jim YES! Thank you!! IgnoreUserInput is exactly what I was looking for. It works.

          Now, here's another question. I also have OrderFLowVWAP added to the chart as an indicator (not from ninjascript). Is there a way to make it so that it ignores user input as well?

          The code for OFVWAP is locked, so don't think I can actually change it. Is there a solution?

          Thanks!

          Comment


            #6
            Hello focus333,

            The best I could suggest there would be to create a "shell indicator" that would add Order Flow VWAP, adds it's own plots, and then assigns the Order Flow VWAP plots to the plots owned by the "shell indicator."

            Then you could do the same OnRender trick to call base.OnRender outside of IsInHitTest render passes only, so the indicator plots cannot be clicked.
            JimNinjaTrader Customer Service

            Comment


              #7
              NinjaTrader_Jim thanks Jim. Would that be a performance drag? Or relatively small impact?

              By the way, have I told you guys how much I love NinjaTrader and the support team?? It's the BEST product out there for a retail quant trader. Kudos to you all!

              Comment


                #8
                Thanks for your positive comments focus333!

                Performance hit should be negligible for creating a "shell indicator" that just wraps what is plotted from the original indicator.
                JimNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Belfortbucks, Today, 09:29 PM
                0 responses
                6 views
                0 likes
                Last Post Belfortbucks  
                Started by zstheorist, Today, 07:52 PM
                0 responses
                7 views
                0 likes
                Last Post zstheorist  
                Started by pmachiraju, 11-01-2023, 04:46 AM
                8 responses
                151 views
                0 likes
                Last Post rehmans
                by rehmans
                 
                Started by mattbsea, Today, 05:44 PM
                0 responses
                6 views
                0 likes
                Last Post mattbsea  
                Started by RideMe, 04-07-2024, 04:54 PM
                6 responses
                33 views
                0 likes
                Last Post RideMe
                by RideMe
                 
                Working...
                X