Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Doubling position size. Help Needed.

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

    Doubling position size. Help Needed.

    Can some one please help me figure out how to build a strategy that doubles position size after each lose. I already have a strategy and all I need to do is add another setting to it. Basically I just want to enter a position long and if I on the next trade I exit with a lose then double my position on the next entry and so on. So add a position size logic that always doubles current position (martingale style). Always loser sequence will be as follows; +1 -2 +4 -8 +16 -32 +64 etc.

    #2
    Hi relogical,

    There's lots of ways you could do this. You'll just need to update an order quantity variable when there's a losing trade. You could work with TradePerformance class to get PnL for the last closed trade. Help for using this class is available in the following reference sample:


    This can be simple or complex depending on your experience working with advanced event handlers and IOrder (to check for exit execution and update your variable then).

    A simple implementation that works with a conditional exit could look like this:
    Code:
    if (exitConditions)
    {
    	if (Position.GetProfitLoss(Close[0], PerformanceUnit.Points) < 0) //Gets unrealized PnL at time of exit. 
    		customQuantity *= 2;
            
             ExitLong();
    }
    
    EnterLong(customQuantity);
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      How can I do this via the Strategy Editor?

      Comment


        #4
        Unfortunately you will have to work with code to have this level of control.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          if(Performance.AllTrades.Count - 1 > 0 && Position.GetProfitLoss(Close[0], PerformanceUnit.Points)< 2.5 ){

          OrderQuantity = Position.Quantity + AddPositionAtReversal ;

          }

          where you get the current position size from Position.Quantiy and the variable AddPositionAtReversal, then pass the OrderQuantity to EnterLong() or EnterShort()

          you can write some code to change the size of the AddPositionAtReversal based on the consolidation condition.

          you can go like 1, -2, +3 , -4 , +5 which I found is safer.

          if your pocket is deep, you can play aggresive martingale.

          Comment


            #6
            I tried searching with no luck. Does anyone know if there is a sample strategy that includes a martingale system? I don't have a lot of experience with coding and I would like to see what a functioning version looks like, so I can try to add it to my strategy. Any help would be greatly appreciated.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            108 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            55 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            37 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            39 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            76 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X