NexusFi: Find Your Edge


Home Menu

 





Drawing In Margin


Discussion in NinjaTrader

Updated
    1. trending_up 5,269 views
    2. thumb_up 5 thanks given
    3. group 1 followers
    1. forum 2 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 478 since Jun 2009
Thanks Given: 1,419
Thanks Received: 404

Hello,

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.
Kirk


Attached Thumbnails
Click image for larger version

Name:	test.bmp
Views:	326
Size:	90.5 KB
ID:	576  
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
EA
Platforms and Indicators
Datafeed for Atas
Platforms and Indicators
Trump Media to sell instant access to market-moving soci …
Traders Hideout
My Rant with AMP Futures
Trading Reviews and Vendors
No book, only a stair: journaling fills where price move …
Cryptocurrency
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Mes vs MNQ
6 thanks
NexusFi site changelog and issues/problem reporting
5 thanks
BERN ALGOS algo trading journal
3 thanks
Johnnys Journal
2 thanks
TopStep Trader disappointment
2 thanks
  #2 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,590

graphics.DrawString()

Look at the MML code as example if needed, around line 700 ish.
https://nexusfi.com/free_downloads/ninjatrader/indicators/39-download.html

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
 
sefstrat's Avatar
 sefstrat 
Austin, TX
 
Experience: Advanced
Platform: NT/Matlab
Broker: Interactive Brokers
Trading: FX majors
Posts: 285 since Jun 2009
Thanks Given: 20
Thanks Received: 768


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 =)

 
Code
    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!";
                    }
                    else
                    {
                        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,
                                        stringFormat);
                    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

 
Code
        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:


Reply With Quote




Last Updated on July 6, 2009


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts