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

reducing the number of Rays drawn

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

    reducing the number of Rays drawn

    Hi,

    I've got too many Rays drawn on my chart (it's doing as per code) but I would like to restrict or curb the number of Rays drawn as some Rays are no longer relevant (too old) and are occupying precious real estate.

    Could I restrict the number of Rays drawn to say the most recent 15? How would I do that?
    Alternatively, could I have keep Rays drawn which begin from a specific day or specific time (like from yesterday 12pm?
    Or could have I keep Rays which are drawn within a certain range (like yesterday's trading range)?

    I tried de-selecting autoscale and adjusting the chart scale but it didn't help. By the time I re-scaled it, the candles were mostly below the bottom of the chart window.

    Regards
    Kay Wai
    Last edited by kaywai; 05-23-2022, 04:20 AM.

    #2
    Hello kaywai,

    You can restrict the number of drawn objects by using either non unique tag names or logic to remove old objects.

    If you wanted to always have 15 total objects you can use non unique tags, for example re use the same 15 tags. Each time you re use a tag it will update the old object to the new values effectively moving the object and limiting to a certain number of tags. You would have to modify your logic to work with repeating tags instead of making unique tag names for each object, this would be something you would have to figure out based on what you made.

    You can also use logic to remove old objects based on some factor. You can use RemoveDrawObject with tags of objects you created to remove them. One way to do that would be to use a for loop to loop over a number. This depends on how you make your tag, you would have to make tags that increment in order to be able to use a loop to later remove them by the tag name.

    An alternative would be to use a List and store the objects in the list after you draw them. Later you could loop over that list to remove objects based on whatever criteria you wanted.

    https://ninjatrader.com/support/help...moveDrawObject

    JesseNinjaTrader Customer Service

    Comment


      #3
      THank you for your suggestions and guidance Jesse. I will take a look and work on it.

      Comment


        #4
        Hi Jesse,

        Is it possible if I wanted to use time to control whether Rays are drawn or not? If I were to draw rays from today's trading data? Would that be possible? Would time zones matter if I was trading the US markets from Asia?
        If I were to remove all drawing objects the the Draw.Rays indicator, would the rest of my drawn objects be removed as well?

        Regards
        Kay Wai

        Comment


          #5
          Hello kaywai,

          You could make time conditions to control when you draw something.

          The rays are being drawn based on your conditions so part of that condition could be a time/date condition.

          https://ninjatrader.com/support/help...lightsub=today
          https://ninjatrader.com/support/help...ightsub=totime

          If I were to remove all drawing objects the the Draw.Rays indicator, would the rest of my drawn objects be removed as well?

          Any that were drawn by this script if you call RemoveDrawObject with its tag, other objects drawn by other scripts or manually are not affected.

          JesseNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by StockJock, 03-22-2022, 12:57 AM
          6 responses
          463 views
          0 likes
          Last Post aligator  
          Started by TradeSimple(Dre), Yesterday, 11:38 PM
          0 responses
          8 views
          0 likes
          Last Post TradeSimple(Dre)  
          Started by jwalkera87, Yesterday, 09:17 PM
          0 responses
          7 views
          0 likes
          Last Post jwalkera87  
          Started by jwalkera87, Yesterday, 09:14 PM
          0 responses
          8 views
          0 likes
          Last Post jwalkera87  
          Started by shinobe, Yesterday, 07:57 PM
          0 responses
          3 views
          0 likes
          Last Post shinobe
          by shinobe
           
          Working...
          X