• 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

Drawing a triangle that touches a bar, similar to the icon of entry

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

    Drawing a triangle that touches a bar, similar to the icon of entry

    Hi Guys,

    It sounds like a dumb question, but I really couldn't find how to draw (from an indicator) a triangle that touches a bar, similar to the icon of entry.

    How do I do that, and how do I control its color and size?

    Thanks

    #2
    Hello,
    Thank you for writing in.
    You can plot triangle markers by using the DrawTriangleUp() and DrawTriangleDown() methods. The size of the triangles that are drawn are based off of your bar width. You can change their color by using their color overload. Please see the following links for more information on these two methods. DrawTriangleUp() and DrawTriangleDown().
    I have provided an example of using the DrawTriangleUp() and DrawTriangleDown() methods.
    DrawTriangleUp("my up triangle" + Time[0], true, 0, Close[0], Color.Blue);
    DrawTriangleDown("my down triangle" + Time[0], true, 0, Open[0], Color.Green);
    If you are wanting to have complete control of the triangle size you could use the DrawTriangle() method. This will allow you to designate each of the three anchor points for the triangle. Please see the following link on DrawTriangle()
    I have provided an example of how to use DrawTriangle().
    DrawTriangle("my triangle" + Time[0], 2, High[2], 1, High[1], 0, High[0], Color.Red);
    If we can be of any other assistance please let us know.
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      Thanks for your reply. However, I did not refer to the methods for which there exists documentation. Rather, I wanted to know how to draw the "TriangleRight" that appears when entering a trade (please see attached a picture with two such triangles) and how to control its color and size.

      Best
      Attached Files

      Comment


        #4
        Hello,
        The only way to draw triangles like the markets for executions is to use the DrawTriangle() method. There is not a DrawTriangleRight() method. I am submitting a feature request to our development team for consideration in adding such a method into future versions of NinjaTrader.
        Cody B.NinjaTrader Customer Service

        Comment


          #5
          Hi Cody,

          Based on the documentation, DrawTriangle() gets the x coordinates, i.e., barsAgo, as ints, whereas the entry marker's left edges seem to be between the current and previous bar.

          Could you write the exact DrawTriangle() call that results in an entry marker, pointing at the close of the CurrentBar?

          Thanks

          Comment


            #6
            Hello,
            You can use the integer BarsAgo as one of the overloads to get the x coordinates however there is another overload that allows you to use DateTime instead. You can use DateTime to plot between bars. I have provided an example of how you could do this below.
            Code:
            DrawTriangle("tag2"+ CurrentBar, true, Time[0].AddSeconds(0),Close[0], Time[0].AddSeconds(-10), Close[0] + .125* TickSize, Time[0].AddSeconds(-10), Close[0] - .125* TickSize, Color.Red,Color.Red, 10);
            Another option to draw these markers would to use a DrawText() method and use a wingdings 3 font using the letter "t" for the left pointing marker and "u" for the right pointing marker. Please see the following link on translating to wingdings characters.

            I have provided an example below of how you could use this to work.
            Code:
            if(Close[0] > Open[0] && SMA(20)[0] > SMA(21)[0])
            			{
            				DrawText ("tag1"+CurrentBar, true, "t", Time[0].AddSeconds(1), Close[0], 5, Color.Red, new Font ("WingDings 3", 6), StringAlignment.Far, Color.Transparent, Color.Transparent, 0); 
            			}
            If these options do not perform as you like you could use the Plot Override Class to get the x and y coordinates and draw the triangle based off of those values. If you have not worked with the Plot Override Class I would recommend to take a look at the CustomPlotSample included with NinjaTrader.
            Cody B.NinjaTrader Customer Service

            Comment


              #7
              Hi Cody,

              Looks great. I will try the options you provided as soon as I can.
              Where can I find the link you mentioned re translating to wingdings characters?

              Thanks

              Comment


                #8
                Hello,
                Here is the link for translating to Wingdings. http://speakingppt.com/wp-content/up...peakingppt.png
                Cody B.NinjaTrader Customer Service

                Comment


                  #9
                  Worked perfectly, thanks!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by topisi9359, Today, 06:54 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post topisi9359  
                  Started by HiddenPhilosopher, Today, 06:45 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post HiddenPhilosopher  
                  Started by PG7940, Today, 04:26 AM
                  0 responses
                  7 views
                  0 likes
                  Last Post PG7940
                  by PG7940
                   
                  Started by marcus2300, Today, 02:25 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post marcus2300  
                  Started by drpapp, 01-24-2019, 06:57 AM
                  5 responses
                  69 views
                  0 likes
                  Last Post pjsmith
                  by pjsmith
                   
                  Working...
                  X