Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Attached to Indicator function to stoploss, to code this in a indicator or strategy
Collapse
X
-
Attached to Indicator function to stoploss, to code this in a indicator or strategy
Just found the function where you can attach an indicator to a stoploss for example. I am wondering if there is a bit of code example out there that can adjust the stop lockstep to the plot of an indicator. It works perfect using the chart function and I would like to mimic this in ninjascript code.Tags: None
-
Hello set2win,
Thanks for your post.
You could pass in the indicator value for the stopPrice parameter when calling your Exit order method or Set method in OnBarUpdate(). This would place the stop loss order at the indicator value.
For example, the code below would submit an Exit order to the price of the SMA() indicator.
ExitLongStopMarket(1, SMA(20)[0]);
See this help guide page for more information about Managed Approach order methods: https://ninjatrader.com/support/help...d_approach.htm
See this help guide page for more information about System Indicator methods: https://ninjatrader.com/support/help...indicators.htm
Here is a forum thread discussing this topic: https://forum.ninjatrader.com/forum/...ommand-for-nt8<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>
-
Hello set2win,
Thanks for your notes.
Yes, if this Exit order method was called on each bar update then the order would continue to be placed at the current SMA indicator value.
Please see the forum thread linked in post # 2 for more information.<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>
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
47 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
23 views
0 likes
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
33 views
1 like
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
51 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
42 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment