Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Rectangles only appear once

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

    Rectangles only appear once

    Hi guys

    I'm trying to get rectangles to appear on each occurrence of a condition.

    However, try as I might, I've only been able to make them appear only on the latest occurrence of the condition. Although this is OK for live trading, I'd like to see these produced historically - each time the condition is met.

    As an example, I've got a strategy with this code:

    Code:
    if (CrossAbove(EMA(14), Close, 1))
                    
    {DrawRectangle("My rectangle",false,10,MIN(Close,10)[0],0,MAX(Close,10)[0],Color.Green,Color.Green,3);}}
    As you'll see from the below image, a rectangle is drawn only once.

    Taken from NT's Help for 'DrawRectangle':
    endBarsAgo
    The end bar (x axis co-ordinate) where the draw object will terminate
    For this parameter, I've just placed a '0', but is there a way of getting the rectangle to occur at every occurrence?

    Any help with this will be much appreciated.
    Attached Files

    #2
    Hello,

    You will need to use a unique tag name if you wish to have the previous drawing kept.

    Try:
    Code:
    DrawRectangle("Rectangle "+ CurrentBar.ToString(),false,10,MIN(Close,10)[0],0,MAX(Close,10)[0],Color.Green,Color.Green,3);
    http://www.ninjatrader.com/support/h...ml?drawing.htm

    For this parameter, I've just placed a '0', but is there a way of getting the rectangle to occur at every occurrence?
    The above should help with resolving this as well

    Please let me know if I can be of further assistance.
    LanceNinjaTrader Customer Service

    Comment


      #3
      It works a treat!

      Without your help, I would never have worked this one out.

      Thanks very much, Lance!

      Comment


        #4
        You're most welcome. Glad to hear its working for you.

        Let me know if I can be of further help.
        LanceNinjaTrader Customer Service

        Comment


          #5
          Hi Lance - I do have another question about 'DrawRectangle'.

          After you draw a rectangle using the chart drawing tools, you can then click on 'Properties' and change the width. But I can't figure out a way of doing this thru coding using DrawRectangle.

          Is there a way of coding this so I can get thicker edges?

          Thanks very much again.

          Comment


            #6
            Hello,

            You would need to store it as an IRectangle and then call the Pen property on that.

            Code:
            //Draws a rectangle
            IRectangle rectangle = DrawRectangle("tag1", true, 10, Low[10] - TickSize, 5, High[5] + TickSize, Color.PaleGreen, Color.PaleGreen, 2);
            //changes the pen width to 4
            rectangle.Pen.Width = 4;
            http://www.ninjatrader.com/support/h...irectangle.htm

            Please let me know if I can be of further assistance.
            LanceNinjaTrader Customer Service

            Comment


              #7
              Thanks very much again, Lance. As last time, it works a treat.

              It's a shame that 'edge thickness' doesn't appear with the normal parameters, as it's so helpful, if not essential. Maybe this will be incorporated into NT8... We'll have to wait and see!

              Cheers.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by nandhumca, Today, 08:47 PM
              0 responses
              3 views
              0 likes
              Last Post nandhumca  
              Started by BullyWig Trader, Today, 07:15 PM
              0 responses
              2 views
              0 likes
              Last Post BullyWig Trader  
              Started by ezrollin, Today, 05:13 PM
              1 response
              11 views
              0 likes
              Last Post ezrollin  
              Started by ineuron, Today, 04:29 PM
              0 responses
              8 views
              0 likes
              Last Post ineuron
              by ineuron
               
              Started by topa11, Today, 04:21 PM
              0 responses
              16 views
              0 likes
              Last Post topa11
              by topa11
               
              Working...
              X