![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Feb 2007
Location: Germany
Posts: 37
Thanks: 1
Thanked 0 times in 0 posts
|
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)); Code:
if (BarsInProgress != 0) return; 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? |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
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
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Feb 2007
Location: Germany
Posts: 37
Thanks: 1
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
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.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Feb 2007
Location: Germany
Posts: 37
Thanks: 1
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#6 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
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.
Dierk
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|