Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
number of shares
Collapse
X
-
number of shares
I've just started Auto trading using IB. I'm having a problem with the strategy executing the correct number of shares. It seems there are several places this number can be set and I'm probably missing one I need to consider. Longer term I need to code so that the strategy enters a consistant dollar amount of shares like #Shares=5000/Last Price, but for now I don't know C+ so I have to calculate the number by hand each morning when I enter the strategy based on the previous close which will roughly give me what I want. So in the Strategy Wizard I set a User Defined Input called Shares with a default of 10 and a minimum of 1. On the Conditions and Actions page /Parameters /Quantity>User Defined Inputs > selected Shares which shows after exiting as EnterLong(Shares,""). Then when setting up the Strategy before the market I select New Strategy in the Control Center window, set the value of "Shares" under Parameters to my calculated number, adjust other settings as needed and put "Set order quantity" to "by strategy" -- should this give me the desired number of shares or will my entry here be overpowered by something somewhere else? Today I had two trades go at 1 share each rather than the expected number, but I'm not sure I had everything set up as described at that point. Just want to know what will happen on the next signal. Thx.Tags: None
-
Thanks -- looks like it worked right with a later signal. When I set up in the morning I want to set up the Strategy, have it execute thru IB and record the trades on a chart as well as in the Control Center. My impression is that if I set up in the Control Center I will not have the chart text and markings. If I set up the strategies on the charts so as to get these I won't have to do anything else -- is that right?
Comment
-
I don't know if this is accurate but it seems to me that if one could use a variable rather than a user defined input to set the number of shares then maybe I could define the variable as say 5000/Last to have my strategy buy $5000 worth of stock. That would give us non-code folks a way to work this -- seemed from the board like there was some interest in this sort of position sizing. Is there a chance this option could be added?
Comment
-
bkout,
What you are trying to do is doable via coding. There is no way around it. You make yourself a variable. Store in 5000/Close[0]. Cast this variable into an integer and then use it for quantity when you call your EnterLong().
Code:someVariable = 5000 / Close[0]; EnterLong((int) someVariable);
Josh P.NinjaTrader Customer Service
Comment
-
position sizing based on dollar amount
After weeks of calculating my share numbers for a given dollar position using another program and then entering it by hand I found that this can be done in Ninja without having to do code as this thread said I would have to. See: http://www.ninjatrader-support2.com/...osition+sizing
Comment
-
Since my systems don't typically trade more than once or twice a day the change from P&L in Account size are not a problem and using this method is much easier than having to go to an extenal sourse to do share size calculations. Now next question -- is there a way to build a certain Account size into a strategy (and have it bring up the Account size methodology by default) rather than have to set it each time the strategy is re-started? Again I know all this could be done by code but since I don't know the code I'm looking for the easiest workaround.
Comment
-
Checking on something. If I managed to have some kind soul tell me where and how to drop that account size line into the strategy code, is it correct that from that point on I could only make any changes by code changes and would not be able to use the wizard? BTW for the "wish list" -- I often want to do another version of a strategy with just a minor change. Rather than have to do a lot of cutting and pasting in creating a new strategy it would be great to be able to create an instant clone of the Strategy (say "Strategy1") and then go edit it.
Comment
-
bkout,
Making any code changes would require you to unlock the code and that means being out of the Wizard.
If you want to make a copy of a strategy do this:
1. Open the original in the Wizard.
2. Press View Code
3. Right click -> Save As -> type in a new name
4. Close NinjaScript Editor
5. Open the new file in the WizardJosh P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ScottW, Today, 06:09 PM
|
0 responses
2 views
0 likes
|
Last Post
by ScottW
Today, 06:09 PM
|
||
Started by Board game geek, 10-29-2023, 12:00 PM
|
14 responses
244 views
0 likes
|
Last Post
by DJ888
Today, 05:38 PM
|
||
Started by Waxavi, 04-19-2024, 02:10 AM
|
4 responses
56 views
0 likes
|
Last Post
by sonia0101
Today, 04:02 PM
|
||
Started by cmtjoancolmenero, Today, 03:58 PM
|
0 responses
9 views
0 likes
|
Last Post Today, 03:58 PM | ||
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
11 responses
1,778 views
0 likes
|
Last Post
by aligator
Today, 03:54 PM
|
Comment