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
Method 2 modify ATM Strategy Stop Loss and Profit Target in a coded strategy.
Collapse
X
-
Method 2 modify ATM Strategy Stop Loss and Profit Target in a coded strategy.
I had a situation today where I took a break even trade and the strategy took a new position immediately afterwards. I want to code if Stop Loss is touched, then disable strategy. I already know to use CloseStrategy(). I don't know of any method to modify ATM Strategy Stops and Profit Targets. I couldn't find anything relevant in the Help Guide(in the ATM Strat section) for modifying ATM Strat SLs and PFs. Thanks for any help.Tags: None
-
Hello jamestrader21x,
Thank you for your post.
Does the strategy use ATM Strategy Methods? If so, AtmStrategyChangeStopTarget() could be used to change the price of a specified order of a specified ATM strategy.
See the help guide documentation below for more information.
AtmStrategyChangeStopTarget() - https://ninjatrader.com/support/help...stoptarget.htm
ATM Strategy Methods - https://ninjatrader.com/support/help...gy_methods.htm
Also, see the SampleAtmStrategy script that comes default with NinjaTrader for an example of using ATM Strategy Methods in a custom NinjaScript. To view the SampleAtmStrategy code, open a new > NinjaScript Editor window, open the Strategies folder, and select the SampleAtmStrategy script.
Let us know if we may assist further.
Brandon H.NinjaTrader Customer Service
-
I want to disable the strategy if my Stop Loss is triggered. I had a situation today where I took a break even trade and the strategy took a new position immediately afterwards. I don't now what method to use to say: If "stop market order" is triggered, then CloseStrategy().
Comment
-
Hello jamestrader21x,
Thank you for your note.
You could track the order in OnExecutionUpdate() by assigning the order to an order object. Then you could check if that order object is not null and call CloseStrategy().
See the SampleOnOrderUpdate example script in the help guide link below that demonstrates the use of OnExecutionUpdate().
SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm
Also, see the help guide documentation below for more information.
OnExecutionUpdate() - https://ninjatrader.com/support/help...tionupdate.htm
Let us know if we may assist further.Brandon H.NinjaTrader Customer Service
Comment
-
OnOrderUpdate() and OnExecutionUpdate() are too complicated for my skill level. I just put in some code to check if I'm long or short. If so, disable the strategy. I'll just have to re-enable it every time I have a winning trade and my criteria is met.
if (PositionAccount.MarketPosition == MarketPosition.Long || PositionAccount.MarketPosition == MarketPosition.Short)
{
CloseStrategy(atm_id);
}
Thanks for the help anyway.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Noerclou, Today, 04:55 AM
|
0 responses
1 view
0 likes
|
Last Post
by Noerclou
Today, 04:55 AM
|
||
Started by llanqui, Yesterday, 09:59 AM
|
2 responses
16 views
0 likes
|
Last Post
by llanqui
Today, 04:00 AM
|
||
Started by ThoriSten, Today, 03:56 AM
|
0 responses
6 views
0 likes
|
Last Post
by ThoriSten
Today, 03:56 AM
|
||
Started by PhillT, 04-19-2024, 02:16 PM
|
3 responses
20 views
0 likes
|
Last Post
by mangel2000
Today, 03:04 AM
|
||
Started by TraderBCL, Today, 02:37 AM
|
0 responses
4 views
0 likes
|
Last Post
by TraderBCL
Today, 02:37 AM
|
Comment