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 Pattontje, Yesterday, 02:10 PM
    2 responses
    14 views
    0 likes
    Last Post Pattontje  
    Started by flybuzz, 04-21-2024, 04:07 PM
    17 responses
    229 views
    0 likes
    Last Post TradingLoss  
    Started by agclub, 04-21-2024, 08:57 PM
    3 responses
    17 views
    0 likes
    Last Post TradingLoss  
    Started by TradingLoss, 04-21-2024, 04:32 PM
    4 responses
    43 views
    2 likes
    Last Post TradingLoss  
    Started by cre8able, 04-17-2024, 04:16 PM
    6 responses
    56 views
    0 likes
    Last Post cre8able  
    Working...
    X