Announcement

Collapse
No announcement yet.

EFS for cumulative up/down speed

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

  • EFS for cumulative up/down speed

    Could anyone please write a study that calculates the average speed of the up bars vs down bars to that point in time?

    (To be used on volume or tick bars)

    I've attached a study that calculates the average up bar vs down bar range for reference.

    Purpose: to compare the speed of up bars to down bars in relation to range of up bars to down bars.

    Thanks in advance
    Attached Files

  • #2
    Re: EFS for cumulative up/down speed

    What is the formula for speed in this case?

    v = d/t

    Velocity (speed) = distance / time is the normal formula


    Originally posted by Himalaya
    Could anyone please write a study that calculates the average speed of the up bars vs down bars to that point in time?

    (To be used on volume or tick bars)

    I've attached a study that calculates the average up bar vs down bar range for reference.

    Purpose: to compare the speed of up bars to down bars in relation to range of up bars to down bars.

    Thanks in advance

    Comment


    • #3
      Clarification on speed/seconds

      Sorry, below is a study that calculates the speed (seconds) of a bar.

      I am basically looking for the study to add the seconds in the up bars and then divide that number by the quantity of up bars - and the same for down bars

      function preMain() {
      setStudyTitle("Tick Bar Time ");
      setCursorLabelName("TBT", 0);
      setDefaultBarFgColor(Color.lime, 0);
      setPlotType(PLOTTYPE_HISTOGRAM, 0);
      }

      var vStart = null;
      var vCur = null;

      function main() {
      var nState = getBarState();

      if (getCurrentBarIndex() < 0) {
      var tickTime = getValue("rawtime", 1) - getValue("rawtime");
      //debugPrintln(getCurrentBarIndex() + " diff: " + tickTime);
      return tickTime;
      } else {
      var vDate = new Date();
      if (nState == BARSTATE_NEWBAR) {
      vStart = vDate.getTime();
      //debugPrintln("*** NEW BAR *** start: " + vStart);
      }

      vCur = vDate.getTime();
      var tickTime = 0;
      tickTime = vCur - vStart;
      //debugPrintln("diff: " + tickTime);
      //var tickTime=(getMinute()-getMinute(-1))*60+getSecond()-getSecond(-1);
      if(tickTime > 0) {
      return tickTime/1000;
      } else {
      return 0;
      }
      }
      }

      Comment


      • #4
        Speed of price increase/decrease

        Anyone knowledgeable willing to take this up?

        Purpose of the study is to gauge if the market is trading up faster than it is trading down or vice versa.

        Himalaya

        Comment


        • #5
          Originally posted by Himalaya
          Anyone knowledgeable willing to take this up?

          Purpose of the study is to gauge if the market is trading up faster than it is trading down or vice versa.

          Himalaya
          I am not sure if I have exactly what you wanted....

          I reset when the instrument changes direction.

          Perhaps that's not what you wanted.

          PHP Code:
          function preMain() {

          setStudyTitle("TRO_TickBarTime ");
          setCursorLabelName("TBT"0);

          setDefaultBarThickness(4,0); 
          setDefaultBarFgColor(Color.black0); 

          setPlotType(PLOTTYPE_HISTOGRAM0);
          }

          var 
          vStart null;
          var 
          vCur null;


          var 
          xUpBars 0;
          var 
          xDnBars 0;

          var 
          xUpSpeed  0;
          var 
          xDnSpeed  0;

          function 
          main() {
          var 
          nState getBarState();


          if (
          getCurrentBarIndex() < 0) {
          var 
          tickTime getValue("rawtime"1) - getValue("rawtime");
          //debugPrintln(getCurrentBarIndex() + " diff: " + tickTime);
          //return tickTime;


            
          if( close() > open() ) { 
              
          xUpBars  xUpBars ;
              
          xUpSpeed xUpSpeed xUpBars / ( tickTime/1000 ) ;  
              
          xDnSpeed ;  
              
          setBarFgColor(Color.green0); 
            }

            if( 
          close() < open() ) { 
              
          xDnBars  xDnBars ;
              
          xDnSpeed xDnSpeed xDnBars / ( tickTime/1000 ) ;
              
          xUpSpeed ;
              
          setBarFgColor(Color.red0);  
            }

          return ( 
          xUpSpeed  xDnSpeed 

          else {
          var 
          vDate = new Date();
          if (
          nState == BARSTATE_NEWBAR) {
          vStart vDate.getTime();
          //debugPrintln("*** NEW BAR *** start: " + vStart);
          }

          vCur vDate.getTime();
          var 
          tickTime 0;
          tickTime vCur vStart;
          //debugPrintln("diff: " + tickTime);
          //var tickTime=(getMinute()-getMinute(-1))*60+getSecond()-getSecond(-1);
          if(tickTime 0) {

            if( 
          close() > open() ) { 
              
          xUpBars  xUpBars ;
              
          xUpSpeed xUpSpeed xUpBars / ( tickTime/1000 ) ;  
              
          xDnSpeed ;
              
          setBarFgColor(Color.green0); 
            }

            if( 
          close() < open() ) { 
              
          xDnBars  xDnBars ;
              
          xDnSpeed xDnSpeed xDnBars / ( tickTime/1000 ) ;
              
          xUpSpeed ;
              
          setBarFgColor(Color.red0);  
            }

          return ( 
          xUpSpeed  xDnSpeed 

          else {
          return ( 
          0  
          }
          }

          Attached Files

          Comment


          • #6
            Hello Avery,

            Thank you very much for posting your code and assisting with this formula request.
            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