after upgrading to NT7 I also had issues using TSSupertrend in a strategy. I also had the error:
NinjaTrader.Strategy.Strategy.TSSuperTrend(int,TSS uperTrend.Utility.MovingAverageType, double, int, TSSuperTrend.Utility.SuperTrendMode)' is a method, which is not valid in the given context.
Here's the good news, I found a solution that worked for me (and with a high probability it will for you...
For anyone interested in using TSSupertrend in a strategy here's what I did:
0) remove TSSuperTrend.Utility from indicators directory, and rename file extension of strategy's using TSSupertrend that failed to compile before (or temporarily remove them from strategy directory) so that you can compile without errors.
1) copy TradingStudies.NinjaScript.Utility.cs to indicators directory
2) open and compile TradingStudies.NinjaScript.Utility.cs
3) copy indicator TSSuperTrend.cs (V2.3) to indicators directory
4) add "using TradingStudies.NinjaScript.Utility; " to declarations section of TSSuperTrend.cs (on top of code )
5) compile TSSuperTrend.cs
6) in strategy, add "using TradingStudies.NinjaScript.Utility;" to declarations section on top of page.
I attached the following files: (modifications listed above are already implemented here)
TradingStudies.NinjaScript.Utility.cs
TSSuperTrend.cs (V2.3) : the indicator
SuperTrendDemo.cs: strategy which shows how to detect if TSSuperTrend switches Long/Short and how to access and print uptrend/downtrend values.
Hopefully this information can be usefull to some of the NinjaTraders out here...;
attention update 21-08-2011
After a discussion with Randy in post #351 to #358 the best way to get it working is to import the SuperTrend Demo strategy directly in NinjaTrader ( ControlPanel File/Utilities/import NinjaScript ) This way, all the referenced indicators and files are included automatically. So the correct procedure would now be:
1) remove TSSuperTrend.Utility from indicators directory (if existing)
2) import SuperTrend Demo.zip in NinjaTrader (File/Utilities/import NinjaScript ) This is the strategy with all the indicators and referenced files.
update 22-08-2011
updated SuperTrend Demo.zip
reason: Corrected strategy switching behaviour; strategy entry's where inverse to supertrend indicator. If supertrend switched to uptrend, the strategy went short, and went long if supertrend swithed to downtrend. Althought this might in fact be very profitable in a sideways market, I thought for clarity it is better to make the switching follow the indicator's up/downtrend.
good luck,
Marco
Comment