Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Draw Line above Entry Long
Collapse
X
-
Hello r3n3v,
Thank you for your post.
Please see the attached example scripts which demonstrate how to use Draw.Line() to draw a line 20 ticks above an entry order for an indicator or strategy.
In the indicator example script, we subscribe to Account OnOrderUpdate events and check for the "Entry" named orders in OnOrderUpdate(). We then use TriggerCustomEvent and call Draw.Line to draw a line 20 ticks above the entry order (20*TickSize). We need to use TriggerCustomEvent because we are only able to make BarsAgo references from data processing events like OnBarUpdate. (BarsAgo references are used in Draw.Line)
In the strategy example script, we use the built-in OnOrderUpdate method. In the OnOrderUpdate method, we check for the order.Name and assign the order to our order object. Then, we check if our order object is not null and call Draw.Line() to draw a line 20 ticks above the entry order.
See the help guide documentation below for more information.
Draw.Line() - https://ninjatrader.com/support/help.../draw_line.htm
OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm
TriggerCustomEvent - https://ninjatrader.com/support/help...ustomevent.htm
Let us know if we may assist further.<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>
-
Hi Brandon,Originally posted by NinjaTrader_BrandonH View PostHello r3n3v,
Thank you for your post.
Please see the attached example scripts which demonstrate how to use Draw.Line() to draw a line 20 ticks above an entry order for an indicator or strategy.
In the indicator example script, we subscribe to Account OnOrderUpdate events and check for the "Entry" named orders in OnOrderUpdate(). We then use TriggerCustomEvent and call Draw.Line to draw a line 20 ticks above the entry order (20*TickSize). We need to use TriggerCustomEvent because we are only able to make BarsAgo references from data processing events like OnBarUpdate. (BarsAgo references are used in Draw.Line)
In the strategy example script, we use the built-in OnOrderUpdate method. In the OnOrderUpdate method, we check for the order.Name and assign the order to our order object. Then, we check if our order object is not null and call Draw.Line() to draw a line 20 ticks above the entry order.
See the help guide documentation below for more information.
Draw.Line() - https://ninjatrader.com/support/help.../draw_line.htm
OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm
TriggerCustomEvent - https://ninjatrader.com/support/help...ustomevent.htm
Let us know if we may assist further.
Just testing out the Draw.Line.
When I loaded the indicator, it gave the following Error message on NinjaScript Output;
Indicator 'DrawLineAboveEntryIndicatorNT8': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
Could you please investigate the above error.
The Strategy seems to work.
Omololu
Comment
-
Hello omololu,
Thank you for your note.
After testing the DrawLineAboveEntryIndicator_NT8 script attached in my previous reply I see the error message you are referring to. I have attached a modified version of the script that no longer has the error message occur.
To test this indicator, enable the indicator on the chart, open Chart Trader in the chart window, select an ATM Strategy template, and place an order. Once the order is placed, a solid green line is drawn 20 ticks above the entry order.
Let us know if we may assist further.Attached Files<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>
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
574 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
332 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|


Comment