Explanation somewhere on creating custom plots with colors etc...... - futures io
futures io futures trading



Explanation somewhere on creating custom plots with colors etc......


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one forrestang with 7 posts (0 thanks)
    2. looks_two devdas with 3 posts (6 thanks)
    3. looks_3 cory with 2 posts (2 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 5,102 views
    2. thumb_up 9 thanks given
    3. group 2 followers
    1. forum 13 posts
    2. attach_file 6 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
 

Explanation somewhere on creating custom plots with colors etc......

(login for full post details)
  #1 (permalink)
Legendary Urban Samurai
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,194 since Jun 2010
Thanks: 290 given, 876 received

You guys know that function sometimes used near the bottom of scripts, under properties for creating graphics on a chart..... Usually starts like this:
 
Code
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
Ninja says they don't support this, so they probably don't have a write up on it anywhere. I guess its about time I figure that out.

But do you guys know of an explanation somewhere on how to create that block, and how it works?

Started this thread Reply With Quote

Journal Challenge February 2021 results:
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(173 thanks from 31 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(120 thanks from 33 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(35 thanks from 17 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #3 (permalink)
the coin hunter
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
 
cory's Avatar
 
Posts: 6,029 since Jun 2009
Thanks: 845 given, 7,893 received


some primers

Reply With Quote
The following 2 users say Thank You to cory for this post:
 
(login for full post details)
  #4 (permalink)
Como Italy
 
Experience: Intermediate
Platform: Ninjatrader, customized
Trading: ES
 
Posts: 526 since Feb 2010
Thanks: 471 given, 640 received

NT doesn't support it, but somewhere on the site they have an example of custom plotting posted. (I don't have it any more, but it's probably called something like "SampleCustomPlotMethod"). Otherwise, your best bet is just to look at some of the indicators others have uploaded.

Reply With Quote
The following user says Thank You to futuretrader for this post:
 
(login for full post details)
  #5 (permalink)
Al,India
 
Experience: Advanced
Platform: NinjaTrader
Broker: RKG
Trading: NiftyFuture
 
devdas's Avatar
 
Posts: 1,562 since Feb 2010
Thanks: 1,504 given, 1,701 received

It provides a context to draw custom drawings through a Graphics object that "tied to" or "points to" the panel on which indicator will be applied. However its uses are certainely wide...but you can start doing simple experiments with drawing some lines and other shapes with function avalibale with graphics object. Just type
"graphics." and intellisence will show available methods for use.

similarly bounds will occupy the rectangular space of panel in which indicator will be applied...and hence mostly represent dimensions in screen pixels....just type "bounds." and get availble methods.

Lastly min and max represnt the minimum and maximum values of vertical scale of indicator panel in which indicator is applied. If none of plot containing dataseries exisit in indicator then these min and max will be nearly 0 and 1.

For your example i hv created a small script, it only draws a rectangle and then draws a string in that
showing scales minimum and maximum values. Just put indicator one by one in price panel and seperate panel and see how it behaves on scrolling chart/changing scale etc.

Harvest The Moon
Nest The Market
Attached Thumbnails
Click image for larger version

Name:	MyExp.png
Views:	157
Size:	57.1 KB
ID:	48304  
Attached Files
Register to download File Type: cs MyExp3.cs (5.4 KB, 48 views)
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
The following 3 users say Thank You to devdas for this post:
 
(login for full post details)
  #6 (permalink)
Legendary Urban Samurai
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,194 since Jun 2010
Thanks: 290 given, 876 received


devdas View Post
It provides a context to draw custom drawings through a Graphics object that "tied to" or "points to" the panel on which indicator will be applied. However its uses are certainely wide...but you can start doing simple experiments with drawing some lines and other shapes with function avalibale with graphics object. Just type
"graphics." and intellisence will show available methods for use.

similarly bounds will occupy the rectangular space of panel in which indicator will be applied...and hence mostly represent dimensions in screen pixels....just type "bounds." and get availble methods.

Lastly min and max represnt the minimum and maximum values of vertical scale of indicator panel in which indicator is applied. If none of plot containing dataseries exisit in indicator then these min and max will be nearly 0 and 1.

For your example i hv created a small script, it only draws a rectangle and then draws a string in that
showing scales minimum and maximum values. Just put indicator one by one in price panel and seperate panel and see how it behaves on scrolling chart/changing scale etc.

Looking more at your example today. Really good example.

Although the intellisense you mentioned doesn't seem to work.

Started this thread Reply With Quote
 
(login for full post details)
  #7 (permalink)
the coin hunter
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
 
cory's Avatar
 
Posts: 6,029 since Jun 2009
Thanks: 845 given, 7,893 received

as far as text colors check out indi from TMFT
View Download Details - Big Mike's Trading Forum

Reply With Quote
 
(login for full post details)
  #8 (permalink)
Legendary Urban Samurai
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,194 since Jun 2010
Thanks: 290 given, 876 received

@devdas

In your example, you use:
 
Code
graphics.DrawString("Scale Min: " + smin + "  Scale Max: " + smax,textfont,textbrush,new Point(recleft + 10,rectop + 5));
Now it looks like this prints a string a fixed distance from the left of your rectangle, and a fixed distance from the top of your rectangle.

What if I wanted to be able to plot several variables one next to and under each other, while being able to keep everything in a nice tight box? Is this possible?

Liek in the picture I have attached here?

Attached Images
 
Started this thread Reply With Quote
 
(login for full post details)
  #9 (permalink)
Legendary Urban Samurai
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,194 since Jun 2010
Thanks: 290 given, 876 received


forrestang View Post
@devdas

In your example, you use:
 
Code
graphics.DrawString("Scale Min: " + smin + "  Scale Max: " + smax,textfont,textbrush,new Point(recleft + 10,rectop + 5));
Now it looks like this prints a string a fixed distance from the left of your rectangle, and a fixed distance from the top of your rectangle.

What if I wanted to be able to plot several variables one next to and under each other, while being able to keep everything in a nice tight box? Is this possible?

Liek in the picture I have attached here?

Sorta thinking out loud here. But with that picture in the post I have above....... Basically I am wanting to create a text box that will remain organized if the chart is resized or if the bars are expanded or contracted.

In the script example @devdas posted, I was moving that box and text around as he suggested. And I see that he had it lined up with an offset to the left/top borders.

In that pic above, basically I have a text box, with essentially 3 rows at top with one 3 variables in each row. Followed by 4 more rows, each row with one variable. Maybe what I need to do is align everything into each one of these boxes? Since it seems like the offset is and the way you align things is based on the number of pixels. If I could count the number of pixels of a given string, then I could align everything up properly, solving the scaling problem.


Here is a pic of what I mean.


----EDIT-----------
I see scaling isn't really an issue with this method of drawing. Nice! Let me see what I can come up with.

Attached Thumbnails
Click image for larger version

Name:	9-7-2011 5-59-39 PM.png
Views:	51
Size:	4.1 KB
ID:	48682  
Started this thread Reply With Quote
 
(login for full post details)
  #10 (permalink)
Legendary Urban Samurai
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,194 since Jun 2010
Thanks: 290 given, 876 received


I've made some headway with using:

 
Code
public override void Plot()
Is it possible to pass variables into this function from my main program?

Attached Thumbnails
Click image for larger version

Name:	Prime2011-09-07_195444.jpg
Views:	89
Size:	101.5 KB
ID:	48693  
Started this thread Reply With Quote
 
(login for full post details)
  #11 (permalink)
Legendary Urban Samurai
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,194 since Jun 2010
Thanks: 290 given, 876 received


forrestang View Post
I've made some headway with using:

 
Code
public override void Plot()
Is it possible to pass variables into this function from my main program?

The answer is YES! Although indirectly.

The variables created in main function declared globally are available to that function.

Also, if you have this in a separate study as I do, .... you can first capture into the main body of script any variables from OTHER studies, and then those variables are available to the void plot() function.

Woot!

Started this thread Reply With Quote
 
(login for full post details)
  #12 (permalink)
Al,India
 
Experience: Advanced
Platform: NinjaTrader
Broker: RKG
Trading: NiftyFuture
 
devdas's Avatar
 
Posts: 1,562 since Feb 2010
Thanks: 1,504 given, 1,701 received


forrestang View Post
The answer is YES! Although indirectly.

The variables created in main function declared globally are available to that function.

Also, if you have this in a separate study as I do, .... you can first capture into the main body of script any variables from OTHER studies, and then those variables are available to the void plot() function.

Woot!

glad...ur getting interest.
about aligning text in graphics in different lines...there are string formats and you can get the hieght of text to be displayed to offset next line.

yes can have globals to transport values...but recently i stuck with graphics plot.....could not retain values
outside the Plot scope as opposite to other methods. It was very frustrating excercise to get values derived
inside graphics plot to outside. Hope some more experienced coder help me out.


 
Code
 
public override void Plot(Graphics graphics,Rectangle bounds,double min,double max)
{
 
mymin = min;                    // mymin Global variable.
Print(mymin.ToString());   // works only if remains as long as in Plot. Losses value
}                                      // outside the plot.


Harvest The Moon
Nest The Market
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #13 (permalink)
Legendary Urban Samurai
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,194 since Jun 2010
Thanks: 290 given, 876 received

@devdas

If you wanted to add the textbrush as a user input so that you could change the colors, how do you go about doing that?

Started this thread Reply With Quote
 
(login for full post details)
  #14 (permalink)
Al,India
 
Experience: Advanced
Platform: NinjaTrader
Broker: RKG
Trading: NiftyFuture
 
devdas's Avatar
 
Posts: 1,562 since Feb 2010
Thanks: 1,504 given, 1,701 received


forrestang View Post
@ devdas

If you wanted to add the textbrush as a user input so that you could change the colors, how do you go about doing that?


this is simple and similar to other variables. Look following changes should be made in script.

1) Declare your text brush without initialisation and add another variable for color.

 
Code
 
#region Variables
.........................
private  System.Drawing.Brush   textbrush;    // no initialization of Brush
private  Color   textcolor;                                 // variable for color.
..........................
#endregion
2) Initialize TextBrush where u need and dispose after use.

 
Code
 
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
{
............................
textbrush = new SolidBrush(textcolor);        // initialize here
.......................
.......................
.......................
textbrush.Dispose();                                    // dispose after use.
 }

3) Make provision for this in Properties...so that it could be shown for input.( Important)

 
Code
 
#region Properties
[Description("Select Text Color")]
[Category("Colors")]
[Gui.Design.DisplayName("Text Color")]
public Color Textcolor
{
get { return textcolor; }
set { textcolor = value; }
}
#endregion
and you are done...

Harvest The Moon
Nest The Market
Attached Thumbnails
Click image for larger version

Name:	ColorSelection.png
Views:	84
Size:	33.0 KB
ID:	48902  
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
The following 3 users say Thank You to devdas for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > Explanation somewhere on creating custom plots with colors etc......


Last Updated on September 9, 2011


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Call Option Buying: The New Pain Trade? w/Carley Garner

Elite only
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

New Challenge (TBD)

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@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