![]() |
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
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Jul 2011
Posts: 35
Thanks: 9
Thanked 1 time in 1 post
|
Hi,
i want to test some intraday strategies using the ATR indicator. However the ATR is based on the Input series but i want to have a daily ATR independent of the input series. Ok my idea was to use the the values of the PriorDayOHLC and adjust the Standard ATR indicator. I changed some stuff but it doesnt seem to work, even on the daily chart the graph looks similar but the absolute values are quite different. |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
Welcome to our forums - looking at your code you would then still take the averaging on the minute bars series, resulting in a much lower average being used than if you worked on a daily chart.
You could add the daily / 1440 min series in the NinjaScript indicator and run your calculations on this added series - http://www.ninjatrader.com/support/h...nstruments.htm
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Jul 2011
Posts: 35
Thanks: 9
Thanked 1 time in 1 post
|
thank you Bertrand,
i created the ATRdaily indicator by adding the line of code. i implemented / found some code to use a fraction of the ATR as a stop loss, it seems to work on the long side but when short orders are executed they are instantly stopped out.
Last edited by markus1000; 01-26-2012 at 12:25 PM.
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi Markuss,
Thank you for sharing the script. Likely this section is contributing. Code:
if(Position.MarketPosition==MarketPosition.Flat)
{
SetStopLoss("",CalculationMode.Price,1,false);
}
It's good to use this style of resetting when flat, but you may want to change to mode ticks and choose a static value, so that the order would always be accepted no matter the market direction. Your dynamic controls for the order would take over right away so this initial placement will mainly go unnoticed. Code:
if(Position.MarketPosition==MarketPosition.Flat)
{
SetStopLoss("",CalculationMode.Ticks, 20, false);
}
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Jul 2011
Posts: 35
Thanks: 9
Thanked 1 time in 1 post
|
ok there still seems to be a problem with the ATR.
Just as a reminder, i want to use the 5 day ATR (based on yesterdays closing price) as an indicator in a intraday strategy. OK i attached an screenshot with the indicator plotted on several timeframes Timeframes: 1min, 60 min and daily. Indicators: ATRday uses 420 minutes (RTH Session) ATRdaily uses 1140 min ATR is the standard Ninja indicator Charts: In a perfect world, the ATRdaily should print the same ATR value no matter what time frame TOP right and buttom right show the same dates, but the values are not similar The indicator isnt even accurate in the daily setting (looks like the ATRdaily is a lagged version of the orginal indictor) |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
This custom indicator you're using is not developed by NinjaTrader, so unfortunately we can't comment on its expected values or comparisons with the standard ATR. If you've identified an indicator you would prefer to use rather than the custom one you found, there's nothing stopping you from using it in your strategy.
If you have specific requirements on developing your strategy, you may consider discussing with one of our NinjaScript consultants, who can work with you to code to your exact specifications. http://www.ninjatrader.com/partners#...pt-Consultants
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Member
Join Date: Jul 2011
Posts: 35
Thanks: 9
Thanked 1 time in 1 post
|
i want to use the standard 5 day ATR in an intraday strategy, a multitimeframe ATR so to speak. but it doesnt seem possible without changing the code
![]() Charting is not the problem, but that doesnt help when backtesting a strategy
Last edited by markus1000; 01-27-2012 at 12:20 PM.
|
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
You can add a daily series to your script, and then calculate 5 day ATR on this series.
In Initialize(): Code:
Add(PeriodType.Day, 1); Code:
double myATR = ATR(Closes[1], 5)[0];
Ryan M
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Input Series of An Indicator | dkrumholz | Indicator Development | 5 | 04-24-2011 12:08 PM |
| Indicator Input Series | gregschr | General Programming | 3 | 02-01-2011 01:53 PM |
| Multiple Data Series with different Indicator Input series | marotom | General Programming | 5 | 01-06-2011 12:11 PM |
| Add daily series to minute series | binwang2 | General Programming | 4 | 04-06-2009 08:56 AM |
| Input Series For Indicator | CraigC | Indicator Development | 7 | 06-28-2008 03:58 AM |