Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to know if an arrow exists on the previous bar?

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

    How to know if an arrow exists on the previous bar?

    My indicator occasionally draws up arrows like this:

    DrawArrowUp("MyArrowUp" + CurrentBar, false, 0, y, Color.Black);

    I would like to know if there is such an arrow on the previous bar, and if yes, do something.

    Something like:
    if (DrawArrowUp("MyArrowUp" + CurrentBar - 1) exists
    then do something

    Thanks

    #2
    Originally posted by sixteencorners View Post
    My indicator occasionally draws up arrows like this:

    DrawArrowUp("MyArrowUp" + CurrentBar, false, 0, y, Color.Black);

    I would like to know if there is such an arrow on the previous bar, and if yes, do something.

    Something like:
    if (DrawArrowUp("MyArrowUp" + CurrentBar - 1) exists
    then do something
    In what context?

    From within the same indicator?
    From within a different indicator?
    From within a strategy?

    Did you write this indicator?
    Can you attach the source of your indicator?

    Drawing an Up arrow or Down arrow does not, by definition, leave a "breadcrumb" for you to interrogate later to see if an arrow was drawn. You'll have to design your own "breadcrumb" code so that you can check if an arrow exists, and on what bar (if you need that, too).

    Such code is not hard, but the design can vary based upon the context in which you want to do the future interrogation. For example, if you want to check this from a strategy, the usual way is leave "breadcrumbs" using a DataSeries or a BoolSeries.

    If someone else wrote the indicator, chances are this "breadcrumb" code may already be in there. But if you're the sole author, then you'll need to write it yourself.

    Comment


      #3
      Hello sixteencorners,

      Thanks for your post.

      Member bltdavid has offered some valued considerations.

      One approach you could take would be to create an int variable to store the bar number of where the last arrow was drawn and then your code would test to see if the current bar minus the saved bar is equal to 1 indicating that indeed an arrow was applied on the previous bar. The value of CurrentBar is the bar number (Reference: http://ninjatrader.com/support/helpG...currentbar.htm) of the bar being processed.

      For example, assume you have created an integer variable called savedBar.

      if (Your conditions to draw arrow)
      {
      DrawArrowUp("MyArrowUp" + CurrentBar, false, 0, y, Color.Black);
      savedBar = CurrentBar; // store the bar the latest arrow is drawn on
      }

      if ((CurrentBar - savedBar) == 1)
      {
      // do something here
      }

      Comment


        #4
        Thank you, problem solved. So easy it is embarrassing!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        579 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 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
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X