Plotting text in indicator panel - NinjaTrader Programming | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming

Plotting text in indicator panel
Started:November 18th, 2010 (07:50 PM) by ibiscmllc Views / Replies:4,341 / 2
Last Reply:November 19th, 2010 (07:56 AM) Attachments:0

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

Plotting text in indicator panel

Old November 18th, 2010, 07:50 PM   #1 (permalink)
Elite Member
Parkland, FL, USA
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Kinetick, Amp Futures
Favorite Futures: ES, 6E
ibiscmllc's Avatar
Posts: 17 since Aug 2010
Thanks: 0 given, 6 received

Plotting text in indicator panel

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?
Please register on to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote

Old November 18th, 2010, 07:50 PM   #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.


Old November 19th, 2010, 07:56 AM   #3 (permalink)
Elite Member
Orlando, Florida
Futures Experience: Advanced
Platform: NinjaTrader, TradeStation, MultiCharts, eSignal, MetaTrader
Favorite Futures: ES
Posts: 56 since Aug 2010
Thanks: 3 given, 65 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

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

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming > Plotting text in indicator panel

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Williams Acc Dist indicator not plotting buzzsaw NinjaTrader Programming 6 March 16th, 2016 05:37 AM
Arrows not plotting on price panel kendallw4 NinjaTrader Programming 2 June 28th, 2011 02:44 PM
Put/Call Ration indicator or plotting capability. hector24 NinjaTrader 4 March 12th, 2011 10:56 PM
NT7 - indicator plotting priorities .. or so ;) max-td NinjaTrader 3 February 11th, 2011 03:24 AM
PLotting GOM Indicator eone NinjaTrader 1 October 7th, 2010 07:16 PM

All times are GMT -4. The time now is 04:07 AM.

Copyright © 2016 by 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

Page generated 2016-10-23 in 0.07 seconds with 20 queries on phoenix via your IP