Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:	201
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:	195
Size:	3.3 KB
ID:	1051111
    JesseNinjaTrader Customer Service

    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.
          JesseNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CortexZenUSA, Today, 12:53 AM
          0 responses
          1 view
          0 likes
          Last Post CortexZenUSA  
          Started by CortexZenUSA, Today, 12:46 AM
          0 responses
          0 views
          0 likes
          Last Post CortexZenUSA  
          Started by usazencortex, Today, 12:43 AM
          0 responses
          2 views
          0 likes
          Last Post usazencortex  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          168 responses
          2,262 views
          0 likes
          Last Post sidlercom80  
          Started by Barry Milan, Yesterday, 10:35 PM
          3 responses
          10 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X