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

Limiting the DrawObjects

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

    Limiting the DrawObjects

    Hi,

    I have an indicator that draws rays from specific similar candlesticks. The program gets bogged down when a lot of rays are drawn. Is it possible to limit the rays that are drawn to the ones that are within say 5% of the current closing price? So I'd use an "if" and a "Remove DrawObjects" but the ray is drawn from anchor points many bars ago. So how would I determine the rays with current positions within 5% of the the current bar?

    #2
    Hi stockgoblin,

    Yes, this is possible although unfortunately we cannot offer a custom coded solution. If you need to expose values about a drawing object, can use IDraw interface.


    You can expose easily the anchor points of a ray:


    Exposing Y value at last bar is a little trickier. I show one approach in this manual alert indicator:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Nice, thanks. I'll try to merge line alert with my custom indicator. At first glance it looks like I'll just need to RemoveDrawObject if lineValueAtLastBar is over 5% away from Close. Wish me luck. I'm sure I'll be asking you more. Stay tuned.

      Comment


        #4
        Great you found the value you need in that script. Good luck on the implementation!
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hi,

          I'd like to remove all programmed rays outside of 5% below or above the last bar.

          I'm thinking I can just modify the LineAlert Indicator as follows:

          THIS:

          //Alert Checking is done here. Can add your own actions to the block if desired.
          if(CrossBelow(Close, lineValueAtLastBar, 1) || CrossAbove(Close, lineValueAtLastBar, 1))
          {
          Alert("AlertLineCrossing", Cbi.Priority.High, alertMessage, soundFile, 0, Color.White, Color.Black);
          }


          TO THIS:

          //Alert Checking is done here. Can add your own actions to the block if desired.
          if(lineValueAtLastBar > Close[0] * 1.05 || lineValueAtLastBar < Close[0] * .95 )
          {
          RemoveDrawObjects();
          }


          This just removes all the rays. How do I refer to just the last bar?I can't use Close[0] because the indicator goes through all the data bar by bar. Do I have to make the lookback period set to 1 or something like that?

          Comment


            #6
            This part may be tricky, because you need to be able to pass in the tag of the drawing object into RemoveDrawObject(). That's the method for removing a single object

            If you structure all your rays as objects with IRay, then you can expose, and reference the tags. A foreach loop can also go through all drawing objects in the collection.

            Using the structure from the Alert script, you may (untested) be able to do something like:

            if (lineValueAtLastBar > Close[0] * 1.05 || lineValueAtLastBar < Close[0] * .95 )
            {
            RemoveDrawObject(draw.Tag);
            }
            Last edited by NinjaTrader_RyanM1; 08-14-2011, 07:24 PM.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Hi Ryan,

              I'm still having trouble modifying the Line Alert Indicator to recognize programmatically drawn lines. I removed the If Userdrawn line but it didn't seem to do much. Any suggestions.

              Comment


                #8
                RemoveDrawObject will work only for manually drawn lines, or for lines programatically drawn by a specific indicator instance. You will not simply be able to use LineAlert for removal only -- You will have to draw and remove in the same script. Most of the tougher concepts should be in the LineAlert indicator, so you may be able to adapt by moving your drawing statements there, and of course removing the check for .UserDrawn.
                Ryan M.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by xiinteractive, 04-09-2024, 08:08 AM
                3 responses
                11 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by Johnny Santiago, 10-11-2019, 09:21 AM
                95 responses
                6,193 views
                0 likes
                Last Post xiinteractive  
                Started by Irukandji, Today, 09:34 AM
                1 response
                3 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by RubenCazorla, Today, 09:07 AM
                1 response
                5 views
                0 likes
                Last Post RubenCazorla  
                Started by TraderBCL, Today, 04:38 AM
                3 responses
                25 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X