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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    156 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    90 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    140 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    130 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    107 views
    0 likes
    Last Post CarlTrading  
    Working...
    X