I want to implement an algorithm that will do the following :" if RealizedProfitLoss <= LossTarget, then reject new orders " so based on a condition, reject any incoming orders. for example when giving a sim account max order size = 3, if you submit an order with 4 contracts, there's a nice popup with an error saying cannot submit 4 contracts for sim account. i want something similar. at the moment I am looking at the OnOrderUpdate() method, but I cannot seem to find how to reject an order.. to give some context, this is an Add-on that needs to be constantly running and checking accounts (i am not sure under which method to have it running Onstatechange ? or onBarUpdate? onOrderUpdate?), this will be used to prevent the user from submitting any orders if their account reaches below or above a target, and close any open positions and cancel any open orders if account reaches below a loss, but i don't want it to close any positions when reaching above a profit target, in that case i want to cancel orders as well as preventing new orders but i don't intend to close open positions in case of a runner. that's why i am looking for a method that rejects an order. reject(order)
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
reject any incoming orders based on condition
Collapse
X
-
reject any incoming orders based on condition
hi !
I want to implement an algorithm that will do the following :" if RealizedProfitLoss <= LossTarget, then reject new orders " so based on a condition, reject any incoming orders. for example when giving a sim account max order size = 3, if you submit an order with 4 contracts, there's a nice popup with an error saying cannot submit 4 contracts for sim account. i want something similar. at the moment I am looking at the OnOrderUpdate() method, but I cannot seem to find how to reject an order.. to give some context, this is an Add-on that needs to be constantly running and checking accounts (i am not sure under which method to have it running Onstatechange ? or onBarUpdate? onOrderUpdate?), this will be used to prevent the user from submitting any orders if their account reaches below or above a target, and close any open positions and cancel any open orders if account reaches below a loss, but i don't want it to close any positions when reaching above a profit target, in that case i want to cancel orders as well as preventing new orders but i don't intend to close open positions in case of a runner. that's why i am looking for a method that rejects an order. reject(order)Last edited by greenberet; 07-22-2024, 04:16 AM. -
Hello greenberet,
Thank you for your inquiry.
You could use a bool to track whether or not the script should allow for additional entries. Require the bool to be true to submit further entries. Set the bool to false when your condition to reject new orders becomes true (if RealizedProfitLoss <= LossTarget). You can add another condition that checks if the bool is false and if so throw a message to the Log stating that further orders will be rejected.
Please let us know if you have any further questions.
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
560 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
325 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
547 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment