NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 01-26-2012, 03:04 AM   #1
markus1000
Member
 
Join Date: Jul 2011
Posts: 35
Thanks: 9
Thanked 1 time in 1 post
Default Daily indicator, Minute Input Series (Beginner question)

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.
Attached Files
File Type: zip DailyATR.zip (4.5 KB, 7 views)
markus1000 is offline  
Reply With Quote
Old 01-26-2012, 03:09 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

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
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 01-26-2012, 12:23 PM   #3
markus1000
Member
 
Join Date: Jul 2011
Posts: 35
Thanks: 9
Thanked 1 time in 1 post
Default

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.
Attached Files
File Type: zip ATRStop.zip (8.0 KB, 7 views)
Last edited by markus1000; 01-26-2012 at 12:25 PM.
markus1000 is offline  
Reply With Quote
Old 01-26-2012, 01:09 PM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi Markuss,

Thank you for sharing the script. Likely this section is contributing.

Code:
if(Position.MarketPosition==MarketPosition.Flat)
{
   SetStopLoss("",CalculationMode.Price,1,false);   
}
Since stop orders are sensitive to their value relative to market, this could work on the long side but not the short.

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);   
}
NinjaTrader_RyanM is offline  
Reply With Quote
Old 01-27-2012, 03:37 AM   #5
markus1000
Member
 
Join Date: Jul 2011
Posts: 35
Thanks: 9
Thanked 1 time in 1 post
Default

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)
Attached Images
File Type: jpg Clipboard02.jpg (168.1 KB, 9 views)
Attached Files
File Type: zip ATRDaily.zip (4.5 KB, 7 views)
markus1000 is offline  
Reply With Quote
Old 01-27-2012, 07:36 AM   #6
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

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
NinjaTrader_RyanM is offline  
Reply With Quote
Old 01-27-2012, 12:17 PM   #7
markus1000
Member
 
Join Date: Jul 2011
Posts: 35
Thanks: 9
Thanked 1 time in 1 post
Default

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.
markus1000 is offline  
Reply With Quote
Old 01-27-2012, 12:32 PM   #8
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

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);
In OnBarUpdate()
Code:
double myATR = ATR(Closes[1], 5)[0];
There is a sample multiseries script in all installation for reference on this. Click Tools > Edit NinjaScript > Strategy > SampleMultiTimeFrame.
NinjaTrader_RyanM is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 11:47 AM.