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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    57 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    79 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    42 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    101 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    61 views
    0 likes
    Last Post PaulMohn  
    Working...
    X