Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Two hooks

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

    Two hooks

    Hi,

    I have problem with programing two hooks on CCI.
    Condition for long signal: CCI made a hook and an another hook (in next 2-8bars) is higher then first

    I want to change period of CCI and lenght two hooks.

    Hooks means that // Condition set 1
    if (CCI(CCI_short)[2] > CCI(CCI_short)[1]
    && CCI(CCI_short)[
    0] > CCI(CCI_short)[1]
    && CCI(CCI_long)[
    2] > CCI(CCI_long)[1]
    && CCI(CCI_long)[
    0] > CCI(CCI_long)[1])



    Please please, help me.
    Last edited by MartinBrr; 06-08-2009, 03:36 PM.

    #2
    MartinBrr,

    I am not quite following what exactly you are trying to do. If you want to trade only if your condition occurs twice you can do this by creating a counter.

    Code:
    if (condition)
    {
         hookCount++;
    }
    
    if (hookCount == 2)
    {
         EnterLong();
         hookCount = 0;
    }
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thank you for answer, but I want do program this:
      For long signal: There are two hooks on CCI in a row (2-8 candel /changeable/) and condition for second hooks-must be higher then first. (On both CCI, with long and short period)





      Originally posted by NinjaTrader_Josh View Post
      MartinBrr,

      I am not quite following what exactly you are trying to do. If you want to trade only if your condition occurs twice you can do this by creating a counter.

      Code:
      if (condition)
      {
           hookCount++;
      }
       
      if (hookCount == 2)
      {
           EnterLong();
           hookCount = 0;
      }

      Comment


        #4
        MartinBrr, you can use the snippet Josh has provided for this - for the 'hook' you could simply state the CCI had changed direction and then count the number of bars between your conditions. To check if the hook in the CCI occurs at a higher price you would then need to save the CCI values of both hooks to variables and compare.

        Comment


          #5
          Seems that you also have to save the bar index (which bar it is) of the trough of the first "hook" (CCI(CCI_short)[1]) and that of the second to know if the two hooks occurred within 8 bars. and reset these 'start' / 'finish' points to either null or, if it fits your pattern criteria, put the previous 'finish' bar into the 'start' bar index while you are waiting for the next hook. You might think through at what point the pattern is no longer valid and then reset both 'start' and 'finish' to null. You might also put a paramenter in for the separation of occurrances so that you can optimize for it... ditto on the value of the CCI of the 2nd trough... you might not want to go long if CCI is greater than 150 for instance.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          670 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          379 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          111 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          575 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          582 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X