NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 07-21-2012, 06:43 AM   #1
wyatt376
Member
 
Join Date: Feb 2012
Posts: 39
Thanks: 0
Thanked 0 times in 0 posts
Default Scale out 2 contracts

Hi to all,
i've a nice problem to scale out 2 contract,

i do the enterlong 2 times, one to contract (not setting the quantity at 2) because i want to give at every entry a different name...

Code:
EnterLong(1,"Long1");
EnterLong(1,"Long2");
set a common stoploss and different profit target,

Code:
SetStopLoss("Long1",CalculationMode.Ticks, 8, false);
SetStopLoss("Long2",CalculationMode.Ticks, 8, false);
SetProfitTarget(Long1",CalculationMode.Ticks, 8);
SetProfitTarget("Long2",CalculationMode.Ticks, 16);
when first contract (Long1) achieves the target i want to set stoploss of other contract (Long2) to breakeven (+2 point to Position.AvgPrice) ..
In this case, which is the mode to do this? Which is the mode to detect profit target of first contract is hitted? Or is there a way to know the number of contract i actually have in market (in this mode, when i have only 1 contract, i change stoploss)?

Another question: when i have 2 contracts in position, the object Position. ... which is the contract to refer this object? Both? Only the first? only the second?

Thanks to all !!

wyatt
wyatt376 is offline  
Reply With Quote
Old 07-21-2012, 12:12 PM   #2
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

wyatt,

The Position will reflect overall state there, so if you have 2 long orders your position is still Long.

Here is a reference sample on modifying stop losses and profit targets : http://www.ninjatrader.com/support/f...ead.php?t=3222

I would suggest using OnOrderUpdate() or OnExecution() to modify your stops since you said you wanted one position to close then to set breakeven.

http://www.ninjatrader.com/support/f...ead.php?t=7499

Please let me know if I may assist further.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 07-22-2012, 02:28 AM   #3
wyatt376
Member
 
Join Date: Feb 2012
Posts: 39
Thanks: 0
Thanked 0 times in 0 posts
Default

Ok, i find this way, isn't there a method for detect the number of contracts when i'm in market position?

another question:

you say: "The Position will reflect overall state there, so if you have 2 long orders your position is still Long"

my ask: if i've 2 contract in position, Position.AvgPrice is the first contract entry price or second contract entry price?

thanks!
wyatt376 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
scale out tonynt Strategy Analyzer 9 01-06-2013 12:25 PM
Switching from Right Scale to Left Scale laocoon Charting 4 01-16-2011 06:32 PM
Scale out Munichtrader General Programming 3 04-14-2010 02:39 PM
how to freeze the vertical scale? (manually adjust the scale?) leontancfa Charting 14 01-28-2010 01:01 PM
How many contracts gstewart Installation and Licensing 3 12-02-2004 11:03 AM


All times are GMT -6. The time now is 08:58 AM.