Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CrosssAbove Syntax

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    CrosssAbove Syntax

    This should be a pretty easy one.

    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:

    The best overloaded method match for 'NinjaTrader.Strategy.StrategyBase.CrossAbove(doub le, NinjaTrader.Data.IDataSeries, int)' has some invalid arguments


    Argument '2': cannot convert from 'double' to 'NinjaTrader.Data.IDataSeries'
    Any thoughts here?

    Regards,

    Andrew

    Help Content:


    PHP Code:
    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(); 
    

    #2
    Hello Andrew,
    Closes[2][0] will return a double and not a data series. Please try using the below code and see if you are able to compile the code.

    Code:
    CrossAbove(Closes[2], stopPrice2, 10)
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Of course. I dont even have to check.

      I feel silly.

      TY again Joydeep.

      Regards,

      Andrew

      Edit: And yes, of course it worked

      Comment


        #4
        Originally posted by alabell View Post
        This should be a pretty easy one.

        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:



        Any thoughts here?

        Regards,

        Andrew

        Help Content:


        PHP Code:
        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(); 
        
        Closes[2][0] is a double: the DataSeries is Closes[2]

        Comment


          #5
          Ty too Koganam, any thoughts on the other "project"?

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X