Announcement

Collapse
No announcement yet.

Time Definition

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

  • Time Definition

    How could I write into the Formula Wizard that
    I want a signal if price held above a moving
    average for 100 periods?

    Thanks very much for your consideration,
    -Matt Powers

  • #2
    Hello Matt,

    The Formula Wizard would not be able to create this type of study because it would require a global variable to store the current count. You could create the basis for the study in the Formula Wizard and then modify it in the EFS Editor to complete the study. You would need to add a global variable (ie nCount) and set it to 0 initially. Then add an if statement inside a BARSTATE_NEWBAR check and increment the nCount variable if the previous bar's close or low was above the MA value. When you find that the close or low (whichever you decide to use) is below the MA value, reset the nCount variable back to 0. Then add another if statement after that (which could still be inside the BARSTATE_NEWBAR check) and do something when you find that nCount >= 100.

    PHP Code:
    var nCount 0;

    function 
    main() {
        
        
    /*
            Formula Wizard code
            ...
            ...
            ...
        */
        
        
    if (getBarState() == BARSTATE_NEWBAR) {
            if (
    low(-1) > MA.getValue(-1)) {
                
    nCount++;
            } else {
                
    nCount 0;
            }
            if (
    nCount >= 100) {
                
    Alert.playSound("Ding.wav");
            }
        }    

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Jason, thanks for the reply
      I appreciate it -
      -Matt Powers

      Comment

      Working...
      X