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

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 05-28-2009, 09:41 PM   #1
epcompany
Member
 
Join Date: Dec 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default Compile TSSuperTrend Indicator in Strategy

I'm trying to get the value of the TSSuperTrend indicator as:

super_trend = TSSuperTrend(Median,14,HMA,2.618,14,ATR)[0];

or
super_trend = TSSuperTrend(14,HMA,2.618,14,ATR)[0];

The first method is as it is called as an indicator. The second is the method shown by the compiler.

The compiler gives me the error message in the attached jpg. The error relates to the HMA and ATR calls.

How can I make this work?

Thanks!

Larry
Attached Images
File Type: jpg ScreenHunter_01 May. 28 20.36.jpg (55.7 KB, 106 views)
epcompany is offline  
Reply With Quote
Old 05-28-2009, 10:18 PM   #2
roonius
Certified NinjaScript Consultant
 
Join Date: Oct 2008
Location: Chicago, IL
Posts: 523
Thanks: 0
Thanked 8 times in 7 posts
Send a message via Skype™ to roonius
Default

include the following line at the top of your script:

using TradingStudies.NinjaScript.Utility;

and

replace HMA with MovingAverageType.HMA

replace ATR with SuperTrendMode.ATR
roonius is offline  
Reply With Quote
Old 05-29-2009, 05:51 AM   #3
epcompany
Member
 
Join Date: Dec 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default Thanks!

Roonius,
Thanks very much! I appreciate the help!

It seems, to me anyway, that there are many nooks and crannies hidden in NT that make it hard for a "Level 2 player" to navigate through the code, like this one.

Is there a reference that exposes more of the hidden areas?

Thanks again!

Larry
epcompany is offline  
Reply With Quote
Old 05-29-2009, 07:37 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,460
Thanks: 1
Thanked 172 times in 82 posts
Default

Larry,

This is not NinjaTrader specific. It is due to the 3rd party code you are using and as such usage can vary depending on who writes it.
NinjaTrader_Josh is offline  
Reply With Quote
Old 05-30-2009, 07:56 AM   #5
epcompany
Member
 
Join Date: Dec 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default

Josh and Roonius,

I appreciate the help!

The next baby step involves what seems to be memory leakage when I call the indicator from my strategy.

I load the two values of the lines and the bool trend into my strategy from:

up_trend = TSSuperTrend(14,MovingAverageType.HMA,2.618,14,Sup erTrendMode.ATR).UpTrend[0];

down_trend = TSSuperTrend(14,MovingAverageType.HMA,2.618,14,Sup erTrendMode.ATR).DownTrend[0];

trend_up = TSSuperTrend(14,MovingAverageType.HMA,2.618,14,Sup erTrendMode.ATR).Trend[0];

These are inside a "if (FirstTickOfBar)" statement, so I only get these once per bar.

With these statements included in my strategy, it takes my i7 3GHz CPU with 3GB RAM running Vista about 30 seconds to load my strategy with 5 minute candles and 15 days of historical data. Without the statements, it takes the machine less than a second to load the strategy.

The instructions consume about 500MB of additional RAM. I can watch the available memory disappear as the strategy is attempting to load. If I recompile and reload the strategy, the first load does not release the memory it took. The second load continues to take memory until I get an "out-of-memory" message.

The TSSuperTrend indicator has remarkable potential when used in a momentum based strategy. I don't think I can use it as is imagining money on the table and the computer running out of memory.

Is there a reason for the high memory use when the indicator variables are ported into a strategy? Am I doing something that causes this? Can it be stopped?

Thanks again very much!

Larry
Last edited by epcompany; 05-30-2009 at 08:30 AM.
epcompany is offline  
Reply With Quote
Old 05-31-2009, 11:44 AM   #6
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 4 times in 4 posts
Default

Hello,

I will have Josh reply on Monday.
NinjaTrader_Ben is offline  
Reply With Quote
Old 05-31-2009, 12:06 PM   #7
roonius
Certified NinjaScript Consultant
 
Join Date: Oct 2008
Location: Chicago, IL
Posts: 523
Thanks: 0
Thanked 8 times in 7 posts
Send a message via Skype™ to roonius
Default

