Help with removing graphics.DrawLine - NinjaTrader Programming | futures io social day trading
futures io futures trading


Help with removing graphics.DrawLine
Updated: Views / Replies:1,398 / 5
Created: by erk707 Attachments:0

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
 

Help with removing graphics.DrawLine

  #1 (permalink)
Elite Member
Irvine, CA
 
Futures Experience: Intermediate
Platform: Ninjatrader
Favorite Futures: Piano, ES, GC, CL, NQ, 6E
 
Posts: 21 since Feb 2011
Thanks: 5 given, 4 received

Help with removing graphics.DrawLine

I am working on an order entry strategy that Draws Line in the override void Plot method. I am a beginner programmer and have figured out how to DrawLines under this method but need help with a few loose ends. I am drawing custom entry, stop loss and take profit line that are being updated tick by tick in OnBarUpdate. If I manually close the trade I am trying to figure out how I can remove the draw object created in this method. Here is where I am stuck:

1. How can I add a string tag so when I use graphics.DrawLine I can identify the lines based on a specific entry order.
2. If I close the trade out how can I remove or clear the DrawLine's based on this string tag.

With Ninja theres the RemoveDrawObject but since I am overriding the method I'm not sure how to achieve removing a specific "tagged" DrawLine.

Do I create a custom method to do this or create an additional overload for DrawLine method so I can add in string tag as a reference.

Then how do I clear or dispose the specific line.

I need to be able to do this with the following draws within Graphics(IE add a specific string tag and be able to clear/dispose/erase)
1. graphics.DrawLine
2. graphics.FillRectangle
3. graphics.DrawString


Thanks for any help that can be provided.

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
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,340 since Dec 2012
Thanks: 11,282 given, 7,092 received



erk707 View Post
I am working on an order entry strategy that Draws Line in the override void Plot method. I am a beginner programmer and have figured out how to DrawLines under this method but need help with a few loose ends. I am drawing custom entry, stop loss and take profit line that are being updated tick by tick in OnBarUpdate. If I manually close the trade I am trying to figure out how I can remove the draw object created in this method. Here is where I am stuck:

1. How can I add a string tag so when I use graphics.DrawLine I can identify the lines based on a specific entry order.
2. If I close the trade out how can I remove or clear the DrawLine's based on this string tag.

With Ninja theres the RemoveDrawObject but since I am overriding the method I'm not sure how to achieve removing a specific "tagged" DrawLine.

Do I create a custom method to do this or create an additional overload for DrawLine method so I can add in string tag as a reference.

Then how do I clear or dispose the specific line.

I need to be able to do this with the following draws within Graphics(IE add a specific string tag and be able to clear/dispose/erase)
1. graphics.DrawLine
2. graphics.FillRectangle
3. graphics.DrawString


Thanks for any help that can be provided.

The direct graphics methods are used whenever Plot is called to redraw the whole area, so you don't so much remove anything as just not draw it. Just trigger a ChartControl.Refresh() if it's really needed (shouldn't be, normally this will happen whenever the price needs updating on-screen anyway so is usually only needed for more special cases like user region moves or bitmap redirection).

See the standard Ninja VolumeProfiles indicator for example.

Travel Well
Reply With Quote
The following user says Thank You to ratfink for this post:
 
  #4 (permalink)
Elite Member
Irvine, CA
 
Futures Experience: Intermediate
Platform: Ninjatrader
Favorite Futures: Piano, ES, GC, CL, NQ, 6E
 
Posts: 21 since Feb 2011
Thanks: 5 given, 4 received


ratfink View Post
The direct graphics methods are used whenever Plot is called to redraw the whole area, so you don't so much remove anything as just not draw it. Just trigger a ChartControl.Refresh() if it's really needed (shouldn't be, normally this will happen whenever the price needs updating on-screen anyway so is usually only needed for more special cases like user region moves or bitmap redirection).

See the standard Ninja VolumeProfiles indicator for example.

ratfink,

Do you know if you can call C# Graphics within a strategy. I know in an indicator you can override the Plot method. What if you wanted to use NT drawing method somethimes and custom C# drawings other times. I am trying to draw a custom line in a strategy with the below. It complies but does not draw anything. Can you point me in the right direction with what I am doing wrong.

 
Code
Graphics graphics;
graphics = this.CreateGraphics();

// Define Pen Color
Pen greenPen = new Pen(Color.Green,4);
// Draw connecting line
if(Close[0] != 0)
{
	graphics.DrawLine(greenPen, ChartControl.CanvasRight/2, ChartControl.CanvasBottom/2, 
ChartControl.CanvasRight, ChartControl.CanvasBottom/2);
				
	Print("Drawing called");
}
else
	Print("failure");

Reply With Quote
 
  #5 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,340 since Dec 2012
Thanks: 11,282 given, 7,092 received


erk707 View Post
ratfink,

Do you know if you can call C# Graphics within a strategy. I know in an indicator you can override the Plot method. What if you wanted to use NT drawing method somethimes and custom C# drawings other times. I am trying to draw a custom line in a strategy with the below. It complies but does not draw anything. Can you point me in the right direction with what I am doing wrong.

Can't override the Plot method in a strategy as far as my test shows, and that's where you would want to put any direct draw graphics, not in the main body, so it's an X (no) from me. Maybe one of the longer standing forum whizzes knows a better/correct route, otherwise back to indicator and strategy drawing board, they can be linked via globals if that is really needed.

(Direct draw graphics have to be re-drawn on any refresh, i.e. N times/sec or window change events, not just when you think they need to be, there is no persistence, unlike the illusion created by drawing object graphics).

Travel Well
Reply With Quote
The following 2 users say Thank You to ratfink for this post:
 
  #6 (permalink)
Elite Member
Irvine, CA
 
Futures Experience: Intermediate
Platform: Ninjatrader
Favorite Futures: Piano, ES, GC, CL, NQ, 6E
 
Posts: 21 since Feb 2011
Thanks: 5 given, 4 received

Creating a synced List between strategy and indicator for Plot override

I wanted to post back an indicator/strategy developed with the Ninja support. What it does is create a synced List between a strategy and indicator. You can dump all your data from within the strategy and it will sync up from within the indicator. You can modify the List from either side indicator or strategy. With this you can loop through the List from within the override Plot method of the indicator to "achieve" a work around override Plot of the strategy. I have uploaded the zip file to the below link.

https://futures.io/download/vip_elite_circle/1581-download.html?view

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

Reply



futures io > > > > > Help with removing graphics.DrawLine

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
DrawLine Email Alert ceramictilepro NinjaTrader Programming 1 February 13th, 2014 11:34 PM
Reset after DrawLine Touched ceramictilepro NinjaTrader Programming 5 February 11th, 2014 12:25 AM
N7 DrawLine not working ceramictilepro NinjaTrader Programming 4 February 2nd, 2014 02:51 PM
.NET advice for persistent graphics.DrawString and graphics.DrawRectangle vantojo NinjaTrader Programming 9 August 3rd, 2013 04:53 PM
DrawLine kaywai NinjaTrader Programming 4 December 5th, 2012 12:22 AM


All times are GMT -4. The time now is 06:23 AM.

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-17 in 0.11 seconds with 19 queries on phoenix via your IP 54.82.81.154