NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 06-25-2012, 06:37 AM   #1
kenb2004
Senior Member
 
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
Default Scaling in then all out

When scaling in at different price levels and then exiting all positions at one price, is it necessary or best to use unique entry names or is not necessary at all? Can this senario be achieved with no entry names at all?
Thanks
kenb2004 is offline  
Reply With Quote
Old 06-25-2012, 07:03 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

Ken, if you're not working in the unmanaged mode, you would need to use unique names.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-25-2012, 07:20 AM   #3
kenb2004
Senior Member
 
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
Default

I'm using Advanced Managed Approach with Iorders. So if a Buy1 entry had a target of 4 ticks profit and then Buy2 enters 4 ticks lower, how would you put both target 4 ticks from the average price with unique entry names.
Thanks
kenb2004 is offline  
Reply With Quote
Old 06-25-2012, 07:23 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

Do you want to exit at 4 ticks for the combined entry price?
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-25-2012, 07:35 AM   #5
kenb2004
Senior Member
 
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
Default

Yes, the average (combined) of the 2 entry prices.
kenb2004 is offline  
Reply With Quote
Old 06-25-2012, 07:39 AM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

There would be 2 ways to approach this -

a) Calculate the exit price needed from your individual executions received

b) Update the target exit order after the second fill is in and your Position.AvgPrice would be updated to reflect the new average
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-25-2012, 08:38 AM   #7
kenb2004
Senior Member
 
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
Default

In approach b) how could you adjust the exit target of Buy1 2 ticks lower and make the Buy2 target the same as the Buy1 target with the execution of Buy2 entry being filled?
kenb2004 is offline  
Reply With Quote
Old 06-25-2012, 08:57 AM   #8
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

You would check for the fill state of your second IOrder (so you know you're in the full position) and then you just recall the exit order method / set method with your newly calculated target values to provide the adjustment.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-25-2012, 09:25 AM   #9
kenb2004
Senior Member
 
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
Default

Bertrand
Is there a way to cancel the Buy1 target and combine the 2 targets to the Buy2 exit with a quantity of 2, 4 ticks from the Position.AvgPrice?
Or does it need to be handled individually: Buy1 target = Buy1 Entryprice + 2 and Buy2 target = Buy2 Entryprice + 6?
Thanks
Last edited by kenb2004; 06-25-2012 at 09:46 AM.
kenb2004 is offline  
Reply With Quote
Old 06-25-2012, 10:03 AM   #10
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

Ken, if you work with the Set methods this would not be possible, as you can't cancel them only move closer or further away. When you work with the Exit() methods you could cancel an individual exit order and submit a final exit order for example with a emtpy ("") tag so it would 'catch' all orders.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-25-2012, 10:22 AM   #11
kenb2004
Senior Member
 
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
Default

Thanks, are there any sample strategies that you have that demonstrate this?
kenb2004 is offline  
Reply With Quote
Old 06-25-2012, 10:23 AM   #12
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

Sorry Ken, not aware of any I could point you to that would use this technique, it would come down to custom coding this exit approach.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-25-2012, 10:56 AM   #13
kenb2004
Senior Member
 
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
Default

So continuing with this senario, using IOrders and no Set Methods, would this way work?
protected override void OnOrderUpdate(IOrder order)
{
if (buy2entry != null && buy2entry == order){
if (order.OrderState == OrderState.Filled){
if (buy1target != null)
CancelOrder(buy1target);
buy2target = ExitLongLimit(0, true, 2, Position.AvgPrice + 4 * TickSize, "Buy_1&2_Profit", "");
} } }
kenb2004 is offline  
Reply With Quote
Old 06-25-2012, 12:04 PM   #14
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello kenb2004,
Yes, it would work fine.

Please let me know if I can assist you any further.
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 08-13-2012, 01:56 PM   #15
kenb2004
Senior Member
 
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
Default

From the code in post#13, how would you make the quantity a "catch-all" like the tag " " ?
Thanks
Code:
buy2target = ExitLongLimit(0, true, 2, Position.AvgPrice + 4 * TickSize, "Buy_1&2_Profit", ""); 
kenb2004 is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Scaling in and Scaling out question regarding commissions MicroTrends Automated Trading 4 07-04-2010 07:57 AM
Scaling In rnr123 Strategy Analyzer 1 08-31-2009 07:23 AM
Scaling in, Scaling out by differing poritions of total account size tooearly Automated Trading 6 08-10-2009 09:48 AM
Scaling In and Out PeterBrazel ATM Strategies (Discretionary Trading) 1 06-11-2009 05:09 AM
Scaling Richard Von Suggestions And Feedback 3 08-21-2007 01:44 PM


All times are GMT -6. The time now is 01:43 AM.