Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Adjust ATM-generated stop after creation?
Collapse
X
-
Adjust ATM-generated stop after creation?
I created a strategy which uses ATMs. It works great, except I would like the stop to start at a particular price, not the price plus slippage. Is there a way to access the stop order that was generated by the ATM to adjust the starting point back to the actual price I want it to start at? Note: I do not want to use stop-limit orders for entry because sometimes entries are missed with those.Last edited by gbourque; 10-17-2023, 02:39 PM.Tags: None
-
Hello gbourque,
Thanks for your post.
NinjaScript strategies that use Atm Strategy Methods to submit orders with ATM Strategy Templates, you could use the AtmStrategyChangeStopTarget() method to modify the price of a specified order of the specified ATM.
See this help guide page for more information about AtmStrategyChangeStopTarget() and sample code: https://ninjatrader.com/support/help...stoptarget.htm
The SampleAtmStrategy strategy that comes default with NinjaTrader also demonstrates using this method in a NinjaScript. To view this reference sample, open a New > NinjaScript Editor window, open the Strategies folder, and double-click on the SampleAtmStrategy file.<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>
-
This works on the first Renko bar, the bar on which the order was initially placed, but on the next bar it doesn't work, the stop price then shows the initial slippage. I only wish to make this adjustment on the first and second bars, the ATM stop movement can take over from there. But why isn't it working on the second bar? Does it have something to do with the order id? I'm using "STOP1" for the order id in both adjustments, as per the example you cited. It doesn't work at all if I use anything but "STOP1". But it doesn't work on the second bar even when I use it.
Comment
-
Let me add that changing the ATM stop on the bar in which the ATM was created does not work in Sim or real accounts. It works in Playback. This is obviously a timing/threading thing. Be sure to test everything with Sim before using with real accounts, because some things work in Playback which will not work in anything but Playback.
Comment
-
Hello gbourque,
Thanks for your notes.
What exactly are you referring to when you mention "the ATM was created does not work in Sim or real accounts"?
To see how the code of your strategy is behaving when running realtime vs running in Playback, debugging prints should be added to the script.
Below is a link to a forum post that demonstrates how to use prints to understand behavior.
https://ninjatrader.com/support/foru...121#post791121<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
-
I mean if you call ATMStrategyCreate() on a bar (assuming update on bar close), if you try to change the stop immediately it will often tell you either the order doesn't exist or the stop doesn't exist. It works in Playback, as it processes orders synchronously. But Sim and real accounts are asynchronous, and you have to wait for the next bar. I found this noted in your documentation somewhere.
I tried all kinds of ways to get around this, but nothing worked. It's not that big of a deal. I've moved on.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
50 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
127 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
69 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment