Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help editing an indicator

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

    Help editing an indicator

    I want to change the font used by an indicator which draws fixed text on the chart, the problem is I cannot find a single reference anywhere in the code to the font or the text size. The font it's drawing is too big.

    The code that draws the text is this:

    OnRender()
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    if(!ViewText || State < State.Realtime)
    {
    return;
    }

    if(chartControl == null || chartScale == null || ChartBars == null)
    {
    return;
    }

    base.OnRender(chartControl, chartScale);

    Text = String.Format(
    "Count: {0} Width: {1} Space: {2}",
    ChartBars.ToIndex - ChartBars.FromIndex + 1,
    chartControl.BarWidth.ToString("0.00"),
    chartControl.Properties.BarDistance.ToString("0.00 ")
    );

    Draw.TextFixed(this, "ZoomReset_Text", Text, Positioner);
    }
    endregion


    If I create a simple font and then add more parameters to Draw.TextFixed such as the Brushes.Color I get an error saying:

    brushes do not exist in this context​

    #2
    Hello several,

    Thank you for your post.

    You should be able to use the following syntax to specify a font and font size for Draw.TextFixed():

    Draw.TextFixed(NinjaScriptBase owner, string tag, string text, TextPosition textPosition, Brush textBrush, SimpleFont font, Brush outlineBrush, Brush areaBrush, int areaOpacity)



    Specify a SimpleFont object to use that has defined your font and font size.



    I was able to achieve this in an indicator script from within OnRender. Please see the attached test script.

    Attached Files

    Comment


      #3
      Hello, thanks for the reply. I already tried exactly this before I made the post and it gives the error 'brushes do not exist in this context​'​. It does not seem to like the use of Brushes.Color

      This is the indicator.

      https://ninjatraderecosystem.com/use...%20the%20chart.

      Comment


        #4
        You're missing the using statement in order to use Brushes.

        using System.Windows.Media;

        Comment


          #5
          ah perfect thanks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          72 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          39 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          63 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          63 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          53 views
          0 likes
          Last Post CarlTrading  
          Working...
          X