Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple Problem with DrawTextFixed

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

    Simple Problem with DrawTextFixed

    Hello.

    I do not seem to get the
    DrawTextFixed
    and
    DrawText
    Methods right.

    I have the code:
    Code:
     protected override void OnBarUpdate()
            {
    DrawTextFixed("tag2", "example", TextPosition.TopRight);
    			DrawText("tag1", "hello", 0, 0 , Color.Red);
    }
    Nothing is being displayed on bar-update. Why could this be?

    regards, Stefan

    #2
    Hello Caliph,

    DrawText() is missing a suitable Y value to draw the text at.
    DrawText(string tag, string text, int barsAgo, double y, Color color)

    You could draw at offsets from high:
    DrawText("tag1", "hello", 0, High[0] + TickSize, Color.Red);

    I tried using your DrawTextFixed() and it worked OK.
    Last edited by NinjaTrader_RyanM1; 11-02-2010, 08:33 AM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the quick answer.


      I chose a suitable y variable like u suggested (copy and pasted your example)

      Still no drawing.

      And I read the description of "DrawOnPricePanel". I have not had included it in my code until then and the default should have been "true" according to the manual.

      Nevertheless I added
      DrawOnPricePanel = true;
      to
      Code:
      initialize()
      I now receive the compilation errors "CS 1502" and "CS0103".
      I am a bit puzzled.
      Last edited by caliph; 11-02-2010, 03:20 AM. Reason: corrected typo in true/false

      Comment


        #4
        Stefan, could you please post the code you have now so we could take a look at the compile errors?

        Comment


          #5
          here the code

          Code:
          public class MyCustomStrategy : Strategy
              {
                  #region Variables
                  // Wizard generated variables
                  private int myInput0 = 1; // Default setting for MyInput0
                  // User defined variables (add any user defined variables below)
          		private double forecast =  1.0080;
                  #endregion
          
                  /// <summary>
                  /// This method is used to configure the strategy and is called once before any strategy method is called.
                  /// </summary>
                  protected override void Initialize()
                  {
                      CalculateOnBarClose = true;
          			DrawOnPricePanel = true;
          			Add(ConstantLines(forecast,0,0, 0));
          			Add(Bollinger(2, 14));
                  }
          
                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
          			DrawTextFixed("tag2", "FixedTest", TextPosition.TopRight);
          			DrawText("tag1", "VTest", 0, High[0] + TickSize, Color.Red);
                  }
          
                  #region Properties
                  [Description("")]
                  [GridCategory("Parameters")]
                  public int MyInput0
                  {
                      get { return myInput0; }
                      set { myInput0 = Math.Max(1, value); }
                  }
                  #endregion
              }

          Comment


            #6
            Hello Caliph,

            DrawOnPricePanel is only part of indicators so you will need to remove it from your strategy.

            Syntax looks good for drawing. Please check that the strategy is enabled and look at the log tab for any error messages.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Copy and pasted the code into a new strategy code-template and it works fine now.
              Thx.

              Comment


                #8
                Do we have syntax to assign an X value other than Bars?

                Seems we can assign a Y value in pixels, but we can only address the X access with bars. Is that correct?

                Comment


                  #9
                  Hello Crassius,

                  For the x position, you can use Date/Time in addition to bars.

                  DrawText(string tag, bool autoScale, string text, DateTime time, double y, int yPixelOffset, Color textColor, Font font, StringAlignment alignment, Color outlineColor, Color areaColor, int areaOpacity)
                  Ryan M.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  633 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  364 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  105 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  567 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  568 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X