NexusFi: Find Your Edge


Home Menu

 





daily 5-day-SMA on 5-minute chart.


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one tranta with 4 posts (2 thanks)
    2. looks_two Tasker_182 with 3 posts (2 thanks)
    3. looks_3 Fat Tails with 2 posts (8 thanks)
    4. looks_4 kronie with 1 posts (0 thanks)
      Best Posters
    1. looks_one Fat Tails with 4 thanks per post
    2. looks_two Silvester17 with 3 thanks per post
    3. looks_3 trendisyourfriend with 2 thanks per post
    4. looks_4 Tasker_182 with 0.7 thanks per post
    1. trending_up 10,082 views
    2. thumb_up 19 thanks given
    3. group 6 followers
    1. forum 15 posts
    2. attach_file 8 attachments




 
Search this Thread

daily 5-day-SMA on 5-minute chart.

  #1 (permalink)
 
tranta's Avatar
 tranta 
Česká republika
 
Experience: Beginner
Platform: NT
Trading: Forex
Posts: 5 since Nov 2012
Thanks Given: 4
Thanks Received: 1

Hi, Im trying code daily 5-day-SMA on 5-minute chart, but it doesnt work, it doesnt show anything on 5minChart
could anybody help me please?

Log:
28.1.2014 16:18 Default Error on calling 'OnBarUpdate' method for indicator 'DenniSMA' on bar 1: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

Code:

#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
#endregion

/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(PeriodType.Day, 1);
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Overlay = true;
}

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

{ if(CurrentBar < 1)
return;


// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(SMA(Closes[1], 5)[0]);
}

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Increase in trading performance by 75%
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
REcommedations for programming help
Sierra Chart
ZombieSqueeze
Platforms and Indicators
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
33 thanks
Tao te Trade: way of the WLD
24 thanks
My NQ Trading Journal
14 thanks
HumbleTraders next chapter
11 thanks
GFIs1 1 DAX trade per day journal
11 thanks
  #3 (permalink)
 
Tasker_182's Avatar
 Tasker_182 
Cedar Rapids, iowa
Legendary Market Wizard
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Posts: 716 since Aug 2009
Thanks Given: 476
Thanks Received: 1,401



tranta View Post
Hi, Im trying code daily 5-day-SMA on 5-minute chart, but it doesnt work, it doesnt show anything on 5minChart
could anybody help me please?

Log:
28.1.2014 16:18 Default Error on calling 'OnBarUpdate' method for indicator 'DenniSMA' on bar 1: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

Code:

#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
#endregion

/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(PeriodType.Day, 1);
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Overlay = true;
}

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

{ if(CurrentBar < 1)
return;


// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(SMA(Closes[1], 5)[0]);
}

Do you have enough days back loaded on your base dataseries. You will need several days back to load.

Be yourself; everyone else is already taken. Oscar Wilde
Reply With Quote
  #4 (permalink)
 
tranta's Avatar
 tranta 
Česká republika
 
Experience: Beginner
Platform: NT
Trading: Forex
Posts: 5 since Nov 2012
Thanks Given: 4
Thanks Received: 1


Tasker_182 View Post
Do you have enough days back loaded on your base dataseries. You will need several days back to load.

50 days back

Started this thread Reply With Quote
  #5 (permalink)
 
Tasker_182's Avatar
 Tasker_182 
Cedar Rapids, iowa
Legendary Market Wizard
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Posts: 716 since Aug 2009
Thanks Given: 476
Thanks Received: 1,401


tranta View Post
50 days back

There is an easier way than writing an indicator to do this. Here is what i did for the chart below.

1) Created new chart with 50 days of 5 minute data.
2) Added another data series, daily, 50 days
3) for the daily data series change the following: (see picture)
A) Set the type to "line on close"
B) Set the color to "transparent"
C) Set the panel to panel #1 (important!!)
D) Turn off the "Plot executions"
E) hit Okay, You will now have a chart showing only the 5 minute data (see picture)

4) open the indicators, select SMA. In the indicator panel change the input series to the daily data series. (See picture)

You now have an sma(5) from daily bars showing on a 5 minute data chart.

Hope this helps.




