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([COLOR=#0000ff][COLOR=#0000ff]"Rectangle "+ [/COLOR]CurrentBar.ToString()[/COLOR],false,10,MIN(Close,10)[0],0,MAX(Close,10)[0],Color.Green,Color.Green,3);


    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;


            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 aussugardefender, Today, 01:07 AM
              0 responses
              3 views
              0 likes
              Last Post aussugardefender  
              Started by pvincent, 06-23-2022, 12:53 PM
              14 responses
              238 views
              0 likes
              Last Post Nyman
              by Nyman
               
              Started by TraderG23, 12-08-2023, 07:56 AM
              9 responses
              384 views
              1 like
              Last Post Gavini
              by Gavini
               
              Started by oviejo, Today, 12:28 AM
              0 responses
              4 views
              0 likes
              Last Post oviejo
              by oviejo
               
              Started by pechtri, 06-22-2023, 02:31 AM
              10 responses
              125 views
              0 likes
              Last Post Leeroy_Jenkins  
              Working...
              X