Announcement

Collapse
No announcement yet.

Real Time Swing.efs

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

  • Real Time Swing.efs

    How could you add the volume up between swings and list it on the chart? For instance, if you had a 19 bar swing with the Real Time Swing.efs indicator what is the total volume just for those 19 bars. Place the total right on the chart like the number of bars on a swing for example 25.2MM.

  • #2
    Hello usgvince,

    One approach you could explore would be to create a global variable to store the accumulated volume figure. Inside the doLine() function you'll see a condition that check for sType == "con" This is the event that occurs at barstate newbar that draws the confirmed swing lines. Inside this condition set your gloabl variable to 0. This will start the accumulation over while the next swing is developing.

    PHP Code:
    nTotalSwingVolume 0
    Then, inside main(), inside a barstate newbar condition, add the previous bar's volume to your global variable.

    PHP Code:
    var nPrevVolume volume(-1);
    if (
    nPrevVolume != null) {
        
    nTotalSwingVolume += volume(-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


    • #3
      Still not getting results

      Attached is my attemp, but it doesn't seem to work. I added //EVR Add where I entered the lines. I also having some problem figuring out the chart output.

      Thanks
      Attached Files

      Comment


      • #4
        FWIW:

        Here is the efs with two minor corrections recommended by Jason:
        a. created a global variable
        b. inserted the sum code within a BARSTATE_NEWBAR routine

        I hope it works as you need.

        note: the volume output is to the output window, not the chart. If you want to see the current volume count you could use drawTextRelative, drawTextAbsolute, or drawTextPixel. If you just want to see the result in the Cursor Window consider replacing the function main() return statement with:
        PHP Code:
        return nTotalSwingVolume.toFixed(); 
        and under function preMain() change:
        PHP Code:
            setShowCursorLabel(false); 
        to:
        PHP Code:
            setShowCursorLabel(true); 
        wayne
        Attached Files
        Last edited by waynecd; 02-05-2009, 09:02 PM.

        Comment


        • #5
          Hi,

          Just in case I added the code that shows the volume output to the Cursor Window.

          wayne
          Attached Files

          Comment


          • #6
            Volume seems off

            When I look at the swing lines on the chart I would like to totalize or average the volume from lowest point to highest point based on the pivot line in the study. Something looks wrong because sometimes the volume is accumulating before and sometimes after the high or low of the pivot line.

            The pivot lines look right on my chart and the volume on some lines start at the next bar after the pivot which is correct, but some times it may be 2 or 3 bars after the pivot line before the volume starts to accumulate.

            Any help on getting the volume on the chart would be appreciated.

            Thanks for the help so far.

            Comment


            • #7
              The formula is not quite right

              I was wondering if where Jason suggested to place the formula isn't in the correct location. The formula was as follows:

              var nPrevVolume = volume(-1)
              if (nPreVolume !=null{
              nTotalSwingVolume += volume(-1)
              }

              I wanted the total volume including the starting pivot point volume from the start of the leg to the end of the pivot leg including the pivot point volume at the end. Perhaps in the above formula volume(0) instead of volume(-1).

              Perhaps the above formula needs to go into the
              function Init(h,l,c){ but the new function would be called
              function Init(h, l, c, v){

              I believe the function Init(h,l,c) looks for a new pivot point.

              I'm not sure how the function Init(h, l, c){ needs to be changed to add the full volume including both pivot points.

              Thanks
              Last edited by usgvince; 02-08-2009, 01:20 PM.

              Comment


              • #8
                Hi usgvince,

                Attached is the best I know how to do for what you are asking. I also added a menu option in case you don't want to display the volume labels.

                I had to change the label positions to start at the pivot bar instead of centered over it because of limitations of drawTextRelative.

                Volume labels are shown above/below the % values.

                You should test to make sure the volume is calculated the way you want.

                wayne
                Attached Files

                Comment


                • #9
                  waynecd - Thanks

                  waynecd - thanks for the help. I'll try it tonight.

                  Comment

                  Working...
                  X