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 Mindset, 04-21-2026, 06:46 AM
          0 responses
          44 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          58 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          35 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          95 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          59 views
          0 likes
          Last Post PaulMohn  
          Working...
          X