Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Redundancy in code to be sure only x positions only are entered

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

    Redundancy in code to be sure only x positions only are entered

    Hey everyone:

    What type of code can I include to be sure as a extra redundancy to be sure only x positions only are entered at a time without making the strategy disable if and when it every tries to happen?

    I do already use the NT parameters that are built in along with good logic in the code...just looking for (if possible) further redundancy to ensure that I am always only 1 contract in and if it tries to go 2 or more it simply disallows it BUT also keep the strategy running.

    For example, if I only want to be in 1 contract (futures) at a time, I want to be sure I am never in more than that at a time. For the most part the code does great in that regard already. However, some circumstances like major news or some other anomaly may make the strategy go in for 2 and then continue with the strategy enabled or sometime detect the overfill and disable.

    I would like to include some simple code to ensure...

    Any ideas?


    #2
    You can check your Position in OnPositionUpdate which should reflect your strategy position sooner than OnBarUpdate if there is a delay in a tick.

    I don't know of any catch all code I can provide as it really depends on the exact scenario you're running into.

    Overfills are serious errors that need to be corrected in your strategy. You can change the error handing to ignore errors and keep running in unmanaged code, however that does not resolve the issue of the overfill, it only prevents the strategy from being disabled. You would then need to program in your own logic for handling these sorts of situations.


    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    647 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X