Be yourself; everyone else is already taken. Oscar Wilde
Reply With Quote
Thanked by:
  #6 (permalink)
 
Tasker_182's Avatar
 Tasker_182 
Cedar Rapids, iowa
Legendary Market Wizard
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Posts: 716 since Aug 2009
Thanks Given: 476
Thanks Received: 1,401


tranta View Post
Hi, Im trying code daily 5-day-SMA on 5-minute chart, but it doesnt work, it doesnt show anything on 5minChart
could anybody help me please?

Log:
28.1.2014 16:18 Default Error on calling 'OnBarUpdate' method for indicator 'DenniSMA' on bar 1: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

Code:

#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
#endregion

/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(PeriodType.Day, 1);
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Overlay = true;
}

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

{ if(CurrentBar < 1)
return;


// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(SMA(Closes[1], 5)[0]);
}


Programmatically speaking, you need to wait for 5 daily bars to process before you can get the SMA(5) to work. So you might change your

if (CurrentBar <1)

to

if CurrentBars[1] < 5) return ;

CurrentBars[1] is the way to refer to the added data series.

Hope that helps

Be yourself; everyone else is already taken. Oscar Wilde
Reply With Quote
Thanked by:
  #7 (permalink)
 
tranta's Avatar
 tranta 
Česká republika
 
Experience: Beginner
Platform: NT
Trading: Forex
Posts: 5 since Nov 2012
Thanks Given: 4
Thanks Received: 1


Tasker_182 View Post
There is an easier way than writing an indicator to do this. Here is what i did for the chart below.

1) Created new chart with 50 days of 5 minute data.
2) Added another data series, daily, 50 days
3) for the daily data series change the following: (see picture)
A) Set the type to "line on close"
B) Set the color to "transparent"
C) Set the panel to panel #1 (important!!)
D) Turn off the "Plot executions"
E) hit Okay, You will now have a chart showing only the 5 minute data (see picture)

4) open the indicators, select SMA. In the indicator panel change the input series to the daily data series. (See picture)

You now have an sma(5) from daily bars showing on a 5 minute data chart.

Hope this helps.


Attachment 135112
Attachment 135114

Its smart solution, but I need code indicator, I want to use that in strategies.

Started this thread Reply With Quote
  #8 (permalink)
 
tranta's Avatar
 tranta 
Česká republika
 
Experience: Beginner
Platform: NT
Trading: Forex
Posts: 5 since Nov 2012
Thanks Given: 4
Thanks Received: 1


Tasker_182 View Post
Programmatically speaking, you need to wait for 5 daily bars to process before you can get the SMA(5) to work. So you might change your

if (CurrentBar <1)

to

if CurrentBars[1] < 5) return ;

CurrentBars[1] is the way to refer to the added data series.

Hope that helps

Thank zou verz much. It works finallz

Started this thread Reply With Quote
Thanked by:
  #9 (permalink)
 gfmatt 
Edmonton, Alberta
 
Experience: Advanced
Platform: IB
Trading: nq
Posts: 55 since Jan 2012
Thanks Given: 29
Thanks Received: 60

If you want to keep things simple you can just convert a 5 sma on a daily to the 5 minute chart :

There are twelve 5 minute periods per one hour multiplied by twenty-four hour per day multiplied by five days (12x24x5 = 288)

So a daily 5 SMA is roughly equivalent to a 288 SMA on a five minute chart (assuming your chart is a 24hr chart). Only a few ticks difference between them.

Reply With Quote
Thanked by:
  #10 (permalink)
 
futurestrader1's Avatar
 futurestrader1 
New York City, USA
 
Experience: Advanced
Platform: NinjaTrader
Trading: ES, CL, 6E
Posts: 149 since Jun 2010
Thanks Given: 81
Thanks Received: 42


It would be nice if the 288SMA would be the same on a 5min chart as a true daily sma on a same chart.
I use NT and ThinkOrSwim. TOS has a Daily SMA indicator built in and it is awesome. Why doesn't NT have it also.

The use of the Daily SMA is what Brian Shannon uses for his day trading and it is a great aid.

Is there a Daily SMA available as a free indicator for NinjaTrader? I would love to see it!

Reply With Quote




Last Updated on October 28, 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