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

DrawTriangle multiple times on same bar

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

    DrawTriangle multiple times on same bar

    I'm using the DrawTriangle to show when my indicator criteria are being met. I'm using;
    DrawTriangleDown("tag10" + CurrentBar, true, 0, Price13, Color.DeepSkyBlue);
    The " + CurrentBar " keeps NT from erasing previous triangles. This works except for when there should be multiple triangles on the same bar. When this should occur, then older triangles disappear on only the most recent triangle stays.

    Is there a work around for this?

    Thanks,

    Safetrading

    #2
    SafeTrading,

    Thank you for your note.

    You would need to either add a logic condition for when you have multiple true instances and to place different DrawTriangles or use a for loop to draw those triangles with the different Tag names so they do not get erased.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      I have another problem, when drawing multiple triangles one on top of another. DrawTriangleUp() and DrawTriangleDown() do not have the option of a yPixelOffset. Therefore I cannot correctly adjust the distance between the triangles as needed.

      My workaround is to use DrawText() in combination with the font WebDings to plot several triangles on top of or below the same bar.

      Please consider adding this option to DrawTriangle(), at least for NinjaTrader 8.

      @safetrading: The only thing you need to do to plot several triangles for the same bar is to make sure that

      -> they all have different tags (triangleA + "CurrentBar", .. ), (triangleB + "CurrentBar", ...) etc.
      -> to make sure that they have a different y value in order to avoid that one plots on top of another triangle

      Comment


        #4
        Harry,

        You don't have a Y-pixel offset but you do have a Y value that can be used for that method.

        Example -
        Code:
        for( int i = 0; i < 10; i++ )
        {
            DrawTriangleDown("myTri" + CurrentBar + i, true, 0, High[0] + (i*2) * TickSize, Color.Red);
        }
        This example will draw a triangle down 10 times each with a increasing number in the Y Value

        I have attached a screen shot of the what this code outputs on the chart
        Attached Files
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Cal View Post
          Harry,

          You don't have a Y-pixel offset but you do have a Y value that can be used for that method.

          Example -
          Code:
          for( int i = 0; i < 10; i++ )
          {
              DrawTriangleDown("myTri" + CurrentBar + i, true, 0, High[0] + (i*2) * TickSize, Color.Red);
          }
          This example will draw a triangle down 10 times each with a increasing number in the Y Value

          I have attached a screen shot of the what this code outputs on the chart

          Thank you Cal, but this will not work as the charts have an Autoscale feature. If you switch to a higher time frame chart, the triangles will overlap. If you switch to a lower time frame chart, the triangles will be too far away from each other. Therefore it is no solution to use the ticksize (your idea would not pass the c-test by William Eckhardt).

          In a second step I had replaced the ticksize with a multiple (for example 0.5) of the true range, which already yields better values. However, this also results in unstable distances between the triangles due to autoscaling.

          The only correct way to do it now, is to use DrawText() with Webdings triangles and a fixed pixel offset. Alternative methods as you suggested do not yield satisfactory results. I have therefore asked for this feature, as it makes things easier than playing around with Webdings.

          Comment


            #6
            Originally posted by Harry View Post
            Thank you Cal, but this will not work as the charts have an Autoscale feature. If you switch to a higher time frame chart, the triangles will overlap. If you switch to a lower time frame chart, the triangles will be too far away from each other. Therefore it is no solution to use the ticksize (your idea would not pass the c-test by William Eckhardt).
            I second this idea and the feature should be added to all draw objects.

            Dan
            eDanny
            NinjaTrader Ecosystem Vendor - Integrity Traders

            Comment


              #7
              Originally posted by Harry View Post
              Thank you Cal, but this will not work as the charts have an Autoscale feature. If you switch to a higher time frame chart, the triangles will overlap. If you switch to a lower time frame chart, the triangles will be too far away from each other. Therefore it is no solution to use the ticksize (your idea would not pass the c-test by William Eckhardt).

              In a second step I had replaced the ticksize with a multiple (for example 0.5) of the true range, which already yields better values. However, this also results in unstable distances between the triangles due to autoscaling.

              The only correct way to do it now, is to use DrawText() with Webdings triangles and a fixed pixel offset. Alternative methods as you suggested do not yield satisfactory results. I have therefore asked for this feature, as it makes things easier than playing around with Webdings.
              I asked for this in 2009. Followed up in 2010 and 2011. Maybe we can get it 4 years later?



              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,229 views
              0 likes
              Last Post xiinteractive  
              Started by andrewtrades, Today, 04:57 PM
              1 response
              14 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by chbruno, Today, 04:10 PM
              0 responses
              7 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              441 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              12 views
              0 likes
              Last Post FAQtrader  
              Working...
              X