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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    52 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    25 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    16 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    23 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    24 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X