![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Apr 2009
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
I wish to calculat the Avearge - ATR for the last 7 days from inside a strategy.
it is mulitframe, the primary bars are intraday - 89 tick so i would: Add(PeriodType.Minute,60); Then i want to get the average value for the ATR for the last 7 days - convet it into ticks and use it to set my targets dynamically... |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
This can be done through custom programming. There are several threads discussing using ATR for trailing stops and things like that. Please take a look at them and see if they help you.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Apr 2009
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
I have had a look at quite a few and inspected the code -and drew a blank - as they are mostly indicators and the such like - all i want is a pattern/ method to obtain the ATR for the last 7 days... as a tick value.
I will keep looking |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Not sure what you mean "tick value". ATR will come out as some range value as determined by the high - low calculation for the various days.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Apr 2009
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
essentially i wish to get the number of ticks an instrument moves per day - using the last 7 days as the period - but calculate it from a intraday period (so it can achieved in a intrady stratefy)...
Eg. last 7 day ES was 20 points per day or 80 ticks i can use the 80 ticks as the basic tradeable oppurtunity. i thought ATR migh assist in this - maybe i need to look at another pattern
Last edited by tomleeson; 07-21-2009 at 03:20 PM.
|
|
|
|
|
|
#6 |
|
Member
Join Date: Apr 2009
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
i found this:
http://www.ninjatrader-support2.com/...e+Range&page=2 somevalue= (ATR(14)[1] * 0.25) * 100); i believe the * 100 is there to convert it to to a number versus degrees? what is the 0.25 (ticks?) |
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
|
Tom, what you outlined in your first post would work, but the larger timeframe must be the primary instrument.
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#8 | |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
|
Quote:
In addition, there is a helpful function in NinjaTrader that rounds a value to the nearest tick size. Here is the reference page for Round2TickSize.
Austin
NinjaTrader Customer Service |
|
|
|
|
|
|
#9 |
|
Member
Join Date: Apr 2009
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks for your replies:
The smaller time has to be the primary. The system has been tested with a weekly atr average value. NT strategy wotn allow me to mix intrady series with weekly series - so i guess i will have to count evrery bar and take an average for each 7 day period.. or create it on another chart and then commuicate this to the running strategy module..:-) through a common static class, a data cache, or maybe even post via a windowsmessage...:-) |
|
|
|
|
|
#10 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
tomlesson,
NT for sure does allow you to mix intraday with weekly. You just need to ensure you reach the min. bars required requirement on all bar series. By default this means you need 20 bars which would be a lot of time to achieve 20 weekly bars.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
|
Tom, I wasn't sure of your programming skills, so I didn't suggest anything too complicated from the start.
You can try this: run your ATR calculations from a daily chart, and then have your strategy communicate with that daily chart to retrieve the values. Here is a reference sample that demonstrates how to expose indicator values. The sample includes a strategy and an indicator--they work together and are a great example.
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#12 |
|
Member
Join Date: Apr 2009
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
yes i think i can see how that would work :-)
|
|
|
|
|
|
#13 | |
|
Member
Join Date: Apr 2009
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
thank you! |
|
|
|
|
|
|
#14 |
|
Member
Join Date: Apr 2009
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
the default of 20 - can i change that programmatically? is that set when the strategy is added to a chart?
|
|
|
|
|
|
#15 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
BarsRequired = 20;
It can also be set via the UI when you add a strategy.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Atr Stop | Anthero2000 | Strategy Development | 3 | 06-01-2009 11:03 AM |
| Weighted ATR | badasan | Indicator Development | 1 | 03-28-2009 12:02 PM |
| ATR Indicator | playafh69 | Indicator Development | 1 | 01-01-2009 10:28 PM |
| ATR plot | cptrader | Indicator Development | 3 | 12-29-2008 09:28 AM |
| ATR Stop | ATI user | Strategy Development | 8 | 09-29-2008 10:12 AM |