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
                }    
            }

    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.

        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 Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X