View Full Version : Accessing trend lines in Strategies
higher.high
09-12-2010, 04:36 PM
I would like to combine my current strategy with a trend line crossover. I have a trend line on a chart of a larger fractal and want to see if price crosses that line from a strategy running on a smaller fractal.
I see that I can attach a line to multiple charts, not sure if that can be used in anyway to let me access that trend line from inside a strategy.
Any help/pointers would be appreciated.
NinjaTrader_Austin
09-12-2010, 06:29 PM
higher.high, unfortunately this is unsupported.
higher.high
09-12-2010, 07:53 PM
Hello Austin,
Thanks for your response.
Is accessing a line from another chart not supported, or just accessing a line from current chart (on which a strategy runs) not supported as well?
NinjaTrader_Bertrand
09-13-2010, 06:13 AM
higher.high, as long as it's on the primary series you can access those drawing objects as NT7 with the DrawObjects collection - http://www.ninjatrader.com/support/helpGuides/nt7/drawobjects.htm
http://www.ninjatrader.com/support/helpGuides/nt7/idrawobject.htm
higher.high
09-17-2010, 03:31 PM
Hello Bertrand (http://www.ninjatrader.com/support/forum/member.php?u=6264),
Let's say I give my trend line a "tag" and access it from my strategy. It is available as a ILine or IDrawObject object. Now is there a way to check in a Strategy's onBarUpdate() where the bar has acrossed the line?
Thanks in advance.
NinjaTrader_Josh
09-17-2010, 03:55 PM
higher.high,
Perhaps there is some confusion here.
All draw objects are IDrawObject objects. Then they are further categorized as things like ILine, IRay, etc.
So the answer to your question is both. It is an ILine IDrawObject.
You will need to custom program your own code to determine where the price crossed the line. From the ILine you can access its start and end anchor points. From there you can loop between each bar between the start and end point to find where price crossed its value. Obviously the line value on each bar would be different though so you would actually need to calculate out the slope of your line and determine the intercept on each of your bars to do this check.