• 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

Cannot Remove Drawn Rectangle

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

    Cannot Remove Drawn Rectangle

    Hi, NT Support Forum,

    I want to draw a rectangle across the candles when envelope of the bodies of three consecutive candles less than 10 ticks and I've written the following scripts to perform this:

    [I]protected override void Initialize()
    {
    CalculateOnBarClose= false; Overlay= true;
    }

    protected override void OnBarUpdate()
    {
    rangeTop = Math.Max(MAX(Close,3)[0],MAX(Open,3)[0]);
    rangeBot = Math.Min(MIN(Close,3)[0],MIN(Open,3)[0]);
    if (rangeTop-rangeBot<=10 * TickSize)
    {
    DrawRectangle("narrow range"+ CurrentBar, false, 3, rangeBot, -1,
    rangeTop,Color.Transparent,Color.Silver,8);
    }
    else if (rangeTop-rangeBot>10 * TickSize)
    {RemoveDrawObject("narrow range");}

    Silver rectangles appear on the screen correctly. However, when the body of the third candle moves beyond the 10-tick limit the rectangle just stops with 10 ticks height and remains there. My intention is to have it removed.

    Can anybody kindly offer some assistance on the above. Thanks.

    #2
    Thanks for the post okuricap - the remove would not work since a drawing object with the tag id narrow range would not exist > you add a current bar postfix to it in your initial call.
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CopyPasteGhost, Today, 11:22 AM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Sulfred, Today, 12:34 AM
    2 responses
    14 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by 1001111, Today, 10:23 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_PaulG  
    Started by NinjaCustomer, Today, 11:07 AM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_Melissa  
    Started by NtFan, Today, 10:47 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X