![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM 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 |
|
Member
Join Date: Jun 2007
Posts: 72
Thanks: 0
Thanked 0 times in 0 posts
|
I would like to hold a position for half hour at least half hour, how to do that?
Thanks
Last edited by Jenny; 10-11-2007 at 01:53 PM.
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Hi Jenny,
If you are working with the Condition Builder please review the information at the following link regarding time comparisons - http://www.ninjatrader-support.com/H...mparisons.html If you are coding it in the NinjaScript Editor please see the following reference sample - http://www.ninjatrader-support.com/v...ead.php?t=3226 You can also work with the BarsSinceEntry() method to determine how many bars have elapsed.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Jun 2007
Posts: 72
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks for your fast respone.
Take care |
|
|
|
|
|
#4 |
|
Member
Join Date: Jun 2007
Posts: 72
Thanks: 0
Thanked 0 times in 0 posts
|
"BarsSinceEntry()" is a very good, do you have others "BarsSince...." , like
BarsSinceCrossAbove(SMA(5), SMA(10))? Thanks |
|
|
|
|
|
#5 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Member
Join Date: Jun 2007
Posts: 72
Thanks: 0
Thanked 0 times in 0 posts
|
MRO is very cool, but the first one works, the second one doesn't work.
LowBar1 =MRO(delegate {return (CrossBelow(SMA(5), SMA(10), 1));},1, 1440) return some number, but HighBar1 =MRO(delegate {return (CrossBelow(SMA(5), SMA(10), 1));},2, 1440); return nothing, even not a "-1". Would you please tell me why? Thanks
Last edited by Jenny; 10-23-2007 at 04:14 PM.
|
|
|
|
|
|
#7 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
If you mean that it does not work in that it only returns a value of -1, then likely the condition is never met. You will likely spend some time debugging to understand what is happening.
If it does not work in terms of throwing exception (error message in the log tab of the Control Center window) then let me know. Here is some information to help you debug. http://www.ninjatrader-support.com/v...ead.php?t=3418
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Member
Join Date: Jun 2007
Posts: 72
Thanks: 0
Thanked 0 times in 0 posts
|
I already use debug, it return nothing, even not "-1". If never met the condition, it should return "-1". And I can see the condition is met by the chart. Within 1440 bar, SMA(5) Cross over SMA(10) hundreds times! Do you think there is a bug some where?
Thanks |
|
|
|
|
|
#9 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Are you getting any errors in your logs?
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#10 |
|
Member
Join Date: Jun 2007
Posts: 72
Thanks: 0
Thanked 0 times in 0 posts
|
No error either. Can you do some test in your side?
Thanks
Last edited by Jenny; 10-23-2007 at 08:02 PM.
|
|
|
|
|
|
#11 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Sure Jenny.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#12 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
After some tests there is nothing wrong with the MRO. Please check out the reference sample I've attached. Try running it on your end. You should see two plots like how it looks in the attached image.
I suspect it to be a bug in your code somewhere since there seems to be no issue with this simple-as-possible indicator using MRO. To install the reference sample please follow these steps:
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#13 |
|
Member
Join Date: Jun 2007
Posts: 72
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks for your sample. It looks work in the indicator, but how come when I try to use it in my Strategy, it doesn't work.:
HighBar1 =MRO(delegate {return (CrossBelow(SMA(5), SMA(10), 1));},2, 1440); Take care |
|
|
|
|
|
#14 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
In the indicator I used your exact line of code. You are going to need to debug your code to see where it is failing. I suspect you probably placed the line within an if statement that is never executed. Thus causing your HighBar1 to never be set.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 1st Hour High/Low | pijamatrader | Indicator Development | 42 | 07-16-2007 05:31 PM |
| OHLC for non-midnight 24 hour market | StinkiePhish | Indicator Development | 1 | 07-12-2007 11:07 PM |
| V 5.1.1.1 Beta Problem - hold button reverses buy/sell columns | dynosaratoga | Installation and Licensing | 7 | 02-17-2006 03:29 AM |