Announcement

Collapse
No announcement yet.

Histogram using getMostRecentTradeSize()

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

  • Histogram using getMostRecentTradeSize()

    I have written an EFS that looks at the most recent trade size, and, then, depending if it was at the bid or the ask, adding that trade size to (or subtracting it from) a running total of volume (TotVol). The EFS then plots a histogram of TotVol.

    It works great real-time.

    I know the function getMostRecentTradeSize() does not access historical data, but it does something funky, and I want to know the smartest way to fix this.

    When I first open the chart, the EFS creates a histogram for prior data bars, based on the trade size of the most recent trade and this is erroneous, since it's just a running addition (or subtraction) of the most recent trade size onto itself. This is done for each bar up to the current (now) bar.

    What's the smartest way to have this indicator not populate a histogram for the back data? Or, what's the smartest way to have this variable TotVol re-set to zero only the first the EFS is turned on?

    I hope this is clear.

    JOHN

  • #2
    Hello John,

    What you need to do is prevent your study from calculating anything until its processing real-time data. To do this, simply add a return statement at the top of main() that checks for the bar index of 0.

    PHP Code:
    function main() {
        if (
    getCurrentBarIndex() != 0) 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
      Thnx, Jason.... that seems smart enough! I'll try that.

      Cheers!

      JOHN

      Comment

      Working...
      X