Announcement

Collapse
No announcement yet.

Price Tick Change Studies?

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

  • Price Tick Change Studies?

    Hi,
    It is possible to develop studies based on Price change relative to the previous price TICK, and not the previous bars CLOSE?

    Eg - a simple ROC which calculates Close (present TICK) - Close (previous TICK)
    : - instead of comparing present TICK to the previous bars CLOSE, which it does now if you calculate ( C() - C(-1) ).

    Thanks,
    Paul

  • #2
    Hello Paul,

    You can accomplish this using the close() function and a global variable to store the previous price. Here's a code example that will display the most recent two prices in the formula output window.

    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
        
    setShowCursorLabel(false);
    }

    var 
    vPrev 0;

    function 
    main() {
        var 
    vLast close();
        
        
    debugPrintln("Previous: " vPrev.toFixed(4) + "  Last: " vLast.toFixed(4));
        
        
    vPrev vLast;
        
        return;

    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
      Hi Jason,
      I ran the study you posted and no data was displayed - could you provide an example of a basic Price ROC for me :

      Present Tick Close () - Previous Tick Close (-1)

      Also, do you have any advice on the Symbol Overlay question i posted today - i think its a study you developed (EFS Database).

      Many thanks,
      Paul

      Comment


      • #4
        Hello Paul,

        By the way, the debugPrintln() function outputs the data to the formula output window. To open that window, go to Tools -> EFS -> Formula Output Window.

        Here's the added code snippit for calculating the ROC.

        PHP Code:
        function preMain() {
            
        setStudyTitle("ROC of Current Vs. Last");
            
        setCursorLabelName("ROC");
        }

        var 
        vPrev 0;

        function 
        main() {
            var 
        vLast close();
            
            
        //debugPrintln("Previous: " + vPrev.toFixed(4) + "  Last: " + vLast.toFixed(4));
            
            
        if (vPrev != 0) {
                var 
        vROC = ((vLast vPrev)/vPrev) * 100;
            }
            
            
        vPrev vLast;
            
            return 
        vROC;

        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


        • #5
          Hi Jason,
          Do you know how i could achieve the following? :

          - Can a TOTAL be STORED & UTILIZED of the vLasts for the time period of the Price Bar, so i can use this data for other calculations?

          eg - the study already produces a Total of the vLasts Bull upticks and vLasts Bear downticks for a 1min or 5min period (or whatever bar period i'm using) - can these totals be stored as the last BARS data (-1) - which can be used for calculations?

          At the moment, if i go to to calculate :

          Bull vLast / Bear vLast = it just uses the last Bull and Bear TICK to calculate this;

          = But i'd like to calculate:
          Bull Total of all vLasts over 1min period / Bear Total of all vLasts over 1min period

          Many thanks,
          Paul

          Comment


          • #6
            Hello Paul,

            What I would do in this case is create two more global variables and call them something like, BearSum and BullSum. Then, somewhere towards the top of main() put in a little routine that looks like this:

            PHP Code:
                if (getBarState() == BARSTATE_NEWBAR) {
                    
            BearSum 0;
                    
            BullSum 0;
                } 
            This will reset the variables at the beginning of each bar. Then later in main() where you set the values for Bull vLast and Bear vLast add a line after each that adds the new data to BearSum or BullSum, respectively.

            PHP Code:
                BearSum += Bear vLast
            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

            Working...
            X