NexusFi: Find Your Edge


Home Menu

 





Newbie question about ATR


Discussion in NinjaTrader

Updated
    1. trending_up 1,293 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread

Newbie question about ATR

  #1 (permalink)
Schopenbauer
Antwerp
 
Posts: 3 since Nov 2014
Thanks Given: 0
Thanks Received: 0

Hi,

I'm creating an indicator that calculates the 10 day ATR + 30 day ATR divided by 2.

However, when I apply it to my chart, it gives the ATR of the last 10 (30) sessions (minute bars).

How do I specify that I don't want it to be the last 10 (30) minute bars but rather the last 10 (30) day bars?

EDIT: this should actually be in the ninjascript subforum, can anyone move it please?

Kind regards

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
REcommedations for programming help
Sierra Chart
Cheap historycal L1 data for stocks
Stocks and ETFs
Better Renko Gaps
The Elite Circle
ZombieSqueeze
Platforms and Indicators
 
  #2 (permalink)
EnsoTrader
Durham, NC
 
Posts: 48 since Oct 2014
Thanks Given: 0
Thanks Received: 21

Is your chart showing 30min bars?

Could you post some of your code?


You need to make sure the dataseries that the ATR is working on is set to Day.
So, either you need to make sure your chart is showing Days or add a new series in your indicator that establishes Day data.

Reply With Quote
  #3 (permalink)
Schopenbauer
Antwerp
 
Posts: 3 since Nov 2014
Thanks Given: 0
Thanks Received: 0



EnsoTrader View Post
Is your chart showing 30min bars?

Could you post some of your code?


You need to make sure the dataseries that the ATR is working on is set to Day.
So, either you need to make sure your chart is showing Days or add a new series in your indicator that establishes Day data.

So I have this code:

protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "A"));
Overlay = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
A.Set(0.10*(ATR(10)[0]+ATR(30)[0])/2);
}

And I want my chart to show minutes. How do I add a new series?

Reply With Quote
  #4 (permalink)
 damerci 
Hamburg
 
Experience: None
Platform: NinjaTrader, TWS
Broker: NinjaTraderBrokerage + Continuum, IB
Trading: Futures, Stocks
Posts: 7 since Jun 2014
Thanks Given: 2
Thanks Received: 3

You have to calculate your indicator in secand dataseries (day data)

Try this:

 
Code
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "A"));
Add(PeriodType.Day, 1);
Overlay = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{

if (BarsInProgress == 1) 
{
A.Set(0.10*(ATR(10)[0]+ATR(30)[0])/2);
}

}

Reply With Quote
  #5 (permalink)
Schopenbauer
Antwerp
 
Posts: 3 since Nov 2014
Thanks Given: 0
Thanks Received: 0


damerci View Post
You have to calculate your indicator in secand dataseries (day data)

Try this:

 
Code
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "A"));
Add(PeriodType.Day, 1);
Overlay = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{

if (BarsInProgress == 1) 
{
A.Set(0.10*(ATR(10)[0]+ATR(30)[0])/2);
}

}

This only shows the graph when I switch to day period, when I'm on minute period it doesn't show anything. Do I need to store the ATR value of each month or something?

I need to calculate the ATR values on the day series but want to use it in the minute series...

Reply With Quote
  #6 (permalink)
EnsoTrader
Durham, NC
 
Posts: 48 since Oct 2014
Thanks Given: 0
Thanks Received: 21

Try this:

 
Code
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "A"));
Add(PeriodType.Day, 1);
Overlay = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{

	if ( CurrentBars[1] < BarsRequired )
		return;
			
	A.Set( (ATR(BarsArray[1], 10)[0] + ATR(BarsArray[1], 30)[0]) / 2 );

}

Reply With Quote




Last Updated on November 12, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts