Announcement

Collapse
No announcement yet.

Checking preceding bar values

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

  • Checking preceding bar values

    This is probably a simple question but for some reason, in eSignal, I find this very confusing.

    If I calculate a custom value, say "X", for each bar, what is the proper code to check the value of "X" for a preceding bar?

    The reason I'm confused is that, for example, to check the value of a close 3 days ago, I use close(3) (or is it close(-3)?). However, to check the value of the RSI three days ago, I have to use .getValue(-3).

    What am I missing here?

  • #2
    Re: Checking preceding bar values

    strupp1

    If I calculate a custom value, say "X", for each bar, what is the proper code to check the value of "X" for a preceding bar?
    It depends on what type of variable X is. See this post for some of the methods that can be used to retrieve a previous value

    The reason I'm confused is that, for example, to check the value of a close 3 days ago, I use close(3) (or is it close(-3)?).
    It is close(-3). Previous bars have negative index while forward bars have positive index

    However, to check the value of the RSI three days ago, I have to use .getValue(-3).
    That will depend on how you have initialized the study. If you do that at BARSTATE_ALLBARS or inside an initialization routine that executes once only when the formula first loads then you will need to use the getValue() method to retrieve the values from the series. This would be true also of the cloose() series object if you initialized it as described above
    Having said that you don't necessarily have to use the getValue() method in as much as you can also directly call a value from a series. See the examples shown in this article on the rsi() function in the EFS KnowledgeBase.
    For other functions see the relative articles in the EFS KnowledgeBase
    Alex


    Originally posted by strupp1
    This is probably a simple question but for some reason, in eSignal, I find this very confusing.

    If I calculate a custom value, say "X", for each bar, what is the proper code to check the value of "X" for a preceding bar?

    The reason I'm confused is that, for example, to check the value of a close 3 days ago, I use close(3) (or is it close(-3)?). However, to check the value of the RSI three days ago, I have to use .getValue(-3).

    What am I missing here?

    Comment

    Working...
    X