Announcement

Collapse
No announcement yet.

efsInternal call/return question

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

  • efsInternal call/return question

    I want to call this function on the last bar of the chart.

    I really do NOT want a series ( it chews up cpu cycles ) but I was following the example I found.

    What is the proper call/return?

    So far:

    PHP Code:


        
    if (bInit == false) {

            
    xRocket efsInternal("fRocket"iBarsclose());

            
    xTank   efsInternal("fTank"iBarsclose());

            
    bInit true;
        } 

    And

    PHP Code:

    // ROCKET FUNCTION

    function fRocket(lengthprice) {

        var 
    MyVal 0;
        var 
    MyBar 0;
        var 
    n;
        var 
    fStop length 

      if( 
    fStop && fStop 20 ) {
        for(
    n=1;n<fStop;n++) {
           var 
    price.getValue(0) - price.getValue(-n) ;
           if( 
    MyVal) {
             
    MyVal ;
             
    MyBar ;
           }
          }
         }
     
    return new Array( 
    getSeries(MyVal), getSeries(MyBar) ) ;


    Thanking You In Advance.

    P.S. what this will do is alert me when an instrument rises a threshold amount within a certain number of bars.

  • #2
    Re: efsInternal call/return question

    Hello Avery,

    Originally posted by buzzhorton
    I want to call this function on the last bar of the chart.

    I really do NOT want a series ( it chews up cpu cycles ) but I was following the example I found.

    What is the proper call/return?

    So far:

    PHP Code:


        
    if (bInit == false) {

            
    xRocket efsInternal("fRocket"iBarsclose());

            
    xTank   efsInternal("fTank"iBarsclose());

            
    bInit true;
        } 

    And

    PHP Code:

    // ROCKET FUNCTION

    function fRocket(lengthprice) {

        var 
    MyVal 0;
        var 
    MyBar 0;
        var 
    n;
        var 
    fStop length 

      if( 
    fStop && fStop 20 ) {
        for(
    n=1;n<fStop;n++) {
           var 
    price.getValue(0) - price.getValue(-n) ;
           if( 
    MyVal) {
             
    MyVal ;
             
    MyBar ;
           }
          }
         }
     
    return new Array( 
    getSeries(MyVal), getSeries(MyBar) ) ;


    Thanking You In Advance.

    P.S. what this will do is alert me when an instrument rises a threshold amount within a certain number of bars.
    If you don't need the results in a Series Object then you can just call the fRocket function directly from within main(). To prevent the function or main() from executing until bar 0 you can check for the bar index of 0 using getCurrentBarIndex() and exit the formula if it is less than 0. Try the following.

    PHP Code:
    function main() {
        if (
    getCurrentBarIndex() < 0) return; // exit unless on bar 0.
        
        
    var length 10;
        var 
    price close();    
        var 
    aValues fRocket(lengthprice);
        if (
    aValues == null) return;
        
        return new Array(
    aValues[0], aValues[1]);    
    }

    function 
    fRocket(lengthprice) {

        var 
    MyVal 0;
        var 
    MyBar 0;
        var 
    n;
        var 
    fStop length 

        if( 
    fStop && fStop 20 ) {
            for(
    n=1;n<fStop;n++) {
                var 
    price.getValue(0) - price.getValue(-n) ;
                if( 
    MyVal) {
                    
    MyVal ;
                    
    MyBar ;
                }
            }
        }
     
        return new Array(
    MyValMyBar);

    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
      Thanks Jason...

      Now I can continue with this study.

      Comment

      Working...
      X