• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 percma, Today, 02:51 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_ChristopherD  
    Started by Vincere, Today, 04:38 AM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_EricB  
    Started by trader_rick, Today, 04:02 AM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Started by Abilene, Today, 01:27 AM
    0 responses
    17 views
    0 likes
    Last Post Abilene
    by Abilene
     
    Started by simjs, Yesterday, 08:11 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Working...
    X