Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Using Drawing Objects in conditions
Collapse
X
-
Using Drawing Objects in conditions
I'm setting up (trying) gap strategy using prior OHLC indicator. I've set a condition where the if the open is above/below the prior days close it draws a ray. Now I wish to make a condition if the price crosses above/below that ray to trigger an action. Is this possible? I've read a couple forum post about drawing objects, but I haven't found anything on setting the object as a condition after it's been created.Tags: None
-
Hello Zinger357,
Thanks for your post.
You could loop through the DrawObjects collection to detect if there is a Ray drawing object on the chart and use StartAnchor.Price and EndAnchor.Price to get the prices of the StartAnchor and EndAnchor of that Ray drawing object.
The StartAnchor.Price or EndAnchor.Price could then be used for conditions in your strategy to detect if the current Close price (Close) is greater than the StartAnchor.Price or EndAnchor.Price.
I have attached an example script you could view that demonstrates this concept. The indicator draws a Ray on the chart from the Low price 10 bars ago to the High price of the current bar. Then, the indicator loops through the drawing objects on the chart and prints out the StartAnchor.Price and EndAnchor.Price of the Ray drawing object in a New > NinjaScript Output window.
See the help guide documentation below for more information.
Draw.Ray(): https://ninjatrader.com/support/help...8/draw_ray.htm
DrawObjects: https://ninjatrader.com/support/help...rawobjects.htm
IDrawingTool ChartAnchors: https://ninjatrader.com/support/help...rawingtool.htm
Please let me know if I may assist further.Attached FilesLast edited by NinjaTrader_BrandonH; 12-08-2022, 08:57 AM.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
589 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
342 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
555 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
552 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment