Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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.Brandon H.NinjaTrader Customer Service
-
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#post791121Brandon H.NinjaTrader Customer Service
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 futtrader, 04-21-2024, 01:50 AM
|
4 responses
41 views
0 likes
|
Last Post
by futtrader
Today, 03:01 PM
|
||
Can someone turn this thinkscript into a ninjascript. 5PM CST OHL and Previous Day
by Option Whisperer
Started by Option Whisperer, Today, 09:55 AM
|
1 response
12 views
0 likes
|
Last Post
by bltdavid
Today, 02:44 PM
|
||
Started by port119, Today, 02:43 PM
|
0 responses
8 views
0 likes
|
Last Post
by port119
Today, 02:43 PM
|
||
Started by Philippe56140, Today, 02:35 PM
|
0 responses
7 views
0 likes
|
Last Post Today, 02:35 PM | ||
Started by 00nevest, Today, 02:27 PM
|
0 responses
7 views
0 likes
|
Last Post
by 00nevest
Today, 02:27 PM
|
Comment