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
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
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.Chris L.NinjaTrader Customer Service
-
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:
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.Chris L.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
3 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
18 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
1 view
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
9 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
||
Started by timmbbo, Today, 08:59 AM
|
2 responses
10 views
0 likes
|
Last Post
by bltdavid
Today, 04:10 PM
|
Comment