Announcement

Collapse
No announcement yet.

do not start at past bars

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

  • do not start at past bars

    Hi,

    I have a formula that I would only want to launch at and after the bar when I apply the , or in other words, I do not want the formula to be executed at any of the past bars even though these bars are displayed.

    One way I can think of is to get the system year, month, day, hour, minute, and compare it with a bar's year, month, day, hour, and minute. If they match, then I start applying the formula. Doing a comparison this is quite cumbersome because of the rollover in month, day, hour and minute.

    I'm wondering if there's an easier solution.

    Thank you.

    William

  • #2
    Hello William,

    Please clarify if my understanding is correct. I think what you are saying is that you want a formula to only process bar 0 in real time?

    If so, the easiest thing to do is add a conditional statement to the top of main() that checks the bar index and exits main unless the bar index is 0.

    PHP Code:

    function main() {
        if (
    getCurrentBarIndex() < 0) return;  // exit unless bar index == 0

        
    ...... your formula code

        
    return sma(10);

    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
      Jason, your understanding is correct. And your solution is exactly what I needed. Thank you.

      William

      Comment


      • #4
        You're most welcome.
        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