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 05-31-2010, 07:49 PM   #1
JSBatch
Junior Member
 
Join Date: Nov 2009
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
Default Add additional Periods and Plots to TRIX?

Newbie question here....

I want to add additional Periods and Plots to the TRIX indicator as included in the NT 6.5. System Indicators. I figured out how to add the add the additional Plots to the 'stock' indicator code but I can't absolutely determine what portion of the code calculates the Periods and Input. I believe this is the portion of the code that calculates the Periods:

if (CurrentBar == 0)
{
Value.Set(Input[0]);
return;
}

EMA tripleEma = EMA(EMA(EMA(Input, period), period), period);
double trix = 100 * ((tripleEma[0] - tripleEma[1]) / tripleEma[0]);

Default.Set(trix);
Signal.Set(EMA(Default, signalPeriod)[0]);
}

Can anyone offer any guidance on how I would modify this code to indicate FOUR TRIX Periods and FOUR TRIX Plots?

Many thanks!!

JSB
JSBatch is offline  
Reply With Quote
Old 06-01-2010, 05:15 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
Default

JSB, welcome to our forums here - are you looking simply looking for 4 times smoothed TRIX?

protected override void OnBarUpdate()
{
if (CurrentBar == 0)
{
Value.Set(Input[0]);
return;
}

EMA quadEma = EMA(EMA(EMA(EMA(Input, period), period), period), period);
double trix = 100 * ((quadEma[0] - quadEma[1]) / quadEma[0]);

Default.Set(trix);
Signal.Set(EMA(Default, signalPeriod)[0]);
}
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-01-2010, 08:54 AM   #3
JSBatch
Junior Member
 
Join Date: Nov 2009
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
Default

Yes, I believe this is what I desire. I will try the code snippet and advise as to my success. Many thanks for your quick reply and your help!

JSB
JSBatch is offline  
Reply With Quote
Old 06-01-2010, 09:55 AM   #4
JSBatch
Junior Member
 
Join Date: Nov 2009
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Bertrand -

The code snippet that you provided did not accomplish what I am try to accomplish with the TRIX indicator.

What I want to do is plot 4 EMA Periods and a Signal on one TRIX indicator - and have input access to the Periods and Signal in the Parameter section of the indicator configuration window. The image below will give you an idea what I am driving toward.

Thanks!

JSBatch is offline  
Reply With Quote
Old 06-01-2010, 10:01 AM   #5
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
Default

The easiest to setup the chart you have is just load the TRIX then 4 times to it with your custom period settings, as you load the indicator to the chart just select to plot them all in the same Panel.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-01-2010, 10:48 AM   #6
JSBatch
Junior Member
 
Join Date: Nov 2009
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks. Did as you suggested and works fine. How can I prevent the parameter settings from displaying in the indicator label?

JSB
JSBatch is offline  
Reply With Quote
Old 06-01-2010, 10:53 AM   #7
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
Default

You would need to setup the indicators then with a blanked outn label field in the indicator properties, then the paramters and indicator names are not displayed at all.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-01-2010, 10:56 AM   #8
JSBatch
Junior Member
 
Join Date: Nov 2009
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
Default

I do want to display at one label (TRIX) on the indicator panel but want to exclude the parameter settings from this label display.
JSBatch is offline  
Reply With Quote
Old 06-01-2010, 11:05 AM   #9
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
Default

You would need to address this then in your code via the steps shown in the sample - http://www.ninjatrader.com/support/f...ead.php?t=4749
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-01-2010, 12:25 PM   #10
JSBatch
Junior Member
 
Join Date: Nov 2009
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks. Will modify Label code as suggested in the sample.

JSB
JSBatch is offline  
Reply With Quote
Reply

Tags
additional periods, additional plots, multiple periods, multiple plots, trix

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
Adding additional Plots to my indicator mefTrader Indicator Development 5 12-30-2009 01:58 PM
ERROR: Failed to call 'Add' method for period type 'Tick' RK_trader Miscellaneous Support 24 06-04-2009 05:49 AM
Trix rtj4201 Indicator Development 29 03-18-2009 07:41 AM
Trix Histogram T2020 Indicator Development 0 03-03-2009 09:08 AM
Using the TRIX Stainless2000 ATM Strategies (Discretionary Trading) 1 08-26-2008 10:34 AM


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