Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Strategy Development

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

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 08-12-2017, 08:59 AM   #1
EquityTrader
Member
 
Join Date: Mar 2012
Posts: 62
Thanks: 9
Thanked 4 times in 3 posts
Default Using int.MaxValue for ExitLong() Quantity Param.

Hello,

I like using ExitLong(...) method overloads without a quantity so that the NT8 execution engine knows to exit either my entire position, or my entire position that was entered with an entry order having a certain signal name, regardless of the number of entry orders and their signal names, and regardless of the number of exit orders already executed as part of my scaling out logic.

The problem is that the only ExitLong(...) method overload that accepts a parameter for "barsInProgressIndex" also requires that "quantity" be provided as well.

The list of ExitLong method overloads is displayed on this page: https://ninjatrader.com/support/help...s/exitlong.htm

Here is the only ExitLong method overload that accepts "barsInProgressIndex":
ExitLong(int barsInProgressIndex, int quantity, string signalName, string fromEntrySignal)

Is it safe, and is it the best possible solution, to pass a value of int.MaxValue as the value for the "quantity" parameter into this method overload in order to safely exit out of either 1) an entire position or 2) the entire position whose entry order had a specific signal name, as the following two method calls demonstrate?

// Flatten only the part of the position whose entry order had a signal name of "SignalNumber8", for the instrument whose "barsInProgressIndex" is 1.
ExitLong(1, int.MaxValue, "ExitSignal14", "SignalNumber8");

// Flatten the entire position for the instrument whose "barsInProgressIndex" is 1, by using "" for the entry signal name.
ExitLong(1, int.MaxValue, "ExitSignal14", "");

Thank you for your help,

EquityTrader
EquityTrader is offline  
Reply With Quote
Old 08-13-2017, 01:24 PM   #2
NinjaTrader_AlanP
NinjaTrader Customer Service
 
NinjaTrader_AlanP's Avatar
 
Join Date: Apr 2016
Location: Denver, CO
Posts: 1,387
Thanks: 115
Thanked 277 times in 267 posts
Default

Hello EquityTrader,

Under the managed approach, NinjaTrader would only submit an exit call for what your position was. So by entering quantity as Int.MaxValue, you are submitting an exit call it with an order quantity of 2,147,483,647, it would be expected that your full position would be closed.

Please let us know if you need further assistance.
NinjaTrader_AlanP is online now  
Reply With Quote
Old 08-14-2017, 09:44 AM   #3
EquityTrader
Member
 
Join Date: Mar 2012
Posts: 62
Thanks: 9
Thanked 4 times in 3 posts
Default

NinjaTrader_AlanP,

Thanks a lot for the information.

It sounds like you are saying that using int.MaxValue for the Quantity for any managed exit order is a safe and acceptable way to exit an entire position, either for a particular entry signal name or for all entry signal names for a given instrument. If this is true, it is great news!

If the conclusion I have drawn from NinjaTrader_AlanP's answer is incorrect or needs to be qualified with caviats, could somebody please respond to this forum thread with their corrections?

Thanks again!

EquityTrader
EquityTrader is offline  
Reply With Quote
Old 08-14-2017, 11:32 AM   #4
NinjaTrader_AlanP
NinjaTrader Customer Service
 
NinjaTrader_AlanP's Avatar
 
Join Date: Apr 2016
Location: Denver, CO
Posts: 1,387
Thanks: 115
Thanked 277 times in 267 posts
Default

Hello EquityTrader,

It is recommended you pass the position quantity to your exit call and not use int.MaxValue.

You should consider saving your position to a variable and passing this variable to your exit call and not rely on int.MaxValue.

Please let us know if you need further assistance.
NinjaTrader_AlanP is online now  
Reply With Quote
Old 08-14-2017, 01:02 PM   #5
EquityTrader
Member
 
Join Date: Mar 2012
Posts: 62
Thanks: 9
Thanked 4 times in 3 posts
Default

Hello NinjaTrader_AlanP,

That is unfortunate, for the following reason:

The managed order exit methods that don't have a barsInProgressIndex parameter already have method overloads without a quantity parameter. This fantastic feature makes it very easy to safely exit an entire position, either for a particular entry signal name or for all entry signal names for a given instrument, so long as the instrument being exited has the same BarsInProgress value as the current value for BarsInProgress.

Unfortunately, the NinjaScript API currently lacks managed order exit method overloads that include a barsInProgressIndex parameter but don't have a quantity parameter, and you've said that I should not use int.MaxValue for the quantity.

It will be difficult to constantly store and update variables for all of the positions for all of the unique entry signals that currently have positions on, as I am scaling in and scaling out constantly.

I feel that I am stuck, unless you can help me think of a way out of my dilemma.

I need a safe way to fully exit out of a managed position (either for a particular entry signal name or for all entry signal names for a given instrument) for a symbol whose BarsInProgress value is different than the current value for BarsInProgress,
as in the example of making trading decisions based on a primary instrument of SPY but trading a secondary instrument of GLD.

How can I do this without being forced to constantly store and update variables for all of the positions for all of the unique entry signals that currently have positions on?

Could the NinjaScript development team either add these missing method overloads, or could you post about what the current quantity-less method overloads pass to the private core order submission methods to tell the platform to "exit out of the entire position"? (I was guessing that the value was int.MaxValue, but maybe I am wrong).

