Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Percent of equity allocation for stocks
Collapse
X
-
Hello johnls101,
You are wanting to modify an existing strategy to allow the strategy to increase the number of contracts (quantity) for the trade as each new trade is placed, is this correct?
In the order submission call, use an int variable. Any time you want to increase the contract quantity increment the variable.
For example:
In #region Variables:
int myQuantity = 1;
if (/* conditions to enter trade */)
{
EnterLong(myQuantity);
}
if (/* conditions to increment quantity */)
{
myQuantity++;
}Chelsea B.NinjaTrader Customer Service
-
Hi Chelsea
Thank you for replying and looking at my request. However, what I am trying to achieve is very much more basic.
As an example, if I had $100,000 total equity, and I had worked out through backtesting that I should allocate 10% equity to each trade, the number of shares would need to be adjusted such that the number of shares x share price <= $10K. I figure that I could subtract the modulus after dividing $10K by the share price to get the highest number of whole shares that would sum to less than $10K. Once I had 10 different trades running (each of 10%), all additional potential trades would fail to initiate until one or more 10% bundle of shares were sold, and more equity freed up.
Unfortunately I don't know how to find what my total equity is and how to allocate 10% to any given share - that is, in an automated way. I am sure that this must have been worked out as equity allocation is such a fundamental requirement for trading shares, but I haven't been able to find it as yet.Last edited by johnls101; 06-23-2016, 04:40 AM.
Comment
-
Hello johnls101,
When backtesting in NinjaTrader 7, I am not aware of any way to get the account cash balance in your strategy.
You could manually create an input that allows you to type in a value of what the cash balance is and then make calculations from there.
Then you would need to write a calculation that calculates how many contracts to place for each order and then use the outcome of that calculation as the quantity amount.
In the Strategy Analyzer, there is the ability to 'Set order quantity' to 'by account size' and set the Account size to a manually entered value. Then NinjaTrader will automatically set the contract size for all orders to the max amount of contracts that can be purchased for the given entered account size.
Below is a link to the help guide on the Strategy Analyzer. Please see the section 'Understanding backtest properties'.
http://ninjatrader.com/support/helpG...a_strategy.htmLast edited by NinjaTrader_ChelseaB; 06-23-2016, 07:48 AM.Chelsea B.NinjaTrader Customer Service
Comment
-
Hi Chelsea
Thanks for the reply.
My major need is implementation (i.e. live trading) rather than back testing as I am using other platforms to back-test.
Please let me know if I have misinterpreted you. However, from what I understand from what you have written, it seems there is no regular or systematic way of managing equity in relation to position size with NinjaTrader. If this is the case, this is a glaring deficiency and should be corrected for both backtesting and live trading. Surely this is not the case?
What happens normally with Ninja in backtesting on say the S&P 500? Does one just test a strategy on 100 shares of everything and is there very heavy weighting of the results towards expensive shares? Is it even feasible to test against the S&P 500? In my experience equity allocation and position size is at least as important as the buy and entry prices to establish system viability.
As I expect total equity to grow relatively slowly in the system I am looking at, in live trading I am thinking that I could approximate equity allocation with a user defined variable for equity that I could alter every few days. I could also define the percentage of equity as a user defined variable and the number of shares for each entity would then be derived as the allocated equity divided by the Close. Is this the way to go when trying to do this live, or is there a more systematic way of doing this? I have a link to Interactive Brokers.
I will see how I go with this and get back to you but I would very much appreciate any other input or suggestions you have.Last edited by johnls101; 07-06-2016, 12:25 AM.
Comment
-
Hello johnls101,
The quantity for each contract would be managed by the logic in your script.
Each programmer may want to write the logic differently. All control of the logic of the strategy is handled with the code within the strategy.
You could use a set quantity for all trades. You could use a slowly increasing quantity as the trades progress. This would all depend on what is written into the strategy to do.
I am also happy to submit a feature request on your behalf to add functionality that would cause NinjaTrader to automatically adjust the contract size of each trade based on a percentage of the account equity size. It is up to the NinjaTrader Development department to decide when and if any request will be implemented.
Would you like to submit this feature request (or one similar)?
When running a strategy in realtime, it is possible to query the account size using GetAccountValue().
http://ninjatrader.com/support/helpG...countvalue.htmChelsea B.NinjaTrader Customer Service
Comment
-
Thanks Chelsea
I would very much like you to submit this as a request on my behalf. From experience the profitability of trend following systems, in particular, seems to increase as percentage equity is increased, and then collapses if this is exceeded. Understanding this is basic to system design. The fact that Ninja has not addressed this suggests that it leaves its customers vulnerable.
There are lots of other ways of addressing position sizing, but a simple percentage of equity is absolute bare minimum. NinjaTrader would do well to look at a whole module on position sizers, but percentage of equity is a basic entrance-level requirement and should be systematised.
As part of the approach, it would be highly desirable to get access to a data series for cumulative equity. When dealing with hundreds of stocks, this can get quite complicated. For instance, should one wait until the end of each day to sum up equity (probably best), or sum it continuously as each share is processed (easier to design, and perhaps one way of obtaining end of day equity anyway).
Thanks ChelseaLast edited by johnls101; 06-29-2016, 03:38 PM.
Comment
-
Hi johnls101,
I've submitted a feature request on your behalf to increase the contract quantity as a percentage of the equity as the equity increases and decrease as the equity decreases.
This request is being tracked with ID #SFT-289. It is up to the NinjaTrader Development to decide when and if a feature request will be implemented.
We do highly value your feedback. Please let me know of any other suggestions or requests you may have.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by login_dejavu, 04-10-2020, 01:49 PM
|
7 responses
194 views
0 likes
|
Last Post
![]()
by markdshark
Today, 06:57 PM
|
||
Started by SheriDi, Today, 06:21 PM
|
0 responses
2 views
0 likes
|
Last Post
![]()
by SheriDi
Today, 06:21 PM
|
||
Started by efeuvejota01, 05-10-2023, 05:34 PM
|
21 responses
153 views
0 likes
|
Last Post
![]()
by bltdavid
Today, 05:17 PM
|
||
Started by Skechers, Yesterday, 05:59 PM
|
4 responses
22 views
0 likes
|
Last Post
![]()
by Skechers
Today, 04:49 PM
|
||
Started by diorfo57, Yesterday, 11:36 PM
|
9 responses
43 views
0 likes
|
Last Post
![]()
by diorfo57
Today, 04:27 PM
|
Comment