NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 09-07-2012, 11:47 PM   #1
nprince
Junior Member
 
Join Date: Apr 2008
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default Multi-time frame indicator problem

Hi

I am trying to develop an indicator like the TTM trend anchor (http://www.tradethemarkets.com/products/item294.cfm). The idea is look at say a daily chart with a heiken ashi and link it to a weekly timeframe. If both the daily and weekly bars are blues, then the indicator is blue, if both are red, the indicator is red, and if one is blue and one is red, the indicator is grey (neutral). This is shown in the attachment. All is going well until I hit the weekly bar of 16/6/12 on AUDUSD as shown in the attachement. I have a blue weekly bar and 5 blue daily bars, but the indicator is grey.

I have used the print command to get the order of calculations, and everything seems to line up so I am very confused. Code is attached. Call up 2 charts of AUDUSD, one weekly, one daily with heiken ashi on both. Apply the indicator to the daily chart and look at the weekly bar for 16/6/12 and the corresponding 5 daily bars.

Any help appreciated.
Attached Files
File Type: zip trendanchor.zip (7.0 KB, 25 views)
nprince is offline  
Reply With Quote
Old 09-08-2012, 01:14 PM   #2
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

nprince,

Could you show me a screen shot here? It doesn't look l like it attached.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 09-10-2012, 04:57 AM   #3
nprince
Junior Member
 
Join Date: Apr 2008
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default

Sure - I think my original was too big. The chart on the left is the daily AUDUSD with the indicator at the bottom. The chart is linked to the weekly of the AUDUSD. Both charts have Heiken Ashi candles. The cross hair is on the Monday and shows that the entire week was blue bars. The equivalent single bar on the weekly is blue, however, my indicator shows grey bars for the whole week (both charts are blue, so I expect a blue bars on my indicator for the week).

Hope the screenshot helps and you can shed some light.
Attached Images
File Type: jpg indicatorScreenShot.jpg (286.8 KB, 22 views)
nprince is offline  
Reply With Quote
Old 09-10-2012, 07:21 AM   #4
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

Hello,

This mostly looks Ok to me, however there is one thing you may want to change. I would suggest using the overload for the HeikenAshi indicator in the proper place, I am wondering if its calling the HeikenAshi for the same time frames.

HeikenAshi(Closes[BarsInProgress] ).HAOpen[0] should work as an example.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 09-12-2012, 04:16 AM   #5
nprince
Junior Member
 
Join Date: Apr 2008
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi

Thanks for the response. I have replaced the code with:

primarySeries.Set(HeikenAshi(Closes[BarsInProgress] ).HAOpen[0] > HeikenAshi(Closes[BarsInProgress] ).HAClose[0] ? 0 : 1);

for the primary series and the same for the secondary series. Have I understood this correctly? If so, it hasn't changed the outcome of the indicator. Any other ideas?

Thanks
nprince is offline  
Reply With Quote
Old 09-12-2012, 08:52 AM   #6
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello nprince,
In historical, the weekly bar will form at the end of the week. If you look into the prints you will find the same as.
Quote:
20120608 Weekly 0.9842 0.9809 0
20120611 Daily 0.9870 0.9927 0
20120612 Daily 0.9899 0.9908 0
20120613 Daily 0.9903 0.9951 0
20120614 Daily 0.9927 0.9973 0
20120615 Daily 0.9950 1.0044 0

20120615 Weekly 0.9825 0.9998 1
Thus the daily bars (green) will refer to the weekly bar as highlighted in red and not to the bar of 20120615 which will be formed after the week ends. Thus you will get the plot as grey, and not blue.
Attached Images
File Type: png Pic.png (90.0 KB, 19 views)
Last edited by NinjaTrader_Joydeep; 09-12-2012 at 09:18 AM.
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 09-24-2012, 05:32 AM   #7
nprince
Junior Member
 
Join Date: Apr 2008
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Joydeep

Thanks for your response - I'm not sure how I missed that from the prints! If this were a live chart, would it calculate differently? ie would the weekly bar for the 15th start forming and be updated for each bar on and after the 11th?

Thanks
nprince is offline  
Reply With Quote
Old 09-24-2012, 06:15 AM   #8
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello nprince,
If Calculate on Bar Close is set to false then in realtime, both the 1 day bar and the weekly bar will updated tick by tick.
NinjaTrader_Joydeep 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Creating EMA for Multi-Time Frame on Highs RoyBoy Strategy Development 7 09-26-2012 11:22 AM
Multi time frame problem basanca General Programming 5 07-09-2012 08:32 AM
Problem with Multi Time Frame kevinchongck Strategy Analyzer 2 05-02-2010 11:57 AM
multi-time frame strategy problem mfmsonic Strategy Development 4 12-20-2009 02:37 AM
Market Reply and Multi time frame Strategy problem kekkis Strategy Development 3 12-30-2008 05:26 AM


All times are GMT -6. The time now is 09:36 AM.