PDA

View Full Version : Multi Time Frame - SampleDataSeries


titleistbb22
09-17-2010, 09:53 AM
Hello - I am working on modifiying the SampleDataSeriew example. I have writen the below code

// Condition set 1
if (BarsInProgress == 0)
{
// Set DataSeries object to store the trading range of the primary bar
primarySeries.Set(Stochastics(7, 12, 3).K);
}

// Executed on secondary bar updates only
if (BarsInProgress == 1)
{
// Set the DataSeries object to store the trading range of the secondary bar
secondarySeries.Set(Close[0] - Close[24]);
}

// When conditions in both primary and secondary enter long
if (CrossAbove(primarySeries[0],20,1) && secondarySeries[0] > 0)
EnterLong();

Ninja is indicating errors with the primarySeries.Set which are

The best overloaded method match for 'NinjaTrader.Data.DataSeries.Set(double)' has some invalid arguments

and

Argument '1': cannot convert from 'NinjaTrader.Data.DataSeries' to 'double'


Ninja also does not like the final condition. Indicating the following errors

The best overloaded method match for 'NinjaTrader.Strategy.StrategyBase.CrossAbove(doub le, NinjaTrader.Data.DataSeries.int)'

Argument '2': cannot convert from 'int' to NinjaTrader.Data.DataSeries'

Any help on this would be appreciated. thank you

NinjaTrader_RyanM
09-17-2010, 10:27 AM
Hello titleistbb22,

You will need to use a double value for primary series.

primarySeries.Set(Stochastics(7, 12, 3).K[0]);

Your crossing statement needs a DataSeries as first input, and this can be your primarySeries.

if (CrossAbove(primarySeries, secondarySeries[0], lookbackPeriod))

> 0 doesn't work in the CrossAbove statement.

See below for help constructing CrossAbove statements or check out SampleMaCrossOver strategy.
http://www.ninjatrader-support.com/HelpGuideV6/CrossAbove.html

titleistbb22
09-17-2010, 11:09 AM
Thank you I will work on that - your second statement that my cross doesn't have the correct components isn't correct. Its two statements to enter long, >0 has nothing to do with the Cross Over.

Using a double will hopefully clear this up

Thank you

achoicys
11-24-2012, 11:58 PM
I have the same problem. I unsuccessfully looked for any suggestion. My code is

if (CrossAbove(TEMA(20)[0], MAMA(High,0.5,0.05).Fama[0], 5))

NT7 throws errors:

The best overloaded method match for 'NinjaTrader.Strategy.StrategyBase.CrossAbove(doub le, NinjaTrader.Data.DataSeries.int)'

Argument '2': cannot convert from 'double' to NinjaTrader.Data.DataSeries'

Any help would be appreciated. Thanks!

titleistbb22
11-25-2012, 07:29 AM
Interesting to see someone working on the same problem I had. My advise, if Ninja has not fixed the fundamental problem of dynamic position sizing, look for different trading platforms to use.

I greatly appreciate the free product and service ninja provided, but without this feature you have to look else where.

Best of luck

sledge
11-25-2012, 09:14 AM
Try this:

if (CrossAbove(TEMA(20)[0], MAMA(High,0.5,0.05).Fama, 5))
I have the same problem. I unsuccessfully looked for any suggestion. My code is

if (CrossAbove(TEMA(20)[0], MAMA(High,0.5,0.05).Fama[0], 5))

NT7 throws errors:

The best overloaded method match for 'NinjaTrader.Strategy.StrategyBase.CrossAbove(doub le, NinjaTrader.Data.DataSeries.int)'

Argument '2': cannot convert from 'double' to NinjaTrader.Data.DataSeries'

Any help would be appreciated. Thanks!

sledge
11-25-2012, 09:19 AM
Your's should work too?

CrossAbove()
http://www.ninjatrader.com/support/forum/print2.png http://www.ninjatrader.com/support/forum/btn_prev_n.png (http://www.ninjatrader.com/support/forum/countif.htm)http://www.ninjatrader.com/support/forum/btn_home_n.png (http://www.ninjatrader.com/support/forum/data_methods_and_properties.htm)http://www.ninjatrader.com/support/forum/btn_next_n.png (http://www.ninjatrader.com/support/forum/crossbelow.htm)


Definition
Checks for a cross above condition over the specified bar look back period.

Method Return Value
This method returns true if a cross above condition occured; otherwise, false.

Syntax
CrossAbove(IDataSeries series1, double value, int lookBackPeriod)
CrossAbove(IDataSeries series1, IDataSeries series2, int lookBackPeriod)


Try this:

if (CrossAbove(TEMA(20)[0], MAMA(High,0.5,0.05).Fama, 5))

sledge
11-25-2012, 09:21 AM
It looks like the documentation no longer matches what NT 7 is doing.

This fails too.


if (CrossAbove(TEMA(20)[0], 27.2, 5))




Your's should work too?

CrossAbove()
http://www.ninjatrader.com/support/forum/print2.png http://www.ninjatrader.com/support/forum/btn_prev_n.png (http://www.ninjatrader.com/support/forum/countif.htm)http://www.ninjatrader.com/support/forum/btn_home_n.png (http://www.ninjatrader.com/support/forum/data_methods_and_properties.htm)http://www.ninjatrader.com/support/forum/btn_next_n.png (http://www.ninjatrader.com/support/forum/crossbelow.htm)


Definition
Checks for a cross above condition over the specified bar look back period.

Method Return Value
This method returns true if a cross above condition occured; otherwise, false.

Syntax
CrossAbove(IDataSeries series1, double value, int lookBackPeriod)
CrossAbove(IDataSeries series1, IDataSeries series2, int lookBackPeriod)

sledge
11-25-2012, 09:27 AM
ok, I'm starting to wake up.

27.2 is probably defaulting to a float.
using (double) 27.2 type casts it and it compiles.


It looks like the documentation no longer matches what NT 7 is doing.

This fails too.


if (CrossAbove(TEMA(20)[0], 27.2, 5))

sledge
11-25-2012, 09:30 AM
Even though the documentation says that MAMA.....Fama[0] returns a double, it appears it doesn't.

Use:


if (CrossAbove(High, (double)MAMA(High,0.5,0.05).Fama[0], 1))
{


I have the same problem. I unsuccessfully looked for any suggestion. My code is

if (CrossAbove(TEMA(20)[0], MAMA(High,0.5,0.05).Fama[0], 5))

NT7 throws errors:

The best overloaded method match for 'NinjaTrader.Strategy.StrategyBase.CrossAbove(doub le, NinjaTrader.Data.DataSeries.int)'

Argument '2': cannot convert from 'double' to NinjaTrader.Data.DataSeries'

Any help would be appreciated. Thanks!

sledge
11-25-2012, 09:46 AM
Thank you I will work on that - your second statement that my cross doesn't have the correct components isn't correct. Its two statements to enter long, >0 has nothing to do with the Cross Over.

Using a double will hopefully clear this up

Thank you



Have you tried:



// When conditions in both primary and secondary enter long
if (CrossAbove(primarySeries,(double)20,1) && secondarySeries[0] > 0)

EnterLong();