![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Sep 2007
Posts: 99
Thanks: 0
Thanked 0 times in 0 posts
|
How can I check in a Ninjascript strategy, to see if a certain profit level has been reached, and then have the strategy stop?
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
We have seriously enhanced the area of accessing performance data in a strategy with our upcoming NT 6.5. What you want to do can be accomodated in this release. We expect beta next week sometime.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Sep 2007
Posts: 99
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Ray,
Can I test Beta version, and be notifyed when available? Jim |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Yes, we will provide public access to the beta software when available.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Sep 2007
Posts: 99
Thanks: 0
Thanked 0 times in 0 posts
|
is this beta version on target to be released this week?
|
|
|
|
|
|
#6 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Yes, that is what we are shooting for.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Member
Join Date: Jun 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
|
This will be a serious enhancement. Can you tell us how to access it? Let's say we want to measure the current P/L in ticks, the max adverse excursion in ticks and the max favorable excursion in ticks and set each equal to a user variable. What would be the code to call the P/L this bar, MAE and the MFE?
Thanks, dendy. |
|
|
|
|
|
#8 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
When the beta is out, it will come with documentation that will answer your questions.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Member
Join Date: Jun 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Ray,
Will the Beta version be announced just like one of the regular versions (on program start-up)? Or will it be announced only on the website somewhere. Thanks, dendy. |
|
|
|
|
|
#10 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
It will be announced in the 6.5 Beta section of this forum to start.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Member
Join Date: Jun 2007
Posts: 79
Thanks: 0
Thanked 0 times in 0 posts
|
I see.
Thanks, dendy. |
|
|
|
|
|
#12 |
|
Member
Join Date: Sep 2007
Posts: 99
Thanks: 0
Thanked 0 times in 0 posts
|
I have 6.5 installed and am back to my original question:
How can I check in a Ninjascript strategy, to see if a certain profit level has been reached, and then have the strategy stop? |
|
|
|
|
|
#13 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Please see the Help Guide section Strategy Performance Methods. We will post reference samples in this area in the coming weeks.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#14 |
|
Member
Join Date: Sep 2007
Posts: 99
Thanks: 0
Thanked 0 times in 0 posts
|
Will this coding do what I want?
Stop the strategy from running once I have achieved a net realized profit of at leat $100? // If the profit on real-time trades is > $100 stop trading if (Performance.RealtimeTrades.TradesPerformance.Curr ency.CumProfit > 100) return; |
|
|
|
|
|
#15 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
To be technically accurate:
- If you include that code in any public event driven method (such as OnBarUpdate()) it will return from that method. Thus, if its the first line in that method, it will no longer process your code underneath that condition check. - So if you only have strategy order logic in OnBarUpdate(), you could add that line of code and prevent any further processing of this method. It will not stop your strategy from running but it will do what you want. - If you want to terminate the strategy (remove it from a chart its running etc..) you can set the strategy "Running" property to "false". // If the profit on real-time trades is > $100 stop trading if (Performance.RealtimeTrades.TradesPerformance.Curr ency.CumProfit > 100) Running = false;
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Calling an ATM Strategy Within NinjaScript | Jim-Boulder | Strategy Development | 5 | 08-26-2010 02:54 AM |
| Ninjascript Columns | svrz | Market Analyzer | 5 | 05-26-2007 06:01 PM |
| NinjaScript Strategy Orders | ThePatientOne | Automated Trading | 1 | 05-25-2007 11:11 AM |
| NT6 NinjaScript Vs NT5 | underground | Indicator Development | 2 | 11-22-2006 05:44 AM |
| Using DLL's in NinjaScript | SigmaTrader | Indicator Development | 5 | 09-24-2006 04:23 PM |