Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

How to determine if a CCI value is above a line value not just the CrossAbove test?

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

    How to determine if a CCI value is above a line value not just the CrossAbove test?

    I am attempting to determine if the CCI value on a bar close is above or below a certain value. I know you can test if it CrossAbove, but can you determine if the value is > than 30 or < than -30 on each bar close and then take some action?

    #2
    Calculate = Calculate.OnBarClose; // set this within OnStateChange(), if (State == State.SetDefaults)

    if(CCI(14)[0] > 30)
    {
    //do something
    }
    if(CCI(14)[0] < -30)
    {
    //do something
    }

    Or you can combine if you need to.
    if(CCI(14)[0] > 30 || CCI(14)[0] < -30)
    {
    //do something
    }

    14 is CCI period.
    Last edited by Leeroy_Jenkins; 02-03-2021, 07:35 AM. Reason: fixed a mistake

    Comment


      #3
      Thanks Leeroy, I will need to learn more about these state commands.

      Comment


        #4
        Hello gjbeaudin,

        Thanks for your post.

        Forum member Leeroy_Jenkins has provided the correct advice assuming you are creating the strategy in Ninjascript.

        If you are using the Strategy Builder then in a sets conditions you would take the approach of:
        Left side: Indicators>CCI
        Center: Less or Greater
        Right side: Misc>Numeric Value 30 or -30

        The Calculate setting specifies how the code is to be run, using Calculate.OnBarClose means your strategy code is run once per bar at the end of the bar. This is the default setting in the strategy builder and can be changed in the "default properties" window of the strategy builder
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks Paul, both responses were very helpful...

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by dbennett3, Today, 01:59 PM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by tkaboris, Today, 01:42 PM
          2 responses
          4 views
          0 likes
          Last Post tkaboris  
          Started by DerkWehler, Today, 11:35 AM
          12 responses
          21 views
          0 likes
          Last Post DerkWehler  
          Started by webus, Today, 06:22 AM
          4 responses
          20 views
          0 likes
          Last Post webus
          by webus
           
          Started by DayTradingDEMON, 07-11-2024, 08:54 AM
          16 responses
          48 views
          0 likes
          Last Post DayTradingDEMON  
          Working...
          X