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 charlesugo_1, 05-26-2026, 05:03 PM
              0 responses
              59 views
              0 likes
              Last Post charlesugo_1  
              Started by DannyP96, 05-18-2026, 02:38 PM
              1 response
              143 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by CarlTrading, 05-11-2026, 05:56 AM
              0 responses
              161 views
              0 likes
              Last Post CarlTrading  
              Started by CarlTrading, 05-10-2026, 08:12 PM
              0 responses
              97 views
              0 likes
              Last Post CarlTrading  
              Started by Hwop38, 05-04-2026, 07:02 PM
              0 responses
              283 views
              0 likes
              Last Post Hwop38
              by Hwop38
               
              Working...
              X