If I understand correctly it's not possible to use OnExecution() method within ATM strategy. Is there any way to change stop loss immediately after entry order execution?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
ATM stop
Collapse
X
-
ATM stop
Hello,
If I understand correctly it's not possible to use OnExecution() method within ATM strategy. Is there any way to change stop loss immediately after entry order execution?Tags: None
-
Hello Leeroy_Jenkins, thanks for writing in.
You will need to run the script OnEachTick to get the update as soon as possible. Call GetAtmStrategyEntryOrderStatus() on each tick (if the ATM has been submitted) to check for the entry order fill. Once that reaches the filled state you can change the stop price with AtmStrategyChangeStopTarget(). This is not as quick as OnExecutionUpdate, but it is the closest you can get using at ATM strategy.
Please let me know if I can assist any further.
-
I'm trying to implement @SampleAtmStrategy in my code and sometimes get 'AtmStrategyChangeStopTarget' method error: Order name 'Stop1' is invalid error. Entry order is filled but looks like stop haven't placed yet. So my code looks like this:
Sometimes it works w/o error.Code:protected override void OnBarUpdate() { if (atmStrategyId.Length > 0) ChangeStop(); } private void ChangeStop() { if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat && !StopPlaced) { try { // You can change the stop price if (GetAtmStrategyMarketPosition(atmStrategyId) == MarketPosition.Long) { AtmStrategyChangeStopTarget(0, StopPriceLong, "Stop1", atmStrategyId); StopPlaced = true; } if (GetAtmStrategyMarketPosition(atmStrategyId) == MarketPosition.Short) { AtmStrategyChangeStopTarget(0, StopPriceShort, "Stop1", atmStrategyId); StopPlaced = true; } } catch (Exception e) { if (State >= State.Terminated) return; Log("SampleTryCatch Error: Please check your code for errors.", NinjaTrader.Cbi.LogLevel.Warning); Print(Time[0] + " " + e.ToString()); } } }
I tried to check it this way and error still exists:
Code://on bar update string[] status = GetAtmStrategyEntryOrderStatus(orderId); if(status[2] == "Filled") ChangeStop();
Comment
-
You mean State.Accepted cuz I'm trying to change stop order which doesn't exist yet.
I'm checking if it's Accepted by using GetAtmStrategyStopTargetOrderStatus but still get this error Order name 'Stop1' is invalid.
There is some delay between filled entry order and ATM places stop loss order. So how can I check Stop1 if it's doesn't exist?
Comment
-
Hello Leeroy_Jenkins, thanks for your reply.
I apologize for the oversight, I did mean either the Working or Accepted state. Do you have a reduced example you can post or send to me? I will be happy to take a look at the original code. If you do not want to post it here, please send it to platformsupport at ninjatrader.com and reference "Attn ChrisL 2780455" in the body of the email.
https://ninjatrader.com/support/help...tAsSourceFiles - Export Script.
I look forward to hearing from you.
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
126 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