Quote:
Originally Posted by epcompany View Post
Josh and Roonius,

I appreciate the help!

The next baby step involves what seems to be memory leakage when I call the indicator from my strategy.

I load the two values of the lines and the bool trend into my strategy from:

up_trend = TSSuperTrend(14,MovingAverageType.HMA,2.618,14,Sup erTrendMode.ATR).UpTrend[0];

down_trend = TSSuperTrend(14,MovingAverageType.HMA,2.618,14,Sup erTrendMode.ATR).DownTrend[0];

trend_up = TSSuperTrend(14,MovingAverageType.HMA,2.618,14,Sup erTrendMode.ATR).Trend[0];

These are inside a "if (FirstTickOfBar)" statement, so I only get these once per bar.

With these statements included in my strategy, it takes my i7 3GHz CPU with 3GB RAM running Vista about 30 seconds to load my strategy with 5 minute candles and 15 days of historical data. Without the statements, it takes the machine less than a second to load the strategy.

The instructions consume about 500MB of additional RAM. I can watch the available memory disappear as the strategy is attempting to load. If I recompile and reload the strategy, the first load does not release the memory it took. The second load continues to take memory until I get an "out-of-memory" message.

The TSSuperTrend indicator has remarkable potential when used in a momentum based strategy. I don't think I can use it as is imagining money on the table and the computer running out of memory.

Is there a reason for the high memory use when the indicator variables are ported into a strategy? Am I doing something that causes this? Can it be stopped?

Thanks again very much!

Larry
I am aware of this, and looking what is causing the trouble.
Will keep you updated as soon as I find the solution
roonius is offline  
Reply With Quote
Old 06-02-2009, 09:53 PM   #8
roonius
Certified NinjaScript Consultant
 
Join Date: Oct 2008
Location: Chicago, IL
Posts: 523
Thanks: 0
Thanked 8 times in 7 posts
Send a message via Skype™ to roonius
Default

http://www.ninjatrader-support2.com/...ad.php?t=11844

You can download updated version (2.1) there
roonius is offline  
Reply With Quote
Old 06-08-2009, 07:10 AM   #9
epcompany
Member
 
Join Date: Dec 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Smile

Roonius,
Thank you very much for V2.1! I ran it all weekend starting and stopping and recompiling, etc. After a VERY long (comparative) time, my machine bogged down with memory problems but this version is far superior to the previous version in terms of memory usage. It is now useful and trust worthy for real-time trading. I appreciate it and you!

I'm sure you understand the power of your indicator relative to price movement: it indicates when you have an advantage trading, it tells you when to stay out, and it is tunable for one's personal risk tolerance. I combined your indicator with PSAR and have made a very powerful trading tool. I hope to owe you a dinner for you and a guest at the Top of the Mark in SF by-and bye.

Larry

PS: One other item. If I call the indicator for bar [0], it returns zero for the two trend values and false for the trend. I only get legitimate values if I run it from bar [1]. I call it on the first tick of bar [0]. If I could push the values up one bar to bar [0], that would be even better.

Here are the strategy lines:

up_trend_value = TSSuperTrend(14,MovingAverageType.HMA,2.618,14,SuperTrendMode.ATR).UpTrend[1];
down_trend_value = TSSuperTrend(
14,MovingAverageType.HMA,2.618,14,SuperTrendMode.ATR).DownTrend[1];
trend_up_indicator = TSSuperTrend(
14,MovingAverageType.HMA,2.618,14,SuperTrendMode.ATR).Trend[1];
epcompany 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
Will not compile latkinso Indicator Development 3 12-27-2013 11:40 AM
SuperTrend strategy (TSSuperTrend) sam028 NinjaScript File Sharing Discussion 3 06-03-2009 07:17 AM
Compile error mktrend General Programming 3 01-07-2009 06:28 AM
Can't Compile Indicator garciaal Indicator Development 1 07-15-2007 11:30 PM
try to compile but Elmi Indicator Development 1 11-05-2006 02:40 AM


All times are GMT -6. The time now is 10:16 AM.

FULL RISK DISCLOSURE: Futures trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.