Thanks for your patience in dealing with my questions. Hopefully my question can be seen as a way to make the NinjaScript API better in a way that benefits everybody.

Thanks again,

EquityTrader
EquityTrader is offline  
Reply With Quote
Old 08-15-2017, 12:40 PM   #6
NinjaTrader_AlanP
NinjaTrader Customer Service
 
NinjaTrader_AlanP's Avatar
 
Join Date: Apr 2016
Location: Denver, CO
Posts: 1,387
Thanks: 115
Thanked 277 times in 267 posts
Default

Hello Equity Trader,

I will submit a feature request that they’re be a syntax which allows you to specify a BIP but not quantity.

The recommended way to exit unique entry signals would be to store the position of those entries to a variable and pass that to your exit call.

Please let us know if you need further assistance.
NinjaTrader_AlanP is online now  
Reply With Quote
Old 08-15-2017, 01:51 PM   #7
EquityTrader
Member
 
Join Date: Mar 2012
Posts: 62
Thanks: 9
Thanked 4 times in 3 posts
Default

Hello NinjaTrader_AlanP,

Thank you very much for submitting that feature request.

It will really complete the NinjaScript Order Submission API
, and will encourage algorithmic trading across multiple instruments on your platform. Some platforms can't do this at all anyway, but by adding in these method overloads, NinjaTrader will really stand out to multi-instrument traders as being a good choice for everything from basic statistical arbitrage to more complicated strategies.

Currently, based on your recommendations, I can see that there is really no good way for me to do what I want to do with NinjaTrader, since passing int.MaxValue for Quantity is not recommended.

Thanks again for submitting the feature request. I will check back periodically to see if NinjaTrader can do what I need in this regard. Hopefully it is an easy enough change, since NinjaScript already has the quantity-less overloads for its exit order methods that (unfortunately) lack a barsInProgressIndex.

EquityTrader
EquityTrader is offline  
Reply With Quote
Old 08-16-2017, 12:43 PM   #8
NinjaTrader_AlanP
NinjaTrader Customer Service
 
NinjaTrader_AlanP's Avatar
 
Join Date: Apr 2016
Location: Denver, CO
Posts: 1,387
Thanks: 115
Thanked 277 times in 267 posts
Default

Hello EquityTrader,

The feature request has been assigned SFT-2612 and votes are being tracked.

Please let us know if you need further assistance.
NinjaTrader_AlanP is online now  
Reply With Quote
Old 08-17-2017, 07:27 AM   #9
EquityTrader
Member
 
Join Date: Mar 2012
Posts: 62
Thanks: 9
Thanked 4 times in 3 posts
Default

Thanks, NinjaTrader_AlanP!

Where can one go to vote for this feature?

I can't find the place on this website that allows people to vote on features. I even used your forum search to search for "SFT-2612" and I googled it, but no voting page was found.

Thanks again!

EquityTrader
EquityTrader is offline  
Reply With Quote
Old 08-17-2017, 10:07 AM   #10
NinjaTrader_AlanP
NinjaTrader Customer Service
 
NinjaTrader_AlanP's Avatar
 
Join Date: Apr 2016
Location: Denver, CO
Posts: 1,387
Thanks: 115
Thanked 277 times in 267 posts
Default

Hello EquityTrader,

They would be tracked through people requesting the feature through either this tread, another, or through email.

Please let us know if you need further assistance.
NinjaTrader_AlanP is online now  
Reply With Quote
Old 08-18-2017, 07:01 AM   #11
EquityTrader
Member
 
Join Date: Mar 2012
Posts: 62
Thanks: 9
Thanked 4 times in 3 posts
Default

Thanks, NinjaTrader_AlanP.

To all NinjaScript programmers who may ever want to create multi-instrument strategies:

Please vote for SFT-2612 by responding to this thread if you like using ExitLong(...) (and ExitShort(...), ExitLongLimit(...), etc.) method overloads without a quantity so that the NT8 execution engine knows to exit either your entire position, or your entire position that was entered with an entry order having a certain signal name, regardless of the number of entry orders and their signal names, and regardless of the number of exit orders already executed as part of your scaling out logic.

The problem for multi-instrument NinjaScript strategy programmers is that the only ExitLong(...) method overload that accepts a parameter for "barsInProgressIndex" also requires that "quantity" be provided as well.

The problem with being forced to provide a quantity is that you risk passing the wrong value. This is especially true if you scale in and out of positions.

By having quantity-less managed Exit(...) orders, you can rely on the NinjaTrader platform properly calculating the proper amount to exit, be it for a specific signal name or for the entire position.

Thank you for voting for SFT-2612,

EquityTrader
EquityTrader 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
ExitLong(int barsInProgressIndex) overload needed gregid Platform Technical Support 9 03-09-2015 02:09 PM
Converting double to Int to use as calculation of share quantity alabell Platform Technical Support 7 08-23-2012 08:36 AM
Enter Long | Double to Int Quantity Issue cfree5119 General Development 3 02-21-2012 09:32 AM
int quantity problem John833 General Development 2 03-05-2010 03:05 PM


All times are GMT -6. The time now is 04:58 PM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.