Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

reject any incoming orders based on condition

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    #2
    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.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    30 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    49 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    38 views
    0 likes
    Last Post CarlTrading  
    Working...
    X