Plotting text in indicator panel - futures io
futures io

Plotting text in indicator panel

Discussion in NinjaTrader

    1. trending_up 7,590 views
    2. thumb_up 9 thanks given
    3. group 4 followers
    1. forum 2 posts
    2. attach_file 0 attachments

Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

Search this Thread

Plotting text in indicator panel

(login for full post details)
  #1 (permalink)
Parkland, FL, USA
Experience: Advanced
Platform: NinjaTrader
Broker: Kinetick, Amp Futures
Trading: ES, 6E
ibiscmllc's Avatar
Posts: 17 since Aug 2010
Thanks: 0 given, 6 received

I would like to draw a descriptive label for each row of dots in my indicator panel. It is not an issue drawing the text to the right of the plot using DrawText but there is apparently no parameter to draw it to the left of the row (so that the label is always visible even if I scroll the price chart to the left). I was told that this may require an overriding of the Plot method. Any good example out there or some sample code that could help me out?

Started this thread Reply With Quote

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(206 thanks from 24 posts)
looks_twoSalao's Journalby Salao
(53 thanks from 11 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(38 thanks from 18 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(35 thanks from 15 posts)
looks_5Maybe a little bit different journalby Malykubo
(14 thanks from 16 posts)
Best Threads (Most Thanked)
in the last 7 days on futures io
Big Mike in Ecuador
76 thanks
The Crude Dude Oil Trading System
72 thanks
Help improve the FIO community
38 thanks
The New Micro Contract - MICRO BITCOIN coming May 2021
29 thanks
futures io site changelog and issues/problem reporting
27 thanks
(login for full post details)
  #3 (permalink)
Orlando, Florida
Experience: Advanced
Platform: NinjaTrader, TradeStation, MultiCharts, eSignal, MetaTrader
Trading: ES
Posts: 57 since Aug 2010
Thanks: 6 given, 73 received

Here's an example of overriding the plot method. If you want to plot the text on the left, you will probably want to increase the left margin by using:

ChartControl.MarginLeft = 20;

// Copyright (C) 2006, NinjaTrader LLC <>.
// NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.

#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Xml.Serialization;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;

// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
/// <summary>
    /// This is a sample for an indicator which with custom plotting.
    /// </summary>
[Description("This is a sample for an indicator using custom plotting.")]
    public class 
CustomPlotSample Indicator
#region Variables
        // Wizard generated variables
        // User defined variables (add any user defined variables below)
private StringFormat            stringFormat    = new StringFormat();
SolidBrush                textBrush        = new SolidBrush(Color.Black);
System.Drawing.Font        textFont        = new Font("Arial"10);

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
protected override void Initialize()
ChartOnly            true;

/// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
protected override void OnBarUpdate()

#region Miscellaneous
        /// <summary>
        /// Overload this method to handle the termination of an indicator. Use this method to dispose of any resources vs overloading the Dispose() method.
        /// </summary>
protected override void OnTermination()

/// <summary>
        /// Called when the indicator is plotted.
        /// </summary>
        /// <param name="graphics">Graphics context</param>
        /// <param name="bounds">Paintable chart region</param>
        /// <param name="min">Min indicator value plotted</param>
        /// <param name="max">Max indicator value plotted</param>
public override void Plot(Graphics graphicsRectangle boundsdouble mindouble max)
// Default plotting in base class. Uncomment if indicators holds at least one plot.
            // base.Plot(graphics, bounds, min, max);

            // fill the complete paintable region
            // note: although the rectangle is greater and even would start plotting at the left upper corner of the chart, 
            // it's clipped to the paintable region
            // the qualification 'InHitTest' is used to exclude the drawn rectangle from the mouse selection action
SolidBrush tmpBrush = new SolidBrush(Color.LightGray);
            if (!
graphics.FillRectangle(tmpBrush, new Rectangle (0020002000));

// plot a green line from the upper left to the lower right corner
            // all painting needs to go by bounds X/Y offset
Pen tmpPen = new Pen(Color.Green);

// plot a green line from the lower left to the upper right corner and apply 
            // apply AnitAlias to make the line look nicer
            // don't forget to reset after plotting -> smoothing has some performance impact
SmoothingMode oldSmoothingMode graphics.SmoothingMode;        // save current smoothing mode
graphics.SmoothingMode SmoothingMode.AntiAlias;                // apply smoothing mode
graphics.DrawLine(new Pen(Color.Green), bounds.Xbounds.bounds.Heightbounds.bounds.Widthbounds.Y);
graphics.SmoothingMode oldSmoothingMode;                        // restore smoothing mode

// plot text in the upper left corner at position 10/10
stringFormat.Alignment    StringAlignment.Near;                    // text is docked to the left
textBrush.Color            Color.Blue;                            // set text color
graphics.DrawString("Upper left corner"textFonttextBrushbounds.10bounds.10stringFormat);
// paint text at the lower left corner right to the bottom on background with an outline
            // 1) plot background rectangle
tmpBrush = new SolidBrush(Color.Red);
graphics.FillRectangle(tmpBrushbounds.10bounds.bounds.Height 2014019);
// 2) plot outline
tmpPen = new Pen(Color.Black);
graphics.DrawRectangle(tmpPenbounds.10bounds.bounds.Height 2014019);
// 3) plot text
graphics.DrawString("Lower left corner"textFonttextBrushbounds.10bounds.bounds.Height 20stringFormat);


        #region Properties

Follow me on Twitter Reply With Quote
The following 9 users say Thank You to MooreTech for this post:

futures io Trading Community Platforms and Indicators NinjaTrader > Plotting text in indicator panel

Last Updated on November 19, 2010

Upcoming Webinars and Events

NinjaTrader Indicator Challenge!


Journal Challenge w/$1,800 in prizes!


Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts