Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Chart Indicator Text Display Issue

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

    Chart Indicator Text Display Issue

    The indicator I created below uses the Draw.TextFixed command for both logic's (SL_TREND and SL_CYCLE_K) to display the proper text on the top left of the chart. Problem is on the chart they display on top of each other instead of left to right in a line, equally spaced. I know that the command line should probably be Draw.Text command with Y offsets but every time I try to code it with a draw.Text command, I get errors.


    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class TPTEST : Indicator
    {
    private Stochastics stochasticsK;
    private SMA sma;
    private Brush upBrush;
    private Brush downBrush;
    private Brush neutralBrush;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"TPTEST";
    Name = "TPTEST";
    Calculate = Calculate.OnEachTick;
    IsOverlay = true;

    }
    else if (State == State.Configure)
    {
    stochasticsK = Stochastics(14, 5, 2);
    sma = SMA(50);

    }
    else if (State == State.DataLoaded)
    {
    upBrush = Brushes.Green;
    downBrush = Brushes.Red;
    neutralBrush = Brushes.Purple;
    }
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBar < 1)
    return;

    double stochasticK = stochasticsK.K[0];
    double prevStochasticK = stochasticsK.K[1];
    double smaValue = sma[0];
    double prevSmaValue = sma[1];



    // SL_CYCLE_K Logic
    if (stochasticK > prevStochasticK)
    {
    Draw.TextFixed(this, "stochDirectionK", "%K UP", TextPosition.TopLeft, upBrush, new SimpleFont("Arial", 15), Brushes.Transparent, Brushes.Transparent, 100);
    }
    else if (stochasticK < prevStochasticK)
    {
    Draw.TextFixed(this, "stochDirectionK", "%K DOWN", TextPosition.TopLeft, downBrush, new SimpleFont("Arial", 15), Brushes.Transparent, Brushes.Transparent, 100);
    }

    // SL_TREND Logic
    if (smaValue > prevSmaValue)
    {
    Draw.TextFixed(this, "smaDirection", "TREND UP", TextPosition.TopLeft, upBrush, new SimpleFont("Arial", 15), Brushes.Transparent, Brushes.Transparent, 100);
    }
    else if (smaValue < prevSmaValue)
    {
    Draw.TextFixed(this, "smaDirection", "TREND DOWN", TextPosition.TopLeft, downBrush, new SimpleFont("Arial", 15), Brushes.Transparent, Brushes.Transparent, 100);

    }
    }
    }
    }




    #2
    Hello Skatester,

    Thank you for your post.

    This would be expected. Draw.TextFixed() draws text in one of 5 available pre-defined fixed locations on panel 1 (price panel) of a chart. You have specified all of these Draw.TextFixed() calls to be drawn in the Top Left corner, so they will overlap on top of each other.

    This method does not adjust or provide a parameter to adjust where the text will be placed, this object can only be placed in one of the five pre-defined fixed locations.

    If you would like more control over where the text is displayed, you can use SharpDX to custom render text on the chart:



    Please let us know if you have any further questions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    556 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 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
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X