Announcement

Collapse
No announcement yet.

Unexpected main() termination and repeated BARSTATE_ALLBARS

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

  • Unexpected main() termination and repeated BARSTATE_ALLBARS

    After a morning's tedious debugPrint()ing I find that the statement:
    PHP Code:
    hh1 highest(6).getValue(-1
    causes the script to restart (ie with "getBarState() == BARSTATE_ALLBARS").
    The series is accessed in this transient way because it was only needed infrequently. I gathered from previous threads that I should not create and store series if I don't need to.

    This is just crazy:
    1) Why?
    2) The code simply exits at the statement, no error is thrown (not caught by a try()), the next line does not execute. I don't this is normal in any other programming environment. I don't believe the docs mention this behaviour at all.
    3) I wonder if this explains why, in other scripts, I have noticed occasional multiple alert firings - is this because of it rerunning? [Oddly, I can't get this script to fire an alert at all with historic bars as part of testing.] What would happen with strategy backtesting (a topic I know nothing about, but can see that some executions could be duplcated)?
    4) There are peformance issues.
    5) Why can't there be some clear explanation that BARSTATE_ALLBARS can occur more than once, and all the situations that could cause it?

    If I create the series at start up I get no problem - I can also access a transient occurence without causing a restart.

    In general I'm finding efs offers some surprising scenarios that don't seem to be explained and thus my code is not prepared for - either structurally or performance wise. Coupled with the absense of a debugger progress is far slower than I would expect.

    An unhappy programmer.

  • #2
    Hello Dave,

    It is unfortunate to hear you are disappointed with EFS. I will try to help you as much as I can.

    Regarding your call, highest(6).getValue(-1), I do see that ALLBARS is executed twice using the following code.

    PHP Code:
    function main() {
        if (
    getBarState() == BARSTATE_ALLBARS) {
            
    debugPrintln("allbars");
        }
        
        var 
    hh1 highest(6).getValue(-1);
        
    //var hh1 = upperDonchian(6, -1);  // alternative
        
        
    return hh1;

    I do not have an explanation for you as to why this happens. However, with this code example I'm not seeing any silent exits. If you can post an example that demonstrates this I'll take a closer look.

    Regarding multiple alert firings, again, there may be something formula specific causing the problem. I can't say that the call you posted is necessarily the cause.

    A better alternative may be to use the upperDonchian() call that is commented out in the example above. Give that a try and see if that helps improve things.
    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