NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > Application Technical Support > Miscellaneous Support

Miscellaneous Support Miscellaneous support issues.

Reply
 
Thread Tools Display Modes
Old 11-23-2008, 10:25 PM   #1
vote4pedro
Junior Member
 
Join Date: Nov 2008
Posts: 9
Thanks: 0
Thanked 0 times in 0 posts
Default Auto determine shares based on price

Greetings,

As an investment strategy I determine the number of shares to purchase based on a fixed percentage of my portfolio divided by the current market price.

Example: (percentage x total portfolio) / price = #shares to purchase

Is there a feature to specify a dollar amount in the order quantity field that will automatically determine the # shares based on the current price?

If not, then perhaps there might be some creative way to at least display the calculated "# of shares" value associated with a symbol, somewhere else for reference purposes? I'm not familiar with NinjaScript but if it can allow simple calculations I would think a custom indicator can be built and added as a new column in the Market Analyzer window to handle this?

Thanks!
vote4pedro is offline  
Reply With Quote
Old 11-24-2008, 07:27 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Change your strategy to run "by account size" in the "Set order quantity" option when you first start up your strategy.
NinjaTrader_Josh is offline  
Reply With Quote
Old 11-25-2008, 12:51 PM   #3
vote4pedro
Junior Member
 
Join Date: Nov 2008
Posts: 9
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks Josh,

As I understand it the solution you provided is for fully automated orders. My intention is to use this feature with manual or semi-auto (ATM) orders. My hope is after selecting an instrument and ATM strategy in the order bar the qty field is automatically updated according to the formula mentioned previously.

The next best solution would be to have a custom column in the Market Analyzer, with the calculated qty's for each instrument row that I can reference when manually entering an order.

Are either of these solutions possible?

Thanks!
vote4pedro is offline  
Reply With Quote
Old 11-30-2008, 04:18 PM   #4
vote4pedro
Junior Member
 
Join Date: Nov 2008
Posts: 9
Thanks: 0
Thanked 0 times in 0 posts
Default

Still waiting for a response if there is a means to have the "quantity" field auto determine shares based on price using manual orders but I figured out the next best thing...

I made a simple custom indicator that calculates the shares based on last price and portfolio size as an input, then included it as a column in the Market Analyzer. Now I can easily reference the desired share quantity for each symbol when manually placing an order. It would be awesome if I could somehow link that column to the order entry quantity field when selecting a symbol row.
vote4pedro is offline  
Reply With Quote
Old 12-01-2008, 07:11 AM   #5
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Pardon the delay. To do what you want is just a matter of custom programming based off of AccountSize. You want to keep track of PnL to determine your most recent buying power given a certain starting account size. Then run your logic to determine what quantity you want to submit at.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-07-2009, 01:57 PM   #6
bkout
Senior Member
 
Join Date: Dec 2008
Location: Austin, TXs
Posts: 111
Thanks: 9
Thanked 0 times in 0 posts
Default

I would like to change several of my strategies from purchasing a fixed number of shares to trading a number of shares based on the dollar value of the position. Let's say I want to always initiate positions with $5000. worth of stock -- how do I do that? Poking around the message boards gives me the feeling that "by account size" is involved -- can I do that in some way as an edit rather that having to re-create the strategies? Can you point me to the step-by- step process? I don't know how to do programming. Thx.
bkout is offline  
Reply With Quote
Old 01-07-2009, 02:07 PM   #7
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

You will most likely need to adjust programming. "By account size" will not necessarily work because after the first trade your account size is no longer $5000.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-07-2009, 10:06 PM   #8
bkout
Senior Member
 
Join Date: Dec 2008
Location: Austin, TXs
Posts: 111
Thanks: 9
Thanked 0 times in 0 posts
Default

Hmm, maybe I'm off base by thinking that's the starting point. It's not that I want to put the whole account into a trade. It's that I want to trade several different systems (eventually automatically) with the same $ position in each system -- say 3 $5000. positions in a $25K account. How can I do this? Hopefully without having to write code since I don't know how.
bkout is offline  
Reply With Quote
Old 01-08-2009, 06:09 AM   #9
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
Default

This would indeed require some custom coding, please take a look at this thread here - http://www.ninjatrader-support2.com/...t=12252&page=2

Accessing brokerage account values is not supported in NinjaTrader 6.5, but it will be in our upcoming NinjaTrader 7 release.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 01-08-2009, 08:30 AM   #10
bkout
Senior Member
 
Join Date: Dec 2008
Location: Austin, TXs
Posts: 111
Thanks: 9
Thanked 0 times in 0 posts
Default

So in the strategy setup if I "Set order quantity" "by strategy" where do I
build that specification into the strategy? I want something like:
number of shares = 5000/last price
bkout is offline  
Reply With Quote
Old 01-08-2009, 08:37 AM   #11
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

If you set it "By strategy" it takes whatever you are submitting your order quantity at. You build it anywhere you want. When you call EnterLong() you specify the quantity you want to buy.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-08-2009, 09:15 AM   #12
bkout
Senior Member
 
Join Date: Dec 2008
Location: Austin, TXs
Posts: 111
Thanks: 9
Thanked 0 times in 0 posts
Default

So the line reads:
EnterLong(Shares, "")
Where Shares is listed on the User Defined Input page as type int, Default 100 and Min 1.
Where can I define the number of shares as 5000/last price? Would I have to create this as a variable which would then be accessed byt the EnterLong command??? Sorry that I don't know the code but I'm hoping to be able to blunder thru this to get what I want
bkout is offline  
Reply With Quote
Old 01-08-2009, 09:19 AM   #13
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Yes you need to create a variable and set its value. You need to be outside of the Wizard for this.

Code:
Shares = 5000 / Close[0];
NinjaTrader_Josh 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
price channels based on the CLOSE zq655 Charting 5 01-08-2008 10:52 PM
Strategy based on indicator value, not price? cassb Strategy Analyzer 2 12-19-2007 06:44 AM
coloring indicator based upon price parameters Thomas Indicator Development 10 08-28-2007 11:44 AM
Use Last Price for Auto Trail Checkbox pivot44 Miscellaneous Support 1 06-07-2006 11:00 AM
Stops based on price vs. increments. rmmsmh Miscellaneous Support 5 05-09-2005 12:11 AM


All times are GMT -6. The time now is 01:19 PM.