Announcement

Collapse
No announcement yet.

Highest Close in X Bars comparison

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

  • Highest Close in X Bars comparison

    Hello. i am trying to author EFS code whereby the close of the last 10 bars must be greater (or less) than a study value in the last 10 bars. i am using the formula wizard. i understand the offset and number of bars inputs but cannot configure them properly.

    FYI the file is attached. thank you very much.
    Attached Files

  • #2
    Re: Highest Close in X Bars comparison

    sberg2007
    If you want to check if each Close in the last 10 bars is greater than the value of the study at the corresponding bar then the only way that it can be done in the Formula Wizard is as shown in the following example



    The alternative is to do this using the Editor. Keep in mind though that changes implemented with the Editor may no longer be readable by the Formula Wizard.
    In this case a solution would be to run a for loop on the values of the Close and of the study eg
    PHP Code:
    for (var i=0i<10i++){
        if(
    close(-i)>myStudy.getValue(...,-i)){
            
    //do this
        
    }

    For a complete description of the for loop including examples on how to use it you may want to review this article of the Core JavaScript Guide which is in the EFS KnowledgeBase. The for loop is also explained in the JavaScript for EFS video series
    Alex


    Originally posted by sberg2007
    Hello. i am trying to author EFS code whereby the close of the last 10 bars must be greater (or less) than a study value in the last 10 bars. i am using the formula wizard. i understand the offset and number of bars inputs but cannot configure them properly.

    FYI the file is attached. thank you very much.

    Comment

    Working...
    X