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

Help develope Indicator

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

    #16
    Originally posted by sburtt View Post
    Thanks, i really appreciated your help.

    I will fix the last part. Only would you know how to code in ninja script the following conditionality i would like to add to rule 1:

    the bar count since ADX(14) crossed above 25 is < than the bars since ADX(14) crossed below 45

    Again thanks
    You would have to add the constructs to the code.

    When you cross above 25, you record the bar number.
    Code:
     
    InitialCrossAbove25Bar = CurrentBar;
    You do similar for when you cross below 45.

    In each case, the bars elapsed since the cross is then: CurrentBar - InitialCross...Bar, which you can evaluate wherever you want. Of course, you have to declare your backing store variables.

    Comment


      #17
      I don't expect you have time to waist, but in case your still interested in this, I think that rule 4
      // 4. If ADX rises from below 10, and is above 10, on 3 out of 4 days, then the market will start to trend.
      should be interpreted in the following way
      // 4. If ADX crosses above 10, and is above 10, on 3 out of 4 days, then the market will start to trend.
      If this is true i suspect the code should be amended from the current code:

      Code:
             
      //   4. If ADX rises from below 10, and is above 10, on 3 out of 4 days, then the market will start
      //   to trend.
         if (CrossAbove(ADX(this.LookBackPeriod), 10, 1))
         {
          this.ADXAbove10Count = 0;
          this.ADXAbove10TestEndBar = CurrentBar + 4;
         }
       
         if (CurrentBar < this.ADXAbove10TestEndBar)
         {
          if (ADX(this.LookBackPeriod)[0] > 10) this.ADXAbove10Count++; //how many days is ADX above 10?    
         }
       
         if (CurrentBar == this.ADXAbove10TestEndBar)
         {
          if (this.ADXAbove10Count >= 3) this.TrendStarting = true; //so what?
          this.ADXAbove10Count = -1; //reset
          this.ADXAbove10TestEndBar = -1; //reset
         }
       
      //   5. If a trend is based on rule 4, it remains in effect until the 5 day
      //   difference in ADX is less than 0.
         if (this.TrendStarting && (ADX(this.LookBackPeriod)[0] < ADX(this.LookBackPeriod)[5]))
         {
          this.TrendStarting = false;
         }
       
         //So far, nothing has been done with the supposition that the trend is starting
      to something like this (I am sure i did a few mistakes, and would appreciate your advice)
      Code:
      //   4. If ADX rises from below 10, and is above 10, on 3 out of 4 days, then the market will start
      //   to trend.
         if (CrossAbove(ADX(this.LookBackPeriod), 10, 1))
         {
          this.ADXAbove10Count = 0;
          this.ADXAbove10TestEndBar = CurrentBar + 4;
         }
       
         if (CurrentBar < this.ADXAbove10TestEndBar)
          {
          if (CrossAbove(ADX(this.LookBackPeriod),10,1))
          {
              if (ADX(this.LookBackPeriod)[0] > 10) this.ADXAbove10Count++; //how many days is ADX above 10?    
          }
         if (CurrentBar == this.ADXAbove10TestEndBar)
         {
          if (this.ADXAbove10Count >= 3) this.TrendStarting = true; //so what?
          this.ADXAbove10Count = -1; //reset
          this.ADXAbove10TestEndBar = -1; //reset
         }
         if (this.TrendStarting == true)
          {
              IsTrending = true;
          }
          }
          
       
      //   5. If a trend is based on rule 4, it remains in effect until the 5 day
      //   difference in ADX is less than 0.
         if (this.TrendStarting && (ADX(this.LookBackPeriod)[0] < ADX(this.LookBackPeriod)[5]))
         {
          IsTrending = false;
         }

      Comment


        #18
        Originally posted by sburtt View Post
        I don't expect you have time to waist, but in case your still interested in this, I think that rule 4
        should be interpreted in the following way
        If this is true i suspect the code should be amended from the current code:

        Code:
         
        //   4. If ADX rises from below 10, and is above 10, on 3 out of 4 days, then the market will start
        //   to trend.
           if (CrossAbove(ADX(this.LookBackPeriod), 10, 1))
           {
            this.ADXAbove10Count = 0;
            this.ADXAbove10TestEndBar = CurrentBar + 4;
           }
         
           if (CurrentBar < this.ADXAbove10TestEndBar)
           {
            if (ADX(this.LookBackPeriod)[0] > 10) this.ADXAbove10Count++; //how many days is ADX above 10?    
           }
         
           if (CurrentBar == this.ADXAbove10TestEndBar)
           {
            if (this.ADXAbove10Count >= 3) this.TrendStarting = true; //so what?
            this.ADXAbove10Count = -1; //reset
            this.ADXAbove10TestEndBar = -1; //reset
           }
         
        //   5. If a trend is based on rule 4, it remains in effect until the 5 day
        //   difference in ADX is less than 0.
           if (this.TrendStarting && (ADX(this.LookBackPeriod)[0] < ADX(this.LookBackPeriod)[5]))
           {
            this.TrendStarting = false;
           }
         
           //So far, nothing has been done with the supposition that the trend is starting
        to something like this (I am sure i did a few mistakes, and would appreciate your advice)
        Code:
        //   4. If ADX rises from below 10, and is above 10, on 3 out of 4 days, then the market will start
        //   to trend.
           if (CrossAbove(ADX(this.LookBackPeriod), 10, 1))
           {
            this.ADXAbove10Count = 0;
            this.ADXAbove10TestEndBar = CurrentBar + 4;
           }
         
           if (CurrentBar < this.ADXAbove10TestEndBar)
            {
            if (CrossAbove(ADX(this.LookBackPeriod),10,1))
            {
                if (ADX(this.LookBackPeriod)[0] > 10) this.ADXAbove10Count++; //how many days is ADX above 10?    
            }
           if (CurrentBar == this.ADXAbove10TestEndBar)
           {
            if (this.ADXAbove10Count >= 3) this.TrendStarting = true; //so what?
            this.ADXAbove10Count = -1; //reset
            this.ADXAbove10TestEndBar = -1; //reset
           }
           if (this.TrendStarting == true)
            {
                IsTrending = true;
            }
            }
         
         
        //   5. If a trend is based on rule 4, it remains in effect until the 5 day
        //   difference in ADX is less than 0.
           if (this.TrendStarting && (ADX(this.LookBackPeriod)[0] < ADX(this.LookBackPeriod)[5]))
           {
            IsTrending = false;
           }
        If that is the way that you want to interpret it, then just use TrendStarting to set the Plot.
        Code:
        if (this.IsTrending || this.TrendStarting) Plot0.Set(1);
        else if (!this.IsTrending) Plot0.Set(-1);

        Comment


          #19
          sorry for the late reply, i was travelling. it works fine, thanks for your help

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by giulyko00, Today, 11:49 AM
          1 response
          2 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by marksingh87, 02-13-2024, 04:55 PM
          6 responses
          208 views
          1 like
          Last Post mshrstv
          by mshrstv
           
          Started by SnailHorn, Today, 08:38 AM
          2 responses
          4 views
          0 likes
          Last Post SnailHorn  
          Started by Skifree, Yesterday, 11:38 PM
          1 response
          15 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by Mathias79, Today, 10:38 AM
          6 responses
          21 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X