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)
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.
The following user says Thank You to ratfink for this post:
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).
The following 2 users say Thank You to ratfink for this post:
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.