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

Draw Objects on First Instance Only

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

    Draw Objects on First Instance Only

    Dear Support,

    I can not find any reference on "How to draw only the first instance of a draw object."

    For Example: The condition "Draw.ArrowUp if Both Price and RSI are rising" will draw arrows on every successive bar that meets the condition. However, we are interested only in the first arrow until the condition no longer exists and the the condition exists again.

    Any reference or example scripts please?

    Many thanks.
    .

    #2
    Hello,

    if the arrow is being plotted on each bar, that likely would mean you are using a unique Tag name like "Tag" + CurrentBar

    To limit a drawing you would need to use a non unique tag like "MyTag" but this would update an existing object if the condition remains true.

    To limit this to the first occurrence only, you would likely need a bool variable. When the drawing is added, set the bool variable to true. You would also need to surround the drawing with a condition to check if the bool variable is true. This would limit the drawing to once when it becomes true the first time and not after. You could reset the bool variable when you want this logic to work again.

    Code:
    if(myBool == false)
    {
        Draw.Dot(...);
        myBool = true;
    }
    
    if(someConditionToReset)
        myBool = false;
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rdtdale, Today, 01:02 PM
    0 responses
    1 view
    0 likes
    Last Post rdtdale
    by rdtdale
     
    Started by alifarahani, Today, 09:40 AM
    3 responses
    15 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by RookieTrader, Today, 09:37 AM
    4 responses
    18 views
    0 likes
    Last Post RookieTrader  
    Started by PaulMohn, Today, 12:36 PM
    0 responses
    7 views
    0 likes
    Last Post PaulMohn  
    Started by love2code2trade, 04-17-2024, 01:45 PM
    4 responses
    41 views
    0 likes
    Last Post love2code2trade  
    Working...
    X