• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

reference IFibonacciRetracements fibRetracementsLongs

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

    reference IFibonacciRetracements fibRetracementsLongs

    Scenario: I have drawn a FibonacciRetracement previously. I want to change the EndTime parameter later based on some program logic condition being met.

    Question: Can I reference the IFibonacciRetracements so i can change only the EndTime parameter of an existing drawobject or do I need to redraw the FibonacciRetracement again? Or can I use DrawObjects to get the reference?

    I would hope to change only that one attribute instead of save all the parameters to redraw it again later.
    Last edited by ct; 07-19-2019, 08:16 PM.

    #2
    Hello ct,

    Thanks for your post.

    Yes, you can change only the one parameters and the fib will be redrawn using that along with the other properties that you did not change.

    here is a quick example you can test with (on live or market replay data)

    Note that I declared the object in the variables region as private at the class level so I can access the properties more easily.

    Once the data is live, the fib is drawn on the first bar close back 10 bars. Then, 5 bars later the fib is then drawn to the current bar as EndBarsAgo is all I changed.

    Code:
            #region Variables
                private bool doitonce = true;
                private int startbar;
                private IFibonacciRetracements fibRetracements;
            #endregion
    
            protected override void Initialize()
            {
                Overlay                = true;
            }
    
            protected override void OnBarUpdate()
            {
                if (Historical) 
                    return;  // wait until live data
    
                if (!Historical && doitonce)  // draw on close of first live bar once.
                {
                    fibRetracements = DrawFibonacciRetracements("tag1", true, 10, Low[10], 0, High[0]);
                    doitonce = false;
                    startbar = CurrentBar;   // save the start bar
                }
    
                if (CurrentBar - startbar == 5 && fibRetracements != null )
                {
                    fibRetracements.EndBarsAgo = 0;   // set the fib to the current bar
                }    
            }
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Paul

      Thanks.

      Will this allow me to save or reference "fibRetracements" outside of a method/procedure/subroutine or on a return to that method after having exited?
      private IFibonacciRetracements fibRetracements; <--- I think this is all I was lacking. Duh. Cheers

      Comment


        #4
        Hello ct,

        Thanks for your reply.

        I believe that will be the case when you create the variable/object at the class level.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Paul

          Got it. Give yourself a gold start from me.

          And thanks for the prompt reply. Much appreciated.

          Cheers

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by buick, Today, 09:37 PM
          0 responses
          4 views
          0 likes
          Last Post buick
          by buick
           
          Started by Hagar, Today, 07:12 PM
          0 responses
          6 views
          0 likes
          Last Post Hagar
          by Hagar
           
          Started by jtrading82, Today, 01:55 PM
          4 responses
          28 views
          0 likes
          Last Post bppayne
          by bppayne
           
          Started by Hagar, Today, 06:52 PM
          0 responses
          4 views
          0 likes
          Last Post Hagar
          by Hagar
           
          Started by vivekniwas, Today, 04:56 PM
          0 responses
          7 views
          0 likes
          Last Post vivekniwas  
          Working...
          X