Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

simple strategy to enter at CCI cross +45/-45

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

    simple strategy to enter at CCI cross +45/-45

    This is to make a simple strategy to enter Long when CCI cross a certain value like +45 or vice versa for -45. I believe this code will enter Long when CCI crosses zero? sorry guys I am brand new to coding, so need some help.
    Any help is appreciated

    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(Close, CCI(14), 1))
    {
    EnterLong(DefaultQuantity, "");
    }

    // Condition set 2
    if (CrossBelow(Close, CCI(14), 1))
    {
    EnterShort(DefaultQuantity, "");
    }
    }

    #2
    Hello,

    You would need to make this change:

    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(45, CCI(14), 1))
    {
    EnterLong(DefaultQuantity, "");
    }

    // Condition set 2
    if (CrossBelow(-45, CCI(14), 1))
    {
    EnterShort(DefaultQuantity, "");
    }
    }
    BrettNinjaTrader Product Management

    Comment


      #3
      thks Brett. but when i run strategy wizard, don't I need to choose Price close in left side when i choose CCI in right side?

      Comment


        #4
        Hello,

        This is correct. This is camparing the current price will cross above or below the current CCI value. Which is not what you want.

        You need to use Misc -> Numberic Value
        BrettNinjaTrader Product Management

        Comment


          #5
          Thks Brett

          Comment


            #6
            Brett - sorry, am not clear. which side should I choose
            Misc -> Numberic Value
            choose CCI in both sides, then give Misc -> Numberic Value in right side of CCI value?

            Comment


              #7
              Hello,

              Use CCI only on the one side and then the numeric value on ther other side.

              Let me know if I can be of further assistance.
              BrettNinjaTrader Product Management

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CarlTrading, 03-31-2026, 09:41 PM
              1 response
              65 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by CarlTrading, 04-01-2026, 02:41 AM
              0 responses
              35 views
              0 likes
              Last Post CarlTrading  
              Started by CaptainJack, 03-31-2026, 11:44 PM
              0 responses
              59 views
              1 like
              Last Post CaptainJack  
              Started by CarlTrading, 03-30-2026, 11:51 AM
              0 responses
              62 views
              0 likes
              Last Post CarlTrading  
              Started by CarlTrading, 03-30-2026, 11:48 AM
              0 responses
              51 views
              0 likes
              Last Post CarlTrading  
              Working...
              X