![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jan 2008
Posts: 1
Thanks: 0
Thanked 0 times in 0 posts
|
Does anyone know how to program NT so that when you backtest a system Ninjatrader recalculates the No. of contracts for each entry based on your current account size, % of account risked and your stop loss.
For example I trade with an account > size of say $100,000 but only use a percentage of this per trade say > 5% or $5000. To calculate the no of contracts traded for the Emini ES > at $50/point and say 7pt stop loss with 5% of $100,000 = 5000/(7x50) > which approximately equals 14 contracts. (I guess the calculation has > to round down to the nearest integer too)! As my account goes up, so > should the No. of contracts traded which compounds your account. How do I do this? > Thanks in advance > > Clive
Last edited by clivehunt; 02-05-2008 at 09:19 AM.
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
You would have to code your math logic in NinjaScript and calculate the "quantity" value which you could shift into the various Enter... methods.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Jun 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
|
Hello Dierk and thanks to clivehunt for the question.
What would be the basic command for calling up the present account value so that it could be used in the way that clivehunt suggests. The account value would change after every trade and so the number of contracts would be adjusted accordingly per the math used. I use Interactive Brokers and NT 6. Thanks, dendy. |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
You can use AccountSize along with Performance to get what you want.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 | |
|
Member
Join Date: Jun 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Josh for the reply,
From what I can tell, AccountSize will not give the Account Value but only allow one to specify the value as such: Quote:
Are you suggesting that this value cannot be obtained and by manually entering the AccountSize I can still calculate my values without NT6 automatically calculating my lot size for me based upon my entered margin requirements. Thanks again for the help. dendy. |
|
|
|
|
|
|
#6 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Pulling in the actual account value is not supported at this time.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#7 | |
|
Member
Join Date: Jun 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks for the response Ray,
Do the following Perfomance commands work for the current NT6 session only? (I'm defining session as the time between NT6 start-up and shut-down.) Let's say we start NT6 in the morning and lose $1000 on short trades and make $1500 on long trades, will the "Performance.AllTrades.Performance.Currency.CumPro fit" give the Cumulative Profit for the day only as $500? Does it care if the orders were entered by a strategy or manually or from the DynamicSuperDOM? Quote:
dendy. |
|
|
|
|
|
|
#8 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
PnL relative to the strategy only and for the history of the strategy. If it only contained real-time trades then it would be for real-time only of course.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Member
Join Date: Jun 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Ray,
I think that what you're saying is that any trade made during the time the strategy is running will be picked up by these "Performance" commands and used in the strategy. Is there any way to make the "Performance" command only work for the trades entered by the strategy in which it resides? For example, I'm running a real time strategy (using real money) with the "Performance" command for Cumulative Profit. I then start up a strategy analyzer and run another strategy against historical data. This back tested strategy produces significant income. Does this back tested run have to impact the real time strategy's "Performance" command, or is there some way to insulate the strategy so that it does not pick up this other data? Thanks, dendy. |
|
|
|
|
|
#10 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Thats not what I am saying. What you want is how it works. Only trades generated by the strategy are included.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Member
Join Date: Jun 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks again Ray,
I believe it is clear to me now. dendy. |
|
|
|
|
|
#12 |
|
Junior Member
Join Date: Jul 2008
Posts: 16
Thanks: 0
Thanked 0 times in 0 posts
|
Hi,
I have a question about: Performance.RealtimeTrades.TradesPerformance.Curre ncy.CumProfit Suppose in Week 1, I first started running Strategy A on EURUSD, GBPUSD, USDCHF and USDJPY at the same time. At any time the above code is called, can I confirm that the cumulative profits is that of the realised profits/losses arising from Strategy A of the four pairs combined? At the end of Week 1, I closed NinjaTrader and switched off my computer. At the start of Week 2, I powered up my computer, opened NinjaTrader and continued running Strategy A on EURUSD, GBPUSD, USDCHF and USDJPY. Can I confirm that the above code will include cumulative profits of both Week 1 and Week 2? |
|
|
|
|
|
#13 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
No, you would need to leave your strategy running to keep performance of your realtime trades accurate. Performance is NOT recalculated from the historical trades as you restart the strategy.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#14 |
|
Junior Member
Join Date: Jul 2008
Posts: 16
Thanks: 0
Thanked 0 times in 0 posts
|
Hi Dierk,
Thanks for your reply. With regards to the situation when Strategy A is run across four currency pairs, Performance will be the cumulative realised profits of all four pairs? |
|
|
|
|
|
#15 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
That is correct.
Dierk
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Account Size - Safety Measure | funk101 | Strategy Development | 7 | 04-28-2008 02:50 PM |
| Account Size / Set Account Programatically | VagyokC4 | Strategy Development | 1 | 09-20-2007 11:40 AM |
| Last Size | MrBaffalo | Indicator Development | 2 | 07-09-2007 07:02 AM |
| Looking for mechanism to scale down size based on performance | scriabinop23 | Strategy Development | 11 | 05-16-2007 01:04 PM |
| Stop Loss Size | JohnnyB | Suggestions And Feedback | 0 | 07-21-2005 04:04 AM |