NexusFi: Find Your Edge


Home Menu

 





Newbie question about ATR


Discussion in NinjaTrader

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




 
Search this Thread
  #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?
Bookmap Global Plus Lifetime + Lifetime Addons For Sale
Platforms and Indicators
One Wallet Made $200K in Hours: AP Probes Polymarket Cea …
Prediction Markets & Event Contracts
Saylors 41-Month HODL Breaks: Strategy Sells 32 BTC as $ …
Prediction Markets & Event Contracts
CME Launches Bitcoin Volatility Futures June 1 -- First …
Cryptocurrency
Kharg Island at 6%, Regime Fall at 1.5% -- The Black Swa …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #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


© 2026 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 - Downloads - Top
no new posts