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
Automatically moving my stoploss
Collapse
X
-
Hello nandhumca,
It would depend on what type of script this is.
If this is a NinjaScript Strategy, the OnExecutionUpdate() method will update for each execution (order fill).
https://ninjatrader.com/support/help...tionupdate.htm
Below is a link to an example ProfitChaseStopTrailExitOrdersExample_NT8 that demonstrates.
Last edited by NinjaTrader_ChelseaB; 03-02-2022, 01:36 PM.Chelsea B.NinjaTrader Customer Service
-
Last edited by NinjaTrader_ChelseaB; 03-02-2022, 01:36 PM.Chelsea B.NinjaTrader Customer Service
Comment
-
Comment
-
Hi Chelsea, I am trying to something similar in ProfitChaseStopTrailIndicatorExample. In that you creating new ProfitTarget ans StopLoss order and submitting it. In my use case, ProfitTarget and Stoploss will be placed by ATM and i want find the StopLoss order and update the price. I tried to access the current StopLoss order with OrderState=Accepted and OrderType=StopMarket. But it is not listing part of account.Orders.
Code:foreach(Order order in account.Orders){ //if(order.OrderState.GetType().Equals(OrderState.Ac cepted.GetType())){ Print ("==========="); Print(order); Print(order.OrderState ); Print(order.OrderType ); //} }
Comment
-
Hello nandhumca,
The .GetType() is probably not what you intend to use. OrderState is an enum if you want to know the type. You want to use the enum values in the comparisons.
Attached is an example script that just prints account order updates and will print active orders when a button is clicked.
Try using an atm strategy and watch for the name="Stop loss" to appear in the orders listed and updates.Attached FilesChelsea B.NinjaTrader Customer Service
Comment
-
below code in your script will print all the orders for the day, not only the active orders currently working. If you see my previous reply , that code is printing all orders. In that only I couldn't find the ACTIVE Profit Target and Stop Loss orders. I tried with name "Stop Loss". It is helping me to filter all the stop loss orders for that account, not the active one and active one is not at all listed with account.Orders.
Code:foreach (Order order in account.Orders) Print(string.Format("{0} | {1}", order.Account.DisplayName, order));
Comment
-
Hello nandhumca,
Stop loss orders will likely be in a Working state and not Active state.
To get only orders that are both working or active:
Code:foreach (Order order in account.Orders.Where(o => o.OrderState == OrderState.Working || o.OrderState == OrderState.Accepted)) Print(string.Format("{0} | {1}", order.Account.DisplayName, order));
What does the stop loss show as the last updated state?Chelsea B.NinjaTrader Customer Service
- Likes 1
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
57 views
0 likes
|
Last Post
by DynamicTest
Today, 08:25 PM
|
||
Started by ScottWalsh, Today, 06:52 PM
|
4 responses
36 views
0 likes
|
Last Post
by ScottWalsh
Today, 07:40 PM
|
||
Started by olisav57, Today, 07:39 PM
|
0 responses
7 views
0 likes
|
Last Post
by olisav57
Today, 07:39 PM
|
||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
20 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
9 views
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
Comment