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

  • NinjaTrader_AdamP
    replied
    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.

    Leave a comment:


  • stockgoblin
    replied
    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?

    Leave a comment:


  • NinjaTrader_AdamP
    replied
    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.

    Leave a comment:


  • stockgoblin
    replied
    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?

    Leave a comment:


  • NinjaTrader_AdamP
    replied
    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.

    Leave a comment:


  • stockgoblin
    replied
    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?

    Leave a comment:


  • NinjaTrader_AdamP
    replied
    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.

    Leave a comment:


  • stockgoblin
    started a topic Too Many Rays on chart

    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

Latest Posts

Collapse

Topics Statistics Last Post
Started by Shai Samuel, Yesterday, 11:29 PM
0 responses
2 views
0 likes
Last Post Shai Samuel  
Started by futurestrader0000, Yesterday, 09:27 PM
0 responses
4 views
0 likes
Last Post futurestrader0000  
Started by AdeptistJune, Yesterday, 09:19 PM
0 responses
6 views
0 likes
Last Post AdeptistJune  
Started by Johnny90, 05-14-2022, 04:17 AM
4 responses
25 views
0 likes
Last Post jeronymite  
Started by junkone, Yesterday, 07:25 PM
0 responses
5 views
0 likes
Last Post junkone
by junkone
 
Working...
X