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 doc syntax has "int offset" but causes error

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

    drawtext doc syntax has "int offset" but causes error

    Hello,

    I've been using 6.5 DrawText for a while and just recently noticed that the documentation both local and online is as follows:

    DrawText(string tag, string text, int barsAgo, double y, Color color)

    DrawText(string tag, bool autoScale, string text, int barsAgo, double y, int yPixelOffset, Color textColor, Font font, StringAlignment alignment, Color outlineColor, Color backColor, int opacity)

    Notice in the complex invocaton syntax the presence of int yPixelOffset

    I have written numerous indicators using the complex DrawText invocation minus the yPixelOffset value. To this day they work just fine.

    But if I try to use this argument, the compiler errors and complains about too many arguments.

    So is this a documentation error or am I mucking something up?

    -T


    #2
    Hello Tulanch,

    I was able to compile DrawText() with an overload that offers pixel offset. Most likely you are specifying too many or too few parameters. Example below , with pixel offset highlighted green.

    Code:
     
     
    DrawText("", true, "", 0 , 0, [COLOR=green][B]0,[/B][/COLOR] Color.Red, new Font("Arial", 12), StringAlignment.Center, Color.AliceBlue, Color.AliceBlue, 10);
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      wow don't know what I was doing wrong... but copied your code and things are working... weird all of my complex drawtext invocations are not quite correct yet they work...oh well don't fix whats working I guess...

      FYI here's what I've been working on ... ability to put text on left side of chart in a pusdo fixed location even if chart scale changes....works great... heres the code that does the work....


      // how to get most left bar id
      int lastBar = Math.Min(ChartControl.LastBarPainted, Bars.Count - 1);
      int barsPainted = ChartControl.BarsPainted;
      int MostLeftBar = (lastBar - barsPainted) + 1;
      int LeftBarOffset = lastBar - MostLeftBar-1;

      if( CurrentBar <LeftBarOffset+1 )
      return;

      DrawHorizontalLine("HL", true, High[0], Color.Purple, DashStyle.Dash, 2);
      DrawText("HLTXT", true, "High", LeftBarOffset , High[0]+0.1, 0, Color.Black, new Font("Arial", 12), StringAlignment.Center, Color.Transparent, Color.Transparent, 0);

      This will draw a lable on the line that will remain on the 1st bar drawn on the left side of chart.... going to implement this into my pivot point line indicator and others...

      thanks again...

      -T
      Last edited by tulanch; 11-02-2010, 10:57 AM.

      Comment


        #4
        Sure thing. Thanks for sharing the code you're working on. It looks interesting.
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by junkone, Today, 11:37 AM
        0 responses
        0 views
        0 likes
        Last Post junkone
        by junkone
         
        Started by quantismo, 04-17-2024, 05:13 PM
        5 responses
        32 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by proptrade13, Today, 11:06 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by love2code2trade, 04-17-2024, 01:45 PM
        4 responses
        34 views
        0 likes
        Last Post love2code2trade  
        Started by cls71, Today, 04:45 AM
        2 responses
        10 views
        0 likes
        Last Post eDanny
        by eDanny
         
        Working...
        X