NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 04-10-2007, 12:02 AM   #1
Nathamus
Member
 
Join Date: Feb 2007
Location: Germany
Posts: 37
Thanks: 1
Thanked 0 times in 0 posts
Post imported post

I would like to use a 1-minute indicator (for stop/limit values) in a tick timeframe strategy, both on the same instrument. The indicator values should only be updated once every minute.
e.g. FDAX, tick timeframe and a SMA(10) on a 1 minute period FDAX => SMA Value is updated only once a minute.

When I add a 2nd bar object to the strategy:
Code:
Add(PeriodType.Minute, 1);
Add(SMA(10));
This object will updated on every tick, even if I limit the OnBarUpdate() to the underling instrument on the ticktimeframe with
Code:
if (BarsInProgress != 0)
 return;
It is the same with the example strategy:
When I add the SampleMultiTimeFrame strategy that is provided with NT 6.0.0.10 to a ticktimeframe chart two SMAs are plotted which are updated several times in a single minute. In the strategy code they a defined as a 5 minute SMA and a 50 minute SMA.

Did I misunderstood something? Why is the SMA updated on every tick?
Nathamus is offline  
Reply With Quote
Old 04-10-2007, 12:43 AM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Post imported post

Indicators in a strategy are updated according the CalculateOnBarClose property of the strategy holding the indicators.

a) if the strategy has CalculateOnBarClose=True, then the indicators will run with CalculateOnBarClose=True
a) if the strategy has CalculateOnBarClose=False, then the indicators will run with CalculateOnBarClose=False
NinjaTrader_Dierk is offline  
Reply With Quote
Old 04-10-2007, 01:01 AM   #3
Nathamus
Member
 
Join Date: Feb 2007
Location: Germany
Posts: 37
Thanks: 1
Thanked 0 times in 0 posts
Post imported post

I tried both CalculateOnBarClose=true and CalculateOnBarClose=false on the SampleMultiTimeFrame strategy. It looks like there is no difference, the plots are the same.

The minute based SMA is updated on every bar close (= every tick) of the tick timeframe underlying and not on every bar close (which is every 10 minutes) of it´s own timeframe.

How can I create an indicator that is updated only on a certain time intervall?



Nathamus is offline  
Reply With Quote
Old 04-10-2007, 01:09 AM   #4
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Post imported post

Hmm, let's make sure we are on the same page: As you throw a strategy/indicator on a chart, it's executed once per bar for the historical part of the bars series. no matter what the CalculateOnBarClose property is set to. CalculateOnBarClose=False only is relevent for strategies/indicators running on incoming realtime data.

Reason: On historical bars data there are no ticks. One bar only triggers OnBarUpdate once.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 04-10-2007, 02:25 AM   #5
Nathamus
Member
 
Join Date: Feb 2007
Location: Germany
Posts: 37
Thanks: 1
Thanked 0 times in 0 posts
Post imported post

Sorry, maybe I did not point it out clearly.

I use a tick time chart and I have historical tick data, so every tick is a bar.

When I throw the strategy/indicator on this chart it is executed once per bar = once per tick. It obviosly does not matter if CalculateOnBarClose is set to true or false.

How can I add an indicator that is updated only once per minute, to a ticktime chart or a strategy running on a tick time chart?
Nathamus is offline  
Reply With Quote
Old 04-10-2007, 02:41 AM   #6
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Post imported post

I see. Sorry you can not visualize on chart an indicator running on a different timeframe than the chart.

But you can add an indicator running on a minute time frame to a strategy running on a tick timeframe. If the strategy then runs on CalculateOnBarClose=false, the indicator will only calculate once per per minute.

The docs (NinjaScript->Developing Custom Strategies->Multi Time Frame & Instrument) hold a sample on how to run indicators on different timeframe than the strategy.
NinjaTrader_Dierk 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


All times are GMT -6. The time now is 08:30 PM.