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 CarlTrading, Yesterday, 11:51 AM
            0 responses
            17 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, Yesterday, 11:48 AM
            0 responses
            22 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-25-2026, 09:53 PM
            0 responses
            17 views
            0 likes
            Last Post CaptainJack  
            Started by CaptainJack, 03-25-2026, 09:51 PM
            0 responses
            13 views
            0 likes
            Last Post CaptainJack  
            Started by Mindset, 03-23-2026, 11:13 AM
            0 responses
            20 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X