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

Accessing Previous Occurrances of an IRay Object

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

    Accessing Previous Occurrances of an IRay Object

    In the Ninja Trading Help manual there is a definition of Iray.

    \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    Examples

    protected override void OnBarUpdate()
    {

    // Draws a ray
    IRay ray = DrawRay("tag1", 10, 1000, 0, 1001, Color.LimeGreen);



    // Print the number of bars ago the 2nd anchor point is located at

    Print(ray.Anchor2BarsAgo);
    }
    ///////////////////////////////////////////////////////////////////////////////////////

    How do I access previous occurrences of the IRay object?

    thanks,
    taddypole...

    #2
    Each time a new ray is drawn with the same variable name the previous will no longer be stored.

    You can access previous occurrences a few different ways

    1. with the tag name (see properties in next link)
    2. with a loop (see example in next link)


    This might be of use as well: http://www.ninjatrader.com/support/h...rawobjects.htm

    If you're dealing with global objects this is a great example:


    There may be other ways but these are the first two that came to mind.

    Let me know if I can further assist.
    LanceNinjaTrader Customer Service

    Comment


      #3
      Thank you Lance,

      I'm looking at the indicator "SwingRaysV1.cs (attached).

      In the Code, a swing High is created as below:

      IRay newRay = DrawRay( "highRay" + (CurrentBar-strength), false, strength, lastSwingHighValue, 0, lastSwingHighValue, swingHighColor, DashStyle.Dot, 2);

      Later as a test to see if the swing is broken, they do a Peek() as below:

      IRay priorRay = (IRay) swingHighRays.Peek();

      It appears that the "Tags" are 'newRay' and 'priorRay' respectively and thus only good for the current Ray.

      I would like to Peek() at previous occurrences to get the anchors of those Rays.

      I looked at the references you provided and still couldn't see how to do this.
      Attached Files
      Last edited by Taddypole; 06-21-2013, 01:25 PM.

      Comment


        #4
        From looking at the Ray line you have here

        "highRay" + (CurrentBar-strength)

        Will be the tag name. You could store this in some manor and can then reference a previous ray through the use of the tag name

        While the following would not be the most efficient way you could so something like

        foreach (IDrawObject draw in DrawObjects)
        {
        if(draw.tag == StringTagYoureLookingFor)
        yourOtherVariable = draw.Anchor1Y;
        }

        Alternatively you could create your own list of draw objects so that you could reference the specific one you were looking for
        LanceNinjaTrader Customer Service

        Comment


          #5
          thanks Lance,

          hoping there was an easier way, but I guess not.

          taddypole...

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by algospoke, Yesterday, 06:40 PM
          2 responses
          19 views
          0 likes
          Last Post algospoke  
          Started by ghoul, Today, 06:02 PM
          3 responses
          14 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          45 views
          0 likes
          Last Post jeronymite  
          Started by Barry Milan, Yesterday, 10:35 PM
          7 responses
          20 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by AttiM, 02-14-2024, 05:20 PM
          10 responses
          181 views
          0 likes
          Last Post jeronymite  
          Working...
          X