Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Fixed Text Drawing Box (no SharpDX) - Not Reliable?

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

    Fixed Text Drawing Box (no SharpDX) - Not Reliable?

    Hi,

    I am trying to make this to work without relying on SharpDX libraries for clean and simple notes to display on the chart panel. It seems that I can't make it to display the text messages correctly.

    Source Code


    Code:
    public class FixedText : Indicator
    {
    private SimpleFont fontStyle;
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"FixedText";
    Name = "FixedText";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = false;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = false;
    DrawVerticalGridLines = false;
    PaintPriceMarkers = false;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    TextLine1 = @"";
    TextLine2 = @"";
    TextLine3 = @"";
    TextLine4 = @"";
    TextLine5 = @"";
    DrawTextPosition = TextPosition.Center;//TextPosition.BottomLeft;
    FontStyle = new Gui.Tools.SimpleFont("Consolas", 18);
    FontColor = Brushes.Blue;
    BackgroundColor = Brushes.White;
    BackgroundColorOpacity = 100;
    }
    else if (State == State.Configure)
    {
    Draw.TextFixed(this, "FixedTextIndicator1", TextLine1 + "\n\n\n\n", DrawTextPosition, FontColor, fontStyle, BackgroundColor, BackgroundColor, BackgroundColorOpacity);
    Draw.TextFixed(this, "FixedTextIndicator2", TextLine2 + "\n\n\n", DrawTextPosition, FontColor, fontStyle, BackgroundColor, BackgroundColor, BackgroundColorOpacity);
    Draw.TextFixed(this, "FixedTextIndicator3", TextLine3 + "\n\n", DrawTextPosition, FontColor, fontStyle, BackgroundColor, BackgroundColor, BackgroundColorOpacity);
    Draw.TextFixed(this, "FixedTextIndicator4", TextLine4 + "\n", DrawTextPosition, FontColor, fontStyle, BackgroundColor, BackgroundColor, BackgroundColorOpacity);
    Draw.TextFixed(this, "FixedTextIndicator5", TextLine5, DrawTextPosition, FontColor, fontStyle, BackgroundColor, BackgroundColor, BackgroundColorOpacity);
    ForceRefresh();
    }
    }
    
    protected override void OnBarUpdate()
    {
    }
    
    #region Properties
    [NinjaScriptProperty]
    [Display(Name="TextLine1", Order=1, GroupName="Parameters")]
    public string TextLine1
    { get; set; }
    
    [NinjaScriptProperty]
    [Display(Name="TextLine2", Order=2, GroupName="Parameters")]
    public string TextLine2
    { get; set; }
    
    [NinjaScriptProperty]
    [Display(Name="TextLine3", Order=3, GroupName="Parameters")]
    public string TextLine3
    { get; set; }
    
    [NinjaScriptProperty]
    [Display(Name="TextLine4", Order=4, GroupName="Parameters")]
    public string TextLine4
    { get; set; }
    
    [NinjaScriptProperty]
    [Display(Name="TextLine5", Order=5, GroupName="Parameters")]
    public string TextLine5
    { get; set; }
    
    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name="DrawTextPosition", Order=10, GroupName="Parameters")]
    public TextPosition DrawTextPosition
    { get; set; }
    
    [NinjaScriptProperty]
    [Display(Name="FontStyle", Order=15, GroupName="Parameters")]
    public SimpleFont FontStyle
    {
    get { return fontStyle; }
    set { fontStyle = value; }
    }
    
    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name="FontColor", Order=20, GroupName="Parameters")]
    public Brush FontColor
    { get; set; }
    
    [Browsable(false)]
    public string FontColorSerializable
    {
    get { return Serialize.BrushToString(FontColor); }
    set { FontColor = Serialize.StringToBrush(value); }
    }
    
    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name="BackgroundColor", Order=21, GroupName="Parameters")]
    public Brush BackgroundColor
    { get; set; }
    
    [Browsable(false)]
    public string BackgroundColorSerializable
    {
    get { return Serialize.BrushToString(BackgroundColor); }
    set { BackgroundColor = Serialize.StringToBrush(value); }
    }
    
    [NinjaScriptProperty]
    [Range(0, 100)]
    [Display(Name="BackgroundColorOpacity", Order=22, GroupName="Parameters")]
    public int BackgroundColorOpacity
    { get; set; }
    
    #endregion
    
    }
    }
    Note: This indicator is from NinjaTraderSystem.




    #2
    Hello nothingbutprofits,

    Where you mention:
    "It seems that I can't make it to display the text messages correctly."
    What is incorrect?
    Is the text not showing at all?

    Possibly unrelated, it looks like you have 5 text objects all in the same TextPosition which would cause these to be layered on top of each other.
    If these are all going to the same location, I would recommend having one drawing object with all of the messages added to the text separated by new lines "\r\n".

    When you state 'This indicator is from NinjaTraderSystem', are you referring to iSystems?


    If not, what you are referring to with NinjaTraderSystem?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello nothingbutprofits,

      Possibly unrelated, it looks like you have 5 text objects all in the same TextPosition which would cause these to be layered on top of each other.
      If these are all going to the same location, I would recommend having one drawing object with all of the messages added to the text separated by new lines "\r\n".
      Your recommendation is very good. With the modifications, I am able to make it work beautifully.

      Here's the latest code revision I made to this FixedText State.Configure routine that works well.

      Code:
      private SimpleFont fontStyle;
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = @"FixedText";
      Name = "FixedText";
      Calculate = Calculate.OnBarClose;
      IsOverlay = true;
      DisplayInDataBox = false;
      DrawOnPricePanel = true;
      DrawHorizontalGridLines = false;
      DrawVerticalGridLines = false;
      PaintPriceMarkers = false;
      ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
      //Disable this property if your indicator requires custom values that cumulate with each new market data event.
      //See Help Guide for additional information.
      IsSuspendedWhileInactive = true;
      TextLine1 = @"";
      TextLine2 = @"";
      TextLine3 = @"";
      TextLine4 = @"";
      TextLine5 = @"";
      DrawTextPosition = TextPosition.BottomLeft;
      FontStyle = new Gui.Tools.SimpleFont("Consolas", 13);
      FontColor = Brushes.Blue;
      BackgroundColor = Brushes.White;
      BackgroundColorOpacity = 100;
      }
      else if (State == State.Configure)
      {
      Draw.TextFixed(this, "FixedTextIndicator1",
      TextLine1 + "\r\n" +
      TextLine2 + "\r\n" +
      TextLine3 + "\r\n" +
      TextLine4 + "\r\n" +
      TextLine5 ,
      DrawTextPosition, FontColor, fontStyle, BackgroundColor, BackgroundColor, BackgroundColorOpacity);
      
      //The above Draw.TextFixed routine is modified - per recommended by NT support:
      //https://ninjatrader.com/support/forum/forum/ninjatrader-8/indicator-development/1173370-fixed-text-drawing-box-no-sharpdx-not-reliable#post1173396
      
      /* Commented out due to same TextPosition which would cause these to be layered on top of each other per NT Support
      Draw.TextFixed(this, "FixedTextIndicator2", TextLine2 + "\n\n\n",
      DrawTextPosition, FontColor, fontStyle, BackgroundColor, BackgroundColor, BackgroundColorOpacity);
      Draw.TextFixed(this, "FixedTextIndicator3", TextLine3 + "\n\n",
      DrawTextPosition, FontColor, fontStyle, BackgroundColor, BackgroundColor, BackgroundColorOpacity);
      Draw.TextFixed(this, "FixedTextIndicator4", TextLine4 + "\n",
      DrawTextPosition, FontColor, fontStyle, BackgroundColor, BackgroundColor, BackgroundColorOpacity);
      Draw.TextFixed(this, "FixedTextIndicator5", TextLine5,
      DrawTextPosition, FontColor, fontStyle, BackgroundColor, BackgroundColor, BackgroundColorOpacity);
      */
      
      ForceRefresh(); //Added to keep the display updated on every change.
      
      }
      }
      Originally posted by NinjaTrader_ChelseaB View Post
      If not, what you are referring to with NinjaTraderSystem?
      Here is the link to original source code:
      This indicator draws your static text which you set in the indicator parameters. It is helpful when you want to remind yourself of your steps, strategy, etc. See attached screenshot for settings and examples. No license, free to use. Enjoy.


      Thanks!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      579 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      554 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X