Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          576 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          553 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X