Announcement

Collapse
No announcement yet.

problem loading bars

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

  • problem loading bars

    so i have been pulling my hairs out trying to figure what was wrong with my code and i finally realized that the EFS is not loading all the bars, only about 200, when there are over 1000 on the chart

    any ideas why

    here is the EFS

    PHP Code:
    var myFlag null// 
    var a,b,c,d,e,v,w,x,y,z;

    var 
    high_3days=0;
    var 
    low_3days=1000000;   
    var 
    high_5days=0;
    var 
    low_5days=0;
    var 
    a_highs = new Array();
    var 
    a_lows= new Array();
    var 
    bar_counter;
    var 
    xDaily_h null;
    var 
    xDaily_l null;

    // 3 day/bar breakout alert 
    function preMain() {
        
    setPriceStudy(true);
        
    setShowTitleParametersfalse );
        
    setCursorLabelName("55 bar bo"0);
    grID 0;    

    }


    function 
    main( )

    // opening bracket



       
    }

    if(
    getBarState()==BARSTATE_ALLBARS)
    {
    xDaily_h high(inv("D"));
    xDaily_l low(inv("D")); 
    var 
    bint false;
    bar_counter 0;
    //a_highs = new Array(2,4,6,8,10);
    }
    if (
    bint == true)
    {
    bar_counter=0;
    bint=false;
    }
    if (
    bar_counter 50)
    {
    a_highs = new Array(a,b,c,d,e);
    a_lows = new Array(v,w,x,y,z);
    }


    // load only at beginning of a bar 
    if (getBarState()==BARSTATE_NEWBAR)
    {
    bar_counter++;
    xDaily_h.getValue(-1);
    xDaily_h.getValue(-2);
    xDaily_h.getValue(-3);
    xDaily_h.getValue(-4);
    xDaily_h.getValue(-5);    
        
      
    xDaily_l.getValue(-1);
    xDaily_l.getValue(-2);
    xDaily_l.getValue(-3);
    xDaily_l.getValue(-4);
    xDaily_l.getValue(-5);   
      



    //low_5daysdays= Math.min(v,w,x,y,z);  
     
    //high_3days = Math.max(a,b,c);
    //low_3days= Math.min(x,y,z);

    if ( a_highs != null);
    {
    //max_highs =33;
    for ( 0i3i++)
    {
    //var v = a_highs[i];
    if (a_highs[i] > high_3days)
    high_3days a_highs[i];
    }   
    }

    if ( 
    a_highs != null);
    {
    //max_highs =33;
    for ( 0i5i++)
    {
    //var v = a_highs[i];
    if (a_highs[i] > high_5days)
    high_5days a_highs[i];
    }   
    }


    if ( 
    a_lows != null);
    {
    //max_highs =33;
    for ( 0i3i++)
    {
    //var v = a_highs[i];
    if (a_lows[i] < low_3days)
    low_3days a_lows[i];
    }   
    }

    if ( 
    a_lows != null);
    {

    for ( 
    0i5i++)
    {
    if (
    a_lows[i] < low_5days)
    low_5days a_highs[i];
    }   
    }





    // end of current bar state


    // start of after newbar

    if( high(0) > high_3days)
    {
    myFlag "Abv 3 D";
    setBarFgColor(Color.black,0);
    setBarBgColor(Color.RGB(192,255,160));
    debugPrintln("ulow of 3 days ="  " bar counter " bar_counter);
    }
    else if (
    low(0) < low_3days)
    {
    myFlag "Blw 3 D";
    setBarFgColor(Color.white,0);
    setBarBgColor(Color.RGB(255,160,160));
    //debugPrintln("downn");
    }
    else
    {
    myFlag "Inside ";
    setBarFgColor(Color.black,0);
    setBarBgColor(Color.lightgrey,0);
    //debugPrintln("Not up or down");
    }


    return new Array(
    myFlag);

    // closing bracket of main


    // Supporting Functions 

  • #2
    Re: problem loading bars

    eurostoxx

    ... i finally realized that the EFS is not loading all the bars, only about 200, when there are over 1000 on the chart
    Are you stating the above based on the count shown in the Formula Output Window? If that is the case then keep in mind that it is the count at the last bar in which the condition if( high(0) > high_3days) is true and not the count across all the bars in the chart.
    Alex


    Originally posted by eurostoxx
    so i have been pulling my hairs out trying to figure what was wrong with my code and i finally realized that the EFS is not loading all the bars, only about 200, when there are over 1000 on the chart

    any ideas why

    here is the EFS

    PHP Code:
    var myFlag null// 
    var a,b,c,d,e,v,w,x,y,z;

    var 
    high_3days=0;
    var 
    low_3days=1000000;   
    var 
    high_5days=0;
    var 
    low_5days=0;
    var 
    a_highs = new Array();
    var 
    a_lows= new Array();
    var 
    bar_counter;
    var 
    xDaily_h null;
    var 
    xDaily_l null;

    // 3 day/bar breakout alert 
    function preMain() {
        
    setPriceStudy(true);
        
    setShowTitleParametersfalse );
        
    setCursorLabelName("55 bar bo"0);
    grID 0;    

    }


    function 
    main( )

    // opening bracket



       
    }

    if(
    getBarState()==BARSTATE_ALLBARS)
    {
    xDaily_h high(inv("D"));
    xDaily_l low(inv("D")); 
    var 
    bint false;
    bar_counter 0;
    //a_highs = new Array(2,4,6,8,10);
    }
    if (
    bint == true)
    {
    bar_counter=0;
    bint=false;
    }
    if (
    bar_counter 50)
    {
    a_highs = new Array(a,b,c,d,e);
    a_lows = new Array(v,w,x,y,z);
    }


    // load only at beginning of a bar 
    if (getBarState()==BARSTATE_NEWBAR)
    {
    bar_counter++;
    xDaily_h.getValue(-1);
    xDaily_h.getValue(-2);
    xDaily_h.getValue(-3);
    xDaily_h.getValue(-4);
    xDaily_h.getValue(-5);    
        
      
    xDaily_l.getValue(-1);
    xDaily_l.getValue(-2);
    xDaily_l.getValue(-3);
    xDaily_l.getValue(-4);
    xDaily_l.getValue(-5);   
      



    //low_5daysdays= Math.min(v,w,x,y,z);  
     
    //high_3days = Math.max(a,b,c);
    //low_3days= Math.min(x,y,z);

    if ( a_highs != null);
    {
    //max_highs =33;
    for ( 0i3i++)
    {
    //var v = a_highs[i];
    if (a_highs[i] > high_3days)
    high_3days a_highs[i];
    }   
    }

    if ( 
    a_highs != null);
    {
    //max_highs =33;
    for ( 0i5i++)
    {
    //var v = a_highs[i];
    if (a_highs[i] > high_5days)
    high_5days a_highs[i];
    }   
    }


    if ( 
    a_lows != null);
    {
    //max_highs =33;
    for ( 0i3i++)
    {
    //var v = a_highs[i];
    if (a_lows[i] < low_3days)
    low_3days a_lows[i];
    }   
    }

    if ( 
    a_lows != null);
    {

    for ( 
    0i5i++)
    {
    if (
    a_lows[i] < low_5days)
    low_5days a_highs[i];
    }   
    }





    // end of current bar state


    // start of after newbar

    if( high(0) > high_3days)
    {
    myFlag "Abv 3 D";
    setBarFgColor(Color.black,0);
    setBarBgColor(Color.RGB(192,255,160));
    debugPrintln("ulow of 3 days ="  " bar counter " bar_counter);
    }
    else if (
    low(0) < low_3days)
    {
    myFlag "Blw 3 D";
    setBarFgColor(Color.white,0);
    setBarBgColor(Color.RGB(255,160,160));
    //debugPrintln("downn");
    }
    else
    {
    myFlag "Inside ";
    setBarFgColor(Color.black,0);
    setBarBgColor(Color.lightgrey,0);
    //debugPrintln("Not up or down");
    }


    return new Array(
    myFlag);

    // closing bracket of main


    // Supporting Functions 

    Comment


    • #3
      thanks for the reply... sorry though I am not 100% clear on what you mean...

      I thought (and correct me if I am wrong), that the:

      if( high(0) > high_3days)

      and all the other 'else' stmts, will run on every new bar, since it is not enclsed in the "current_bar state".

      are you saying that the if stmt will only run until it returns "true" 1 time, and then after that stop?

      if so, then I would just need to enclose the if statmnt in BarState_Currentbar? I tried that but nothing happens (really the EFS doesnt do anything)

      i just want the if statments to run on every new bar/ tick. The counter is only there to initialize the array after a few bars pass, since otherwise i get an error message

      Comment


      • #4
        its also wierd since i wrote a test script to see if there is something wrong, but this (below) EFS loads all the bars

        I am really stuck as to what I am doing wrong in the fist EFS but not the 2nd

        PHP Code:
        var a,b,c,d,e,v,w,x,y,z;
        var 
        bar_counter=0;
        var 
        xDaily_h null;
        var 
        xDaily_l null;

        function 
        preMain() {}


        function 
        main( )
        {

        if(
        getBarState()==BARSTATE_ALLBARS)
        {
        xDaily_h high(inv("D"));
        xDaily_l low(inv("D")); 
        }

        if (
        getBarState()==BARSTATE_NEWBAR)
        {
        bar_counter++;
        xDaily_h.getValue(-1);
        xDaily_h.getValue(-2);
        xDaily_h.getValue(-3);
        xDaily_h.getValue(-4);
        xDaily_h.getValue(-5);    
            }
            
            
            
        debugPrintln" bar counter " bar_counter  ); 
            
            } 

        Comment


        • #5
          eurostoxx

          thanks for the reply... sorry though I am not 100% clear on what you mean...
          I thought (and correct me if I am wrong), that the:
          if( high(0) > high_3days)
          and all the other 'else' stmts, will run on every new bar, since it is not enclsed in the "current_bar state".
          That conditional statement [as well as the ones that follow it] is evaluated once per bar on historical bars and then on every tick in real time however the debugPrintln included in it is executed only when that statement is true hence the value of bar_counter [which is increased once every bar] will reflect the count at that bar.
          If you want to verify the total count then add a debug statement immediately after you increase bar_counter by 1 on each bar
          Alex


          Originally posted by eurostoxx
          thanks for the reply... sorry though I am not 100% clear on what you mean...

          I thought (and correct me if I am wrong), that the:

          if( high(0) > high_3days)

          and all the other 'else' stmts, will run on every new bar, since it is not enclsed in the "current_bar state".

          are you saying that the if stmt will only run until it returns "true" 1 time, and then after that stop?

          if so, then I would just need to enclose the if statmnt in BarState_Currentbar? I tried that but nothing happens (really the EFS doesnt do anything)

          i just want the if statments to run on every new bar/ tick. The counter is only there to initialize the array after a few bars pass, since otherwise i get an error message

          Comment


          • #6
            ok so I think i have narrowed the problem

            i am unsure as to where to initialized my custom array in the code.. i want to use it on a 15/30min chart, and I want the array to have 5 days H/L values so I though I would need to get about 50-100 bars before i call the getvalue, so that is why I put the counter in

            but now i cant seem to figure out where to declare the variable (i thought above the premain) and then intialize the array within the new bar when counter > 100

            but even if I try that , as

            a_highs[3] = c; (where a_high is the array for highs)

            i get an error

            Comment


            • #7
              finally got it.... my for loop, to find the high/ low vale was the problem!

              wow what a waste of time on a stupid little thing!

              Comment

              Working...
              X