Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Eliminate Multiple arrows in the same bar

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

    Eliminate Multiple arrows in the same bar

    Hi, I created an Indicator that when a certain condition was met, it would draw an arrow. I actually have had this happen in a couple of cases where I have created an indicator to draw arrow, where it draws 1, 2, 3 4 ,5 arrows on the same bar when the condition is met.
    Here is a snippet of the code, in the OnBarUpdate section: Note Bars in Progress 1 is a 144 tick dataseries
    protected override void OnBarUpdate()
    {
    if(CurrentBar < 21) return;
    if (BarsInProgress == 1)
    {

    if (AuHMA1.Trend[0] == 1 && AuHMA1.Trend[1] != 1 && AuLinReg1.Trend[0] == 1 )
    {

    UpArrow[0] =1;
    if (BarsInProgress == 0) entryBar = CurrentBar;
    }
    else UpArrow[0] =0;


    if (AuHMA1.Trend[0] == -1 && AuHMA1.Trend[1] != -1 && AuLinReg1.Trend[0] ==-1 && CurrentBar != entryBar)
    {
    DownArrow[0] = 1;
    //Draw.ArrowDown(this, "ARROWDOWN" + CurrentBar, false, 0, High[0]+TickSize*1, long_Exit_Color);
    if (BarsInProgress == 0) entryBar = CurrentBar;
    }
    else DownArrow[0] =0;


    }

    /// Bars in progress is 0 for this code
    if (UpArrow[0] == 1 && UpArrow[1] == 0 && CurrentBar != entryBar) Draw.ArrowUp(this, "ARROWUP" + CurrentBar, false, 0, Low[0]-TickSize*1, long_Entry_Color);
    if (DownArrow[0] == 1 && DownArrow[1] == 0 && CurrentBar != entryBar ) Draw.ArrowDown(this, "ARROWDOWN" + CurrentBar, false, 0, High[0]+TickSize*1, long_Exit_Color);

    }

    Trying to figure out how to eliminate the multiple arrows to just one?

    #2

    hi set2win,

    apparently arrows are drawn every 144tick series is called,
    so probably playing with the tag name could help, how about CurrentBars[0] in the tag name ?
    Draw.ArrowDown(this, "ARROWDOWN" + CurrentBars[0], false, 0, High[0]+TickSize*1, long_Exit_Color);
    does it do the trick ?

    Comment


      #3
      Thks, Amedeus, that worked!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      633 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      567 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X