Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamic managing of multiple orders

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

    #16
    Chelsea, I've made this simple procedure that I think it should work.

    Setting EntriesPerDirection correctly in order to allow the desired maximum position, and having in mind that Z is an integer:

    Code:
    if (Position.MarketPosition == MarketPosition.Flat) 				
    {				
    	if(z>0 )			
    	{			
    		EnterLong(z*100000); 		
    	}			
    	if(z<0 )			
    	{			
    		EnterShort(-z*100000); 		
    	}			
    }				
    if (Position.MarketPosition == MarketPosition.Long) 				
    {				
    	if(z>0 )			
    	{			
    		if(z*100000>Position.Quantity )		
    		{		
    			EnterLong(z*100000-Position.Quantity); 	
    		}		
    		if(z*100000<Position.Quantity )		
    		{		
    			ExitLong(Position.Quantity-z*100000); 	
    		}		
    	}			
    	if(z<0 )			
    	{			
    		EnterShort(-z*100000); 		
    	}			
    }				
    if (Position.MarketPosition == MarketPosition.Short) 				
    {				
    	if(z>0 )			
    	{			
    		EnterLong(z*100000); 		
    	}			
    	if(z<0 )			
    	{			
    		if(-z*100000>Position.Quantity )		
    		{		
    			EnterShort(-z*100000-Position.Quantity); 	
    		}		
    		if(-z*100000<Position.Quantity )		
    		{		
    			ExitShort(Position.Quantity+z*100000); 	
    		}		
    	}			
    }
    Any idea, comment, suggestion?

    I' have not put it to work yet, but soon
    Last edited by pstrusi; 11-14-2013, 05:14 PM.

    Comment


      #17
      Hello pstrusi,

      Without the complete code I cannot know how this code will behave as I will not know the value of z.
      I do not see any syntax errors if that is helpful.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Surprisingly , the correct EntriesPerDirection for a correct Scaling in/out is 1 and EntriesHandling -> AllEntries. Thanks anyway for the comment

        Comment


          #19
          Hi pstrusi,

          With EntriesPerDirection set to 1, you should only be able to submit 1 EnterLong. After you are in a position any further EnterLongs will be ignored.

          If this is not the case, could you submit a "toy" (reduced to just this one issue) strategy that is able to show this is not correct?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #20
            I had mistakenly overlooked the previous input in the scaling in/out backtest. As you've correctly said, if EntriesPerDirection is 1, the system will just allow 1 Buy order ( independently of its size, which it's up to another input ).

            I've tested the scaling in/out script setting EntriesPerDirection to 14, and under this set the system does allow the whole process without any trouble.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            65 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            41 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            23 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            26 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            52 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X