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

Access IText object with BarsAgo

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

    Access IText object with BarsAgo

    HI,

    With this code I can change the text color of the object I just created.
    Code:
    IText SpikeLong;
    SpikeLong = DrawText("SpikeL"+(CurrentBar-1), true, "S"+SCBull.ToString(), 1, High[1]+2*TickSize, 0, Color.Black, new Font ("Arial", 8), StringAlignment.Center, Color.Empty, Color.Empty, 0);
     SpikeLong.TextColor = Color.Gray;
    But how e.g can I access the object one bar ago?

    What is the syntax to do this?

    Thanks

    Thomas

    #2
    Hello td_910,
    You can retrive the specific draw object from the DrawObjects collection. Please refer to the below code which further demonstrates it.

    Code:
    IText txt = (IText)DrawObjects["SpikeL" + (CurrentBar-2).ToString()];
    if (txt != null)
    {
    	//do something
    }
    Last edited by NinjaTrader_Joydeep; 12-19-2012, 07:39 AM.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Very nice, Joydeep,

      now I know how to access object properties of earlier created objects.

      This works as well:
      Code:
      IText SpikeLong = (IText)DrawObjects["SpikeL" + (CurrentBar-2)];
      But, just for curiosity, what do I use BarsAgo for?

      Thanks

      Comment


        #4
        Hello td_910,
        Glad to know it works fine for you.

        The barsAgo property lets you to set where you want the text to be drawn (on the X/time axis)

        The bar (x axis co-ordinate) where the draw object will be drawn. For example, a value of 10 would paint the draw object 10 bars back.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Yes, right, know that.
          But what do I use it for when doing references with IText?

          Comment


            #6
            Hello td_910,
            The DrawObjects collection will return the draw objects based on the name/tag of the draw object and not by the barsAgo property.
            JoydeepNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by judysamnt7, 03-13-2023, 09:11 AM
            4 responses
            53 views
            0 likes
            Last Post DynamicTest  
            Started by ScottWalsh, Today, 06:52 PM
            4 responses
            33 views
            0 likes
            Last Post ScottWalsh  
            Started by olisav57, Today, 07:39 PM
            0 responses
            5 views
            0 likes
            Last Post olisav57  
            Started by trilliantrader, Today, 03:01 PM
            2 responses
            19 views
            0 likes
            Last Post helpwanted  
            Started by cre8able, Today, 07:24 PM
            0 responses
            6 views
            0 likes
            Last Post cre8able  
            Working...
            X