.NET advice for persistent graphics.DrawString and graphics.DrawRectangle - NinjaTrader Programming | futures io social day trading
futures io futures trading


.NET advice for persistent graphics.DrawString and graphics.DrawRectangle
Updated: Views / Replies:899 / 9
Created: by vantojo Attachments:1

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • 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.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

.NET advice for persistent graphics.DrawString and graphics.DrawRectangle

  #1 (permalink)
Elite Member
Neuquen, Argentina
 
Futures Experience: Intermediate
Platform: Ninja
Favorite Futures: CL, TF, 6S, NG, sometimes GC
 
Posts: 195 since Jul 2012
Thanks: 25 given, 39 received

.NET advice for persistent graphics.DrawString and graphics.DrawRectangle

Hello NET gurus...

I'm working on a new version of SlopeBox that would have multiple MA/slopeboxes in one indicator. It is working well, but only the last drawn box is staying on the screen.....the public SlopeBox (forgot where I found it, probably futures.io (formerly BMT)) uses .NET methods to draw, not NinjaTrader methods...

graphics.DrawRectangle
graphics.DrawString

For example, the indicator has three different MA, and three different SlopeBoxes. The boxes are drawn in an override to the Plot Method.

Here is the draw code in the Plot override method....for each Plot this is called. Only the last box remains on the screen. The other two appear to be erased as soon as the next one is written.

//the bounds offset is multiplied by the box number to properly position new instances of the SlopeBox
graphics.DrawRectangle
(new Pen(Plots[0].Pen.Color, 2),
bounds.X + bounds.Width - 60,
bounds.Y + bounds.Height - Boxnumber * 40,
46,
22);

StringBuilder strDegrees = new StringBuilder();
strDegrees.Append((degrees).ToString());
strDegrees.Append(Convert.ToChar(0176));
textBrush.Color=degreesColor;

graphics.DrawString
(strDegrees.ToString(),
textFont,
textBrush,
bounds.X + bounds.Width - 60,
bounds.Y + bounds.Height - Boxnumber * 40,
stringFormat);

Any ideas?

When I get it working I will post it.

Thanks.

Reply With Quote
 
  #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.

 
  #3 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received



vantojo View Post
Hello NET gurus...

I'm working on a new version of SlopeBox that would have multiple MA/slopeboxes in one indicator. It is working well, but only the last drawn box is staying on the screen.....the public SlopeBox (forgot where I found it, probably futures.io (formerly BMT)) uses .NET methods to draw, not NinjaTrader methods...

graphics.DrawRectangle
graphics.DrawString

For example, the indicator has three different MA, and three different SlopeBoxes. The boxes are drawn in an override to the Plot Method.

Here is the draw code in the Plot override method....for each Plot this is called. Only the last box remains on the screen. The other two appear to be erased as soon as the next one is written.

//the bounds offset is multiplied by the box number to properly position new instances of the SlopeBox
graphics.DrawRectangle
(new Pen(Plots[0].Pen.Color, 2),
bounds.X + bounds.Width - 60,
bounds.Y + bounds.Height - Boxnumber * 40,
46,
22);

StringBuilder strDegrees = new StringBuilder();
strDegrees.Append((degrees).ToString());
strDegrees.Append(Convert.ToChar(0176));
textBrush.Color=degreesColor;

graphics.DrawString
(strDegrees.ToString(),
textFont,
textBrush,
bounds.X + bounds.Width - 60,
bounds.Y + bounds.Height - Boxnumber * 40,
stringFormat);

Any ideas?

When I get it working I will post it.

Thanks.


I guess I would be verifying that the boxnumber is working as that is the key to offsetting the boxes from each other. If they are the same number of course will overlay on each other.
Hopefully others can give you more to go on.

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
 
  #4 (permalink)
Elite Member
Neuquen, Argentina
 
Futures Experience: Intermediate
Platform: Ninja
Favorite Futures: CL, TF, 6S, NG, sometimes GC
 
Posts: 195 since Jul 2012
Thanks: 25 given, 39 received

boxnumber working

yes, the boxnumber is working OK...because if I comment out plot1 and plot2, plot0 will draw its slopebox

if I comment out Plot2 only, then the Plot0 slopebox does not show, but the plot1 slopebox does show. Seems that only the last slopebox written remains.

Ninjatrader draw functions let the coder say whether the prior draw object is erased when a new one is written...but this does not seem to be in the .net methods mentioned

would post the indicator code here but I don't know how to export it...the public enums are in the mother indicator and it won't compile stand alone on the export

Reply With Quote
 
  #5 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received


vantojo View Post
yes, the boxnumber is working OK...because if I comment out plot1 and plot2, plot0 will draw its slopebox

if I comment out Plot2 only, then the Plot0 slopebox does not show, but the plot1 slopebox does show. Seems that only the last slopebox written remains.

Ninjatrader draw functions let the coder say whether the prior draw object is erased when a new one is written...but this does not seem to be in the .net methods mentioned

would post the indicator code here but I don't know how to export it...the public enums are in the mother indicator and it won't compile stand alone on the export

You can just attach the CS file itself.

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
 
  #6 (permalink)
Elite Member
Neuquen, Argentina
 
Futures Experience: Intermediate
Platform: Ninja
Favorite Futures: CL, TF, 6S, NG, sometimes GC
 
Posts: 195 since Jul 2012
Thanks: 25 given, 39 received

CS code attached

If you comment out Plot2 and Plot1 you will see that the box for Plot0 is on the chart.

When Plot0 and Plot1 are enabled (i.e. not commented), then the box for Plot 0 is not there

When Plot0, Plot1, and Plot2 are enabled, only the box for Plot 2 is on the chart

would like all three boxes to be on the chart

(also would like to know how to get rid of parameters that are no longer needed, but were in the mother code...)

Thank You!!

Attached Files
Register to download File Type: cs AASlopeBoxWORK.cs (14.6 KB, 21 views)
Reply With Quote
 
  #7 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received


vantojo View Post
If you comment out Plot2 and Plot1 you will see that the box for Plot0 is on the chart.

When Plot0 and Plot1 are enabled (i.e. not commented), then the box for Plot 0 is not there

When Plot0, Plot1, and Plot2 are enabled, only the box for Plot 2 is on the chart

would like all three boxes to be on the chart

(also would like to know how to get rid of parameters that are no longer needed, but were in the mother code...)

Thank You!!

I don't have much time to work on this but one thing you can look at is using 3 of:

graphics.DrawRectangle(new Pen(Plots[0].Pen.Color, 2), bounds.X + bounds.Width - 60,bounds.Y + bounds.Height - 2 * 40, 46,22); where boxnumber variable is replaced by the actual number (in this example "2")

Probably the same with the graphics drawstring.

If I can find the time this weekend I'll see how much I can do to help but thought maybe these clues would get you started.

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
 
  #8 (permalink)
Elite Member
Neuquen, Argentina
 
Futures Experience: Intermediate
Platform: Ninja
Favorite Futures: CL, TF, 6S, NG, sometimes GC
 
Posts: 195 since Jul 2012
Thanks: 25 given, 39 received

reply

after doing some testing with Replay...it appears I didn't understand the NT paradigm

in Replay (assuming that NT works the same with live data??) the Plot Override is called on each tick, even when CalculateOnBarClose is True

(In Replay) The Plot Override is called independently of the Plot(), and it appears that it is called after all the Plot() methods.

For my purposes I want the slope to be calculated on bar close...which is different than how most would use this....

I'm going to have to rethink how this is written (for my purpose)

(also Boxnumber should have been boxnumber)

Reply With Quote
 
  #9 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received

You might consider using the bool FirstTickOfBar if you want to control the processing.

I just have to ask, why do you want to write an indicator to show 3 angles when you can simply put 3 instances of 1 on the chart?

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
 
  #10 (permalink)
Elite Member
Neuquen, Argentina
 
Futures Experience: Intermediate
Platform: Ninja
Favorite Futures: CL, TF, 6S, NG, sometimes GC
 
Posts: 195 since Jul 2012
Thanks: 25 given, 39 received

reply


Yes, I will filter for first tick of bar....

This code is going to go into a mother indicator.

Rather than instantiate a bunch of separate indicators, I want them all in one codeset, for the most part, so that the data is easily shared by one single intelligent algorithm...for example, to know the simultaneous value of three different MA is valuable information. It is easier for a process to have all this information in one place, especially if it is going to be correlated with other live indicators / calculations.

Reply With Quote

Reply



futures io > > > > > .NET advice for persistent graphics.DrawString and graphics.DrawRectangle

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Graphics cards c12345 Tech Support 24 April 30th, 2017 01:16 AM
Pc Graphics Card spx_tdr Tech Support 84 December 5th, 2015 07:40 AM
graphics resizing UrmaBlume Traders Hideout 7 August 19th, 2010 09:23 PM
Graphics question zeller4 NinjaTrader Programming 3 July 3rd, 2009 10:11 AM
More graphics Poocher Feedback and Announcements 1 June 15th, 2009 11:12 PM


All times are GMT -4. The time now is 08:46 PM.

Copyright © 2017 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
Page generated 2017-12-10 in 0.14 seconds with 20 queries on phoenix via your IP 54.83.122.227