Announcement

Collapse
No announcement yet.

chart is stuck on "Loading Data..."

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

  • chart is stuck on "Loading Data..."

    Any help is appreciated.

    When I run the following code the chart stays on "Loading Data..." forever. It does not affect any other operation and I can even delete the study from the chart when it is in this state.

    I would like to use the close(0) of a 1 min chart (symbol $ADD) when it is above or below a 21 ema for 1 min chart of $ADD to color the background of a 55T chart of the "ES #F".

    Attached is a picture of the chart and the code sample follows:

    PHP Code:
    var bInit false

    function 
    preMain() {
        
    setPriceStudy(true);
    }

    var 
    vLastAlert = -1;
    var 
    myStudy0 null;
    var 
    Type0 "ema";
    var 
    Length0 21;
    var 
    Source0 "close";
    var 
    Offset 0;
    var 
    vSymbol "$ADD";
    var 
    Interval0 1;

    function 
    main(){

        if ( 
    bInit == false ) { 
            
            if(
    vSymbol == nullvSymbol getSymbol();
            if(
    Interval0 == nullInterval0 getInterval();
            var 
    xSymbol vSymbol+","+Interval0;

            if(
    myStudy0 == nullmyStudy0 offsetSeries(eval(Type0)(Length0,eval(Source0)(sym(xSymbol))),Offset);
            
    bInit true
        } 
        var 
    CloseVal close(0,sym(xSymbol));

        if (
    CloseVal myStudy0.getValue(0)){
                
    setBarBgColor(Color.RGB(255,255,192));
        } else if (
    CloseVal myStudy0.getValue(0)){
                
    setBarBgColor(Color.RGB(255,234,255));
        }

        return 
    getSeries(myStudy0).toFixed(2);

    Attached Files

  • #2
    Re: chart is stuck on "Loading Data..."

    waynecd
    The reason the script is stuck on "Loading data..." is because you are not passing a valid symbol to the close(0,sym(xSymbol)) call
    To verify that add a debug statement in the line above that call and you will see that xSymbol will return the symbol/interval once on the first iteration of the efs and then will return undefined on the subsequent iteration.
    This is because you declared xSymbol as a local variable inside the bInit routine which means that xSymbol will be declared and assigned a valid symbol on the first iteration. On the following iteration the bInit routine is not executed hence the variable xSymbol does not get declared.
    To resolve this you need to declare xSymbol as a global variable
    Alex


    Originally posted by waynecd
    Any help is appreciated.

    When I run the following code the chart stays on "Loading Data..." forever. It does not affect any other operation and I can even delete the study from the chart when it is in this state.

    I would like to use the close(0) of a 1 min chart (symbol $ADD) when it is above or below a 21 ema for 1 min chart of $ADD to color the background of a 55T chart of the "ES #F".

    Attached is a picture of the chart and the code sample follows:

    PHP Code:
    var bInit false

    function 
    preMain() {
        
    setPriceStudy(true);
    }

    var 
    vLastAlert = -1;
    var 
    myStudy0 null;
    var 
    Type0 "ema";
    var 
    Length0 21;
    var 
    Source0 "close";
    var 
    Offset 0;
    var 
    vSymbol "$ADD";
    var 
    Interval0 1;

    function 
    main(){

        if ( 
    bInit == false ) { 
            
            if(
    vSymbol == nullvSymbol getSymbol();
            if(
    Interval0 == nullInterval0 getInterval();
            var 
    xSymbol vSymbol+","+Interval0;

            if(
    myStudy0 == nullmyStudy0 offsetSeries(eval(Type0)(Length0,eval(Source0)(sym(xSymbol))),Offset);
            
    bInit true
        } 
        var 
    CloseVal close(0,sym(xSymbol));

        if (
    CloseVal myStudy0.getValue(0)){
                
    setBarBgColor(Color.RGB(255,255,192));
        } else if (
    CloseVal myStudy0.getValue(0)){
                
    setBarBgColor(Color.RGB(255,234,255));
        }

        return 
    getSeries(myStudy0).toFixed(2);

    Comment


    • #3
      Alex, thanks again,

      I'm starting to understand efs cycling, which should decrease my coding errors significantly.

      As always, your help is invaluable.

      Comment


      • #4
        waynecd
        You are most welcome
        Alex


        Originally posted by waynecd
        Alex, thanks again,

        I'm starting to understand efs cycling, which should decrease my coding errors significantly.

        As always, your help is invaluable.

        Comment

        Working...
        X