At the bottom of the post is the help content for CrossAbove or CrossBelow. I am using it to create dynamic Stop Losses that update based on a few parameters.
Using the first Syntax listed below, the following should work:
Syntax
CrossAbove(IDataSeries series1, double value, int lookBackPeriod)
or in my case, here is a toy version of my code:
double stopPrice2 = 75.00
CrossAbove(Closes[2][0], stopPrice2, 10)
This syntax generates the following errors:
Argument '2': cannot convert from 'double' to 'NinjaTrader.Data.IDataSeries'
Regards,
Andrew
Help Content:
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)
Parameters
lookBackPeriod
Number of bars back to check the cross above condition
series1 & series2
Any DataSeries type object such as an indicator, Close, High, Low, etc...
value
Any double value
Examples
// Go short if CCI crossed above 250 within the last bar
if (CrossAbove(CCI(14), 250, 1))
EnterShort();
// Go long if 10 EMA crosses above 20 EMA within the last bar
if (CrossAbove(EMA(10), EMA(20), 1))
EnterLong();
// Go long we have an up bar and the 10 EMA crosses above 20 EMA within the last 5 bars
if (Close[0] > Open[0] && CrossAbove(EMA(10), EMA(20), 5))
EnterLong();
Comment