Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Max Position Size

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

    Max Position Size

    I was wondering if there's a sample script out there where it shows how to do max position size at any given time if a condition is met.

    I wanted to start initially with 1 contracts using ATM, and every time a condition is met scale in with the same ATM template to a max of 3 contracts.

    #2
    Hello AgriTrdr,

    I am not aware of a specific sample like that using ATM's, you would essentially need to replicate the SampleATMStrategy code 3 times to have 3 ATM's.

    You can scale in/out if you use the managed approach, in that case you would use multiple entries and then signal names to tie the exits with specific parts of the position. To enter the max position size you would just enter with 3 quantity instead of 3 separate orders.

    Comment


      #3
      Hi Jesse,

      Thanks for your response. I found the attached sample on Ninjatrader Help for a Trade Limiter. The sample restricts the trade to max # per day. The alteration that I did was added on my "ExitLong" or "ExitShort" logic "tradeCounter--" to subtract the count so it limits the max contracts at any given time to 5.

      An example would be if it enters long 1 at 8:35 then another long 1 at 8:45 (tradeCounter would be 2), if logic is met to exit short, it would exit short 1 contract so the trade counter would be 1.

      Would this be the right way to do it?

      Thanks,
      Ujit
      Attached Files

      Comment


        #4
        Hello AgriTrdr,

        If you are asking if that is how you can do the given task with ATM's then no, that would be the Managed Approach being used in that sample. For ATM's you would have to see the SampleATMStrategy again for the example of 1 usage.

        For a Managed approach strategy the file you attached would be able to limit the trades to X per day.

        Comment


          #5
          Hi Jesse - yes I was asking about Managed Approach. I do know that the sample file would limit to trades to X per day, but I would like to modify it so it would limit to trades to X at any given time. Would the sample work if in "ExitLong" or "ExitShort" logic I include "tradeCounter--"?

          Or is there an example that you could share if the sample doesn't work?

          Comment


            #6
            Hello AgriTrdr,

            X trades at any given time would be different than per day. The way that sample works now is that it resets each day to 0. For any given time you would have to also decrement the variable when a trade is complete so that it could reduce the count and allow for future trades.

            If we assume all orders are successful and filled you can use OnExecutionUpdate to watch for filled orders: https://ninjatrader.com/support/help...ub=onexecution

            Based on an order fill you could subtract 1 or the quantity from the variable being used to prevent entries.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            71 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            143 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            76 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            47 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            51 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X