NexusFi: Find Your Edge


Home Menu

 





Strategy code assist needed for handling positions


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one sburtt with 6 posts (0 thanks)
    2. looks_two MWinfrey with 1 posts (0 thanks)
    3. looks_3 monpere with 1 posts (0 thanks)
    4. looks_4 FalseProphets with 1 posts (0 thanks)
    1. trending_up 3,353 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 10 posts
    2. attach_file 1 attachments




 
Search this Thread

Strategy code assist needed for handling positions

  #1 (permalink)
 sburtt 
London, UK
 
Experience: Advanced
Platform: NinjaTrader
Trading: EUR/USD
Posts: 58 since Jul 2012
Thanks Given: 3
Thanks Received: 4

Hi Guys,

I am new to NT, I am sure this is likely easy ... just cant yet get my head around it.

If my market position is long and my strategy generates a short signal, how can tell NT to go short twice the default size, and even more important how can I explain NT that at this point my net short position is 1 time the default size, hence stop loss should apply to that size and not the 2 * default size?

Please let me know if my query is clear, thanks for your help

John

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
Cheap historycal L1 data for stocks
Stocks and ETFs
REcommedations for programming help
Sierra Chart
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #3 (permalink)
 
MWinfrey's Avatar
 MWinfrey 
Lubbock TX
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Stage 5 Trading
Trading: CL
Posts: 1,878 since Jul 2009
Thanks Given: 1,450
Thanks Received: 3,335



sburtt View Post
Hi Guys,

I am new to NT, I am sure this is likely easy ... just cant yet get my head around it.

If my market position is long and my strategy generates a short signal, how can tell NT to go short twice the default size, and even more important how can I explain NT that at this point my net short position is 1 time the default size, hence stop loss should apply to that size and not the 2 * default size?

Please let me know if my query is clear, thanks for your help

John

If I understand your situation correctly that's just a stop and reverse. You don't have to keep track of the number of contracts.

go to this link and look at the sample code in the attachment Strategy: Trading crossovers - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

That should get you started.

Reply With Quote
  #4 (permalink)
 sburtt 
London, UK
 
Experience: Advanced
Platform: NinjaTrader
Trading: EUR/USD
Posts: 58 since Jul 2012
Thanks Given: 3
Thanks Received: 4


MWinfrey View Post
If I understand your situation correctly that's just a stop and reverse. You don't have to keep track of the number of contracts.

go to this link and look at the sample code in the attachment Strategy: Trading crossovers - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

That should get you started.

not really. What I mean is assume I am long 50k EURUSD, when I get a short signal what NT does is cover 50k EURUSD long and short 50k EURUSD, basically it sells 100k EURUSD, but instead of doing this with 1 trade it does 2 trades, hence I pay twice commissions.

IF I set my short order to:

EnterShort(DefaultQuantity*2,"");

I avoid this problem, HOWEVER, at this point it doesn't accept/identify the correct quantity to buy on my StopLoss, what NT does is set the StopLoss quantity to 100k, rather than my current position of 50k.

My question is what should I use in the Quatity field of my order:

ExitShort();

?

Thanks,

Started this thread Reply With Quote
  #5 (permalink)
 
monpere's Avatar
 monpere 
Bala, PA, USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus, IB
Trading: SPY, Oil, Euro
Posts: 1,854 since Jul 2010
Thanks Given: 300
Thanks Received: 3,372


sburtt View Post
not really. What I mean is assume I am long 50k EURUSD, when I get a short signal what NT does is cover 50k EURUSD long and short 50k EURUSD, basically it sells 100k EURUSD, but instead of doing this with 1 trade it does 2 trades, hence I pay twice commissions.

IF I set my short order to:

EnterShort(DefaultQuantity*2,"");

I avoid this problem, HOWEVER, at this point it doesn't accept/identify the correct quantity to buy on my StopLoss, what NT does is set the StopLoss quantity to 100k, rather than my current position of 50k.

My question is what should I use in the Quatity field of my order:

ExitShort();

?

Thanks,

Use 'Unmanaged' orders. But, that does require some additional (advanced) coding.

Reply With Quote
  #6 (permalink)
 sburtt 
London, UK
 
Experience: Advanced
Platform: NinjaTrader
Trading: EUR/USD
Posts: 58 since Jul 2012
Thanks Given: 3
Thanks Received: 4

Here is attached an example of what I mean

Started this thread Reply With Quote
  #7 (permalink)
 sburtt 
London, UK
 
Experience: Advanced
Platform: NinjaTrader
Trading: EUR/USD
Posts: 58 since Jul 2012
Thanks Given: 3
Thanks Received: 4

are you sure there is no way to sort this issue out under the managed order protocol?

Started this thread Reply With Quote
  #8 (permalink)
FalseProphets
Toledo, OH
 
Posts: 41 since Nov 2012
Thanks Given: 16
Thanks Received: 46

Hi,
You have to go the route of unmanaged orders to circumvent the Ninja failsafe of having two trades in two directions simultaneously. One question I always ask, is saving on the commission that important that you want to open yourself to the world of unmanaged orders?
Again, it can be done but not recommended. Time better spent on extending profitability of current methods than squeezing money out of the commissions bucket, IMHO.

Reply With Quote
  #9 (permalink)
 baruchs 
Israel
 
Experience: Intermediate
Platform: NinjaTrader
Broker: pfg
Trading: eminis
Posts: 323 since Jun 2009


Quoting 
What I mean is assume I am long 50k EURUSD, when I get a short signal what NT does is cover 50k EURUSD long and short 50k EURUSD, basically it sells 100k EURUSD, but instead of doing this with 1 trade it does 2 trades, hence I pay twice commissions.

You pay commition for 100K! It doesn't metter if you make 1,2 or 100 trades.

Reply With Quote
  #10 (permalink)
 sburtt 
London, UK
 
Experience: Advanced
Platform: NinjaTrader
Trading: EUR/USD
Posts: 58 since Jul 2012
Thanks Given: 3
Thanks Received: 4



baruchs View Post
You pay commition for 100K! It doesn't metter if you make 1,2 or 100 trades.

Not true if you have a fixed commission up to 100k

Started this thread Reply With Quote




Last Updated on November 13, 2012


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts