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

DrawText

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

    DrawText

    Hello,


    I want to add to an indicator that plots values below the bar and works ok now but I want to add autoscale true to my DrawText(CurrentBar.ToString(),str,0,Low[0]-TickSize,ChartControl.AxisColor);


    But I dont understand from HelpGuide what I have to add (beside "......" which is clear)

    DrawText(...., ..................,.......... , ............., ......, int yPixelOffset, ........ Font font, StringAlignment alignment, Color outlineColor, Color areaColor, int areaOpacity)


    I dont understand why in the helpguide there is almost every time the minimum example shown.


    Thank you for giving me a DrawText example that contents all.



    Thank you!
    Tony

    #2
    Hello tonynt,

    Thanks for your post.

    Here is a complete example.

    DrawText("Tagname", true, "Text to Display", 0, Low[0] - 8 * TickSize, 0, Color.Red, new Font ("Arial", 18, FontStyle.Bold),StringAlignment.Center, Color.Empty, Color.Empty, 0);
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      thank you for your reply. Could do it with this help easily.

      Another question concerning drawing please: when I have DrawDot or DrawSquare High[0]+3*TickSize I thought it will be plotted always 3Ticks above the High. But its sometimes closer to the bar. I mean its the same for a chart but another chart with another dataseries the distance is different. Isnt it then always High+3*Ticks?

      What would I have to add or change so that the distance is each chart the same. This is important because there are other informations by text between bar and drawingobject.


      Thank you!
      Tony
      Last edited by tonynt; 08-10-2018, 12:06 PM. Reason: typing error

      Comment


        #4
        Hello tonynt,

        Thanks for your reply.

        I suspect it would be because of the scaling/instrument of the chart. As an extreme example, if you plotted 3 ticks above the high of a minute bar and then plot 3 ticks above the high of 60 minute bar, chances are the 60 minute bar would be touching the draw object because the chart would like be scaled quite differently.

        I don't know that there is a one size fits all answer for this, using the draw methods, and if anyone reading this in the community has a solution please feel free to post.

        When I create indicators with drawing objects I usually create a user adjustable integer parameter called Offset that lets the user adjust the distance, for me that is the easiest solution and allows for personal adaptation.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Paul,


          thank you for the hint. This is OK, but the problem occurs also with same dataseries.


          I attach a screenshot with 6S on the left and 6A on the right.

          It occurs that its even more different than you see here - in same dataseries.
          So that its plotting over the hightest number of bid/ask even more. So I add more distance in the code but then sometimes its plotting over the text which is above. Thats why I want to have it simply constant - in same dataseries.



          Thank you!
          Tony
          Attached Files
          Last edited by tonynt; 08-10-2018, 12:56 PM. Reason: typing error

          Comment


            #6
            Hello tonynt,

            Thanks for your reply.

            If you have added autoscale = true to your indicator then that will allow the chart scale to move the relationship of the objects.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Paul,


              with your hint that its caused by autoscale I want to make a workaround for solution to create a certain distance plotted on the chart (so that I dont need autoscale for the indicator to be plotted the drawingobjects in visible area) but its not plotting both strings, only one of them. What is wrong here please?


              Thank you!
              Tony


              string str1 = string.Empty;
              str1+=Time[0].ToString() + ": ";
              DrawText(CurrentBar.ToString(), true, str1, 0, High[0] + 4*TickSize, 0, Color.Black, new Font ("Arial", 8, FontStyle.Regular),StringAlignment.Center, Color.Empty, Color.Empty, 0);

              string str = string.Empty;
              str = string.Format("A {0}",SumAsks(0)+SumBids(0));
              DrawText(CurrentBar.ToString(), true, str, 0, Low[0] - 4*TickSize, 0, Color.Black, new Font ("Arial", 8, FontStyle.Regular),StringAlignment.Center, Color.Empty, Color.Empty, 0);

              Comment


                #8
                Hello tonynt,

                Thanks for your reply.

                On both draw text statements you are using the same tag name of DrawText(CurrentBar.ToString(),
                If both are executed only the last one would show.

                You can add another letter like this:

                DrawText("A"+CurrentBar.ToString(), .....
                DrawText("B"+ CurrentBar.ToString(),....

                To create a unique tag name.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks for the hint.


                  I have one question more please. I cant find in the help guide how to draw as text only the time without date . With str+=Time[0].ToString() + ": "; I have also date.


                  Thank you!
                  Tony

                  Comment


                    #10
                    Hello tonynt,

                    Thanks for your reply.

                    You would not find that info in the helpguide as it is a C# type question. You can find out about Time properties here: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx In that link, one of the properties is TimeOfDay

                    A bar time is a date/time structure so if you Print (Time[0]); it will print the bars date and time. If you add the property of TimeOfDay this will return on the time, Print (Time[0].TimeOfDay);

                    To use in your code then:

                    With str+=Time[0].TimeOfDay.ToString() + ": ";
                    Paul H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Perr0Grande, Today, 08:16 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post Perr0Grande  
                    Started by elderan, Today, 08:03 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post elderan
                    by elderan
                     
                    Started by algospoke, Today, 06:40 PM
                    0 responses
                    10 views
                    0 likes
                    Last Post algospoke  
                    Started by maybeimnotrader, Today, 05:46 PM
                    0 responses
                    9 views
                    0 likes
                    Last Post maybeimnotrader  
                    Started by quantismo, Today, 05:13 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post quantismo  
                    Working...
                    X