Drawing In Margin - NinjaTrader Programming | futures.io
futures.io futures trading

Go Back   futures.io

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

Drawing In Margin
Started:July 6th, 2009 (11:21 AM) by zeller4 Views / Replies:2,678 / 2
Last Reply:July 6th, 2009 (11:24 PM) Attachments:1

Welcome to futures.io.

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

Drawing In Margin

Old July 6th, 2009, 11:21 AM   #1 (permalink)
Elite Member
Futures Experience: Intermediate
Platform: NT7
Favorite Futures: CL, NQ, NG
Posts: 449 since Jun 2009
Thanks: 1,342 given, 376 received

Drawing In Margin


The attached partial screenshot of my chart shows the right hand margin with a default width set to 75.

The word "Overbought" in my stochastic plot is drawn there using "DrawTextFixed" - that I know about for this example.

The ECO2New2 has values on the y-axis. I'd like to see a plot with a value in the margin...

I'm trying to find a draw tool that will allow me to draw in the right hand margin with price levels / indicator levels / labels, etc. that will be aligned with a specific y value.

Any help or direction you can give would be much appreciated.

Attached Thumbnails
Drawing In Margin-test.bmp  
Reply With Quote

Old July 6th, 2009, 11:43 AM   #2 (permalink)
Site Administrator
Manta, Ecuador
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
Big Mike's Avatar
Posts: 45,447 since Jun 2009
Thanks: 28,847 given, 79,600 received


Look at the MML code as example if needed, around line 700 ish.


Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following user says Thank You to Big Mike for this post:

Old July 6th, 2009, 11:24 PM   #3 (permalink)
Elite Member
Austin, TX
Futures Experience: Advanced
Platform: NT/Matlab
Broker/Data: Interactive Brokers
Favorite Futures: FX majors
sefstrat's Avatar
Posts: 285 since Jun 2009
Thanks: 20 given, 735 received

Here is a static method I use for drawing text.. it chooses the color of text label based on the color of the plot passed the color of the value based on whether it is above/below zero.

You will need to modify it slightly to choose the y value in the way you want, but you may find it useful =)

    public static class Util
        private static StringFormat stringFormat = new StringFormat();
        private static SolidBrush textBrush = new SolidBrush(Color.Black);
        private static System.Drawing.Font textFont = new Font("Arial", 8);
        static Util()
            stringFormat.Alignment = StringAlignment.Far;

      public static void drawValueString(NinjaTrader.Indicator.Indicator ind, Graphics graphics, Rectangle bounds, string plotName, int plotNum, DataSeries series, int boxNum)

            int index = -1;
            int bars = ind.CalculateOnBarClose ? (ind.ChartControl.BarsPainted-2) : (ind.ChartControl.BarsPainted-1);

            if (ind.Bars != null)
                index = ((ind.ChartControl.LastBarPainted-ind.ChartControl.BarsPainted)-1)+bars;
                if (ind.ChartControl.ShowBarsRequired || ((index-ind.Displacement) >= ind.BarsRequired))
                    double val = series.Get(index);
                    string s = plotName+": ";
                    StringBuilder str = new StringBuilder();
                    str.Append((Math.Round(val, 3)).ToString());
                    Color valColor = (val > 0) ? Color.YellowGreen : Color.OrangeRed;
                    textBrush.Color = valColor;
                    Brush b = textBrush;
                    if (plotNum == -1)
                        //do nothing
                    else if (ind.Plots[plotNum] == null)
                        s = "Err: Plot Does not exsit!";
                        b = (ind.Plots[plotNum].Pen.Color == Color.Transparent)
                                ? textBrush
                                : ind.Plots[plotNum].Pen.Brush;
                    graphics.DrawString(s, textFont, b, bounds.X+bounds.Width-37, bounds.Y+bounds.Height-boxNum*20,
                    graphics.DrawString(str.ToString(), textFont, textBrush, bounds.X+bounds.Width-3,
                                        bounds.Y+bounds.Height-boxNum*20, stringFormat);

Here is an example of how its called from indicator

        public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
            base.Plot(graphics, bounds, min, max);
            if (ColorMode > 0)
                drawColorLine(graphics, bounds, min, max, this.Value, this.PenUp, this.PenDown, this.penTurn, false);
            if (_drawValues)
                Util.drawValueString(this, graphics, bounds, "Value", 0, Value, 1);
                Util.drawValueString(this, graphics, bounds, "delta", -1, dValue, 2);
                Util.drawValueString(this, graphics, bounds, "alpha", -1, alpha, 3);
                Util.drawValueString(this, graphics, bounds, "beta", -1, beta, 4);
                Util.drawValueString(this, graphics, bounds, "Kv", -1, Kv, 5);
                Util.drawValueString(this, graphics, bounds, "dThreshold", -1, dThreshold, 6);
                Util.drawValueString(this, graphics, bounds, "dAvg", -1, _dAvg[0], 7);
how it looks:
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote
The following 4 users say Thank You to sefstrat for this post:


futures.io > Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming > Drawing In Margin

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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
Margin requirement changes Big Mike Brokers and Data Feeds 20 September 24th, 2011 01:48 AM
Drawing trailing stop on chart protrader007 NinjaTrader Programming 6 July 22nd, 2011 12:47 AM
symbols and margin johni MultiCharts 1 July 9th, 2011 03:45 PM
Price bars drawing behind indicators rsi77 NinjaTrader Programming 3 July 14th, 2010 01:53 AM
drawing Fib lines emini_Holy_Grail Traders Hideout 4 January 15th, 2010 05:43 PM

All times are GMT -4. The time now is 07:33 PM.

Copyright © 2016 by futures.io. 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-26 in 0.07 seconds with 20 queries on phoenix via your IP