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 pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
148 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
||
Started by mattbsea, Today, 05:44 PM
|
0 responses
5 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
33 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
5 views
0 likes
|
Last Post
by tkaboris
Today, 05:13 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
16 responses
3,282 views
0 likes
|
Last Post
by Leafcutter
Today, 04:14 PM
|
Comment