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

Too Many Rays on chart

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

    Too Many Rays on chart

    Hi!

    I have a custom indicator that draws rays between the closing prices of bars. After awhile too many rays get drawn and bog down the program. I only need to see the rays that are within a certain distance from the current closing price of the current bar. Is there a way to tell the value of a ray that was made many bars ago at the current bar and remove it if it is outside of a certain range?

    Thanks for any help

    #2
    stockgoblin,

    Yes, this is possible. Essentially you will want to modify the indicator so that it deletes rays when they do not satisfy some condition.

    Here are some reference samples.

    Drawing objects that update : http://www.ninjatrader.com/support/f...ead.php?t=3419

    Removing objects : http://www.ninjatrader.com/support/f...ad.php?t=18995

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Ray points

      Yea, I'm just confused to how to determine the value of a ray that's already been made at the time of the current bar. The ray was made of two points in the past but how do I determine it's value at the current bar?

      Comment


        #4
        Stockgoblin,

        I am not sure what you mean. Could you please clarify?

        If you store the references to your rays, these are IRay objects.

        http://www.ninjatrader.com/support/h....html?iray.htm

        You can access parameters of the Ray, by doing for example :

        Code:
        IRay my_ray;
        
        protected override void OnBarUpdate()
        {
           //Code for drawing arrays, etc. somewhere you have my_ray = DrawRay( <parameters>);
        
        Print( my_ray.Anchor1BarsAgo); //An int value representing the number of bars ago of the 1st anchor point
        
        Print( my_ray.Anchor1Y);  //A double value representing the y value of the 1st anchor point
        
        Print( my_ray.Anchor2BarsAgo);  //An int value representing the number of bars ago of the 2nd anchor point
        
        Print( my_ray.Anchor2Y);  //A double value representing the y value of the 2nd anchor point
        
        }
        Please let me know if I may assist further.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          current Ray Y value

          Okay,

          example:

          Ray made by previous 2 bars, say at Y close values of 10 and 20. So, at the next current bar the ray is at Y value 30. The close of the current bar is at say 12. I only want rays that are within say 10 of the current bar close so that ray can be removed as it's current value is above 22.

          How do I determine the 30 value, the current Y value of a previous ray?

          Comment


            #6
            Stockgoblin,

            If I understand correctly, you would use :

            my_ray.Anchor2Y;

            Where my_ray is the previous ray drawn like :

            my_ray = DrawRay( <input parameters>);

            Please let me know if I may assist further.
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              Ray points

              Alright, I think I understand,

              This is the Drawray code I use:

              DrawRay("Stockline" + Time, false, barsAgo, Previouscrossclose, CurrentBar, Crossclose, CrossColor, DashStyle.Dot, lineWidth);


              So each ray is tagged differently.
              How would I refer to all of them?

              Comment


                #8
                Originally posted by stockgoblin View Post
                Alright, I think I understand,

                This is the Drawray code I use:

                DrawRay("Stockline" + Time, false, barsAgo, Previouscrossclose, CurrentBar, Crossclose, CrossColor, DashStyle.Dot, lineWidth);


                So each ray is tagged differently.
                How would I refer to all of them?
                Stockgoblin,

                I am happy to assist.

                You could name each DrawRay as "Stockline"+Previouscrossclose or something more useful for referencing them, then use the RemoveDrawObject("Stockline"+Previouscrossclose); method to get rid of them

                Alternatively you could store all the IRay objects in a list or something and iterate through the list to check for conditions and delete.

                Here is a forum post with some references to uses of Foreach with draw objects : http://www.ninjatrader.com/support/f...ad.php?t=45776

                Please let me know if I may assist further.
                Adam P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by rexsole, Today, 11:48 AM
                1 response
                11 views
                0 likes
                Last Post NinjaTrader_PatrickG  
                Started by jeronymite, Yesterday, 05:05 PM
                3 responses
                52 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Started by Don22Trader1, Yesterday, 05:54 PM
                3 responses
                46 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by Jebulay, Today, 08:36 AM
                1 response
                42 views
                0 likes
                Last Post NinjaTrader_PatrickG  
                Started by ShayeAus, Yesterday, 09:09 PM
                4 responses
                68 views
                0 likes
                Last Post bltdavid  
                Working...
                X