Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Hiding multiple condition arrows

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

    Hiding multiple condition arrows

    Hello,
    I have a bit of a house cleaning issue that I can't figure out and am hoping for some help.
    I have several conditions that print arrows as is shown in the attachment. Obviously the arrows print when the condition is true, but I only want to see the arrow when the condition is true the first time. Is there a way to allow the condition to be true for each succeeding bar but only print the arrow on the first bar? Any ideas?
    Thanks.
    Attached Files

    #2
    Hello CaptainAmericaXX,

    Thank you for the post.

    You would need to use logic to control this, likely a bool variable would work for this use case. You would also need to reset this at some point so the arrow can be drawn for future conditions when you wanted it. A simple example would be toggling between two conditions, you want the first arrow drawn and skip each arrow after that until the opposing condition which it can be reset. Here is a simple example of that use case:

    Code:
    bool canDrawArrowUp = true;
    bool canDrawArrowDown = true;
    protected override void OnBarUpdate()
    {
        if(CurrentBar < 1) return;
        if(Close[0] < Open[1])
        {
            if(canDrawArrowUp)
            {
                Draw.ArrowUp(this,"up"+ CurrentBar, true, 0, Close[0], Brushes.Red);
                canDrawArrowUp = false;    
                canDrawArrowDown = true;
            }
        } 
    
        else if(Close[0] > Open[1])
        {
            if(canDrawArrowDown)
            {
                Draw.ArrowDown(this,"down" + CurrentBar, true, 0, Close[0], Brushes.Green);
                canDrawArrowUp = true;    
                canDrawArrowDown = false;
            }
        } 
    }
    In this use case if the close is greater or lesser than the open of the prior bar delegates if an arrow is drawn.

    Without using any logic, this is drawn on nearly every bar:
    Click image for larger version

Name:	2019-03-12_1159_001.png
Views:	298
Size:	4.6 KB
ID:	1051110

    Using the bool conditions allows you to control when these happen:

    Click image for larger version

Name:	2019-03-12_1159.png
Views:	284
Size:	3.3 KB
ID:	1051111

    Comment


      #3
      Ahh, simple enough. Thanks Jesse!

      Comment


        #4
        Originally posted by NinjaTrader_Jesse View Post
        Hello CaptainAmericaXX,

        Thank you for the post.

        You would need to use logic to control this, likely a bool variable would work for this use case. You would also need to reset this at some point so the arrow can be drawn for future conditions when you wanted it. A simple example would be toggling between two conditions, you want the first arrow drawn and skip each arrow after that until the opposing condition which it can be reset. Here is a simple example of that use case:
        Hi Jesse,

        Jim suggested a simple one bool approach here that I believe produces the same result. Is that the case?

        Thanks.

        Dear Support, A simple indicator draws many buy and sell arrows when price is above and below RSI 50 line. I am looking for a sample script that will keep only

        Comment


          #5
          Hello aligator,

          Yes, it looks this would be another way to accomplish the task.

          Please let me know if I may be of additional assistance.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          128 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          73 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          116 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          109 views
          1 like
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          88 views
          0 likes
          Last Post CarlTrading  
          Working...
          X