Announcement

Collapse
No announcement yet.

$TVOL time synch problem

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

  • $TVOL time synch problem

    I modified a script posted by Chris Kryza here to calculate $TVOL same-time moving average. The idea is to evaluate market participation at any point of the day relative to longer term VMA.

    The attached EFS calculates $TVOL current bar volumes and plots an histogram for those volumes plus a VMA line for same-time bars over a certain number of periods specifieds in the parameters list. All the values used in the formula are extracted from symbol $TVOL, regardless of the symbol used in the main chart.

    The EFS seems to work fine, except when the symbol in the price study pane is ES #F. Then the 9:30 bar doesn't match the time shown on the X axis. Any idea why this is happening?
    I am using a custom time template set to EST equity hours (9:30-16:00) and 63 days of data.
    Attached Files
    Last edited by probtrader; 01-16-2006, 01:40 PM.

  • #2
    BTW, because $TVOL contains cumulative volume values, I had to calculate the current value by substracting the previous close from the current close, for each bar except the opening bar.

    If there is a symbol that publish total current volumes, it would simplify the formula.

    Comment


    • #3
      Hello probtrader,

      The problem lies in how you are calculating the bar volume for the $TVOL symbol. From the code that Chris posted you just need to change the logic for populating the aTimes array to the following.

      PHP Code:
      //aTimes[nCurIndex].Data.unshift( volume(-1) );
              
      if (getDay(-1) != getDay(-2)) {
                  
      aTimes[nCurIndex].Data.unshiftclose(-1) );
              } else {
                  
      aTimes[nCurIndex].Data.unshiftclose(-1) - close(-2) );            
              } 
      At the end of main, change the logic for nPlot1 to the following.

      PHP Code:
      //nPlot1 = volume(0);
          
      if (getDay(0) != getDay(-1)) {
              
      nPlot1 close(0);
          } else {
              
      nPlot1 close(0) - close(-1);
          } 
      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


      • #4
        Jason,
        I changed the script as you suggested but the $TVOL bars are still out of synch when I display ES #F in the main chart area. Please see attachments.
        The $TVOL pick volume at 11:00 on 1/13 is wrong.
        Attached Files

        Comment


        • #5
          Attached the new formula.
          Attached Files

          Comment


          • #6
            Hello probtrader,

            To incorporate the external symbol synchronization into your version, you just need to replace the EFS1 instances of getDay, getHour, getminute with the EFS2 equivlants day, hour and minute. And then wrap the instances of sSymbol in each of those calls and the calls to close() with the sym() function.

            PHP Code:
                // store the volume from the bar that just closed
                // in our array indexed by time (nCurIndex)
                
            if( day(-1sym(sSymbol)) != day(-2sym(sSymbol)) ) {
                    
            aTimes[nCurIndex].Data.unshift(close(-1sym(sSymbol)));
                } else {
                    
            aTimes[nCurIndex].Data.unshift(close(-1sym(sSymbol)) - close(-2sym(sSymbol)));
                } 
            PHP Code:
                // Plot current volume and average for same-time volume
                
            if( day(0sym(sSymbol)) != day(-1sym(sSymbol)) ) {
                    
            nPlot1 close(0sym(sSymbol));
                } else {
                    
            nPlot1 close(0sym(sSymbol)) - close(-1sym(sSymbol));
                } 
            PHP Code:
            //get the current bar time (as total minutes)
            function getBarTimenOffsetsSymbol ) {
            var 
            nTmp 0;
                
            nTmp = (hour(-nOffsetsym(sSymbol))*60) + minute(-nOffsetsym(sSymbol));
                return( 
            nTmp );

            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


            • #7
              Looks much better. Thank you Jason.
              What is the difference between using sym("$TVOL") and just the plain string "$TVOL" in the serie functions?
              Attached Files

              Comment


              • #8
                Hello probtrader,

                The sym() function synchronizes the data between symbols based on the time stamp of the bar rather than bar index, which is the effect when just using the string of "$TVOL."
                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