Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

looking for how to make a restriction of open positions

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

    looking for how to make a restriction of open positions

    Hello everyone, looking for how to make a restriction of open positions,
    for example, I need an indicator to do that only 2 contracts can be opened and nothing more.

    Roughly speaking, I want to limit random inputs during scalping, the indicator should check if, for example, 2 contracts are already open, then it no longer allows you to enter the position.

    how can I implement this with an indicator?
    please example
    Thank you in advance

    #2
    Hello memonolog,

    If the indicator is what is doing the trading you could use a int variable and just count to 2, after that don't allow the logic to submit more orders until a predefined time or action. You could also use the account and its Positions collection to check what positions are open to stop your logic.

    If you mean to prevent manual orders after 2 contracts there is not a supported way to do that from NinjaScript. You would generally just need to avoid placing more orders than you wanted if manually trading.

    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    566 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X