Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        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.

            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by cre8able, Yesterday, 01:16 PM
            3 responses
            11 views
            0 likes
            Last Post cre8able  
            Started by ChartTourist, Today, 08:22 AM
            0 responses
            4 views
            0 likes
            Last Post ChartTourist  
            Started by LiamTwine, Today, 08:10 AM
            0 responses
            2 views
            0 likes
            Last Post LiamTwine  
            Started by Balage0922, Today, 07:38 AM
            0 responses
            5 views
            0 likes
            Last Post Balage0922  
            Started by JoMoon2024, Today, 06:56 AM
            0 responses
            6 views
            0 likes
            Last Post JoMoon2024  
            Working...
            X