Announcement

Collapse
No announcement yet.

Signal event occured within X days ago?

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

  • Signal event occured within X days ago?

    I'm trying to figure out how to code a signal for an event that happened within the last 5 days. I know how to check to see if it happened a fixed # of days ago, but it's the range I'm having trouble with.

    Specifically, in this example I want to know if the W%R went below -80 or above -20 at any time within the last 5 periods (days in this case). How does one code this sort of thing?

    Thanks!

    Jonathan

  • #2
    Jonathan
    The attached efs based on the builtin %R study provides you an example of how to do it.
    The efs will paint the background in red or lime if within the last user defined number of bars the %R was above -20 or below -80. All parameters can be modified through Edit Studies.
    Alex
    Attached Files

    Comment


    • #3
      Great Alex, thanks! A little hacking & slashing & I think I've got what I needed incorporated into the efs I was building.

      Jonathan

      Comment


      • #4
        Oh I forgot to mention one strange thing... I was playing with different lengths for the lookback, but changing the number from 5 to anything else didn't seem to have any effect. Any idea why?

        THanks!

        J

        Comment


        • #5
          Jonathan
          Forgot to make one change when I added that parameter. Replace the following line
          var vR = vPercentR.getValue(PercentRStudy.PERCENTR,0,-5);
          with
          var vR = vPercentR.getValue(PercentRStudy.PERCENTR,0,-Lookback);
          The way it was before changing the Lookback had an effect only when it was 5 or less.
          Alex

          Comment

          Working...
          X