Announcement

Collapse
No announcement yet.

Calling efsExternal real time

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

  • Calling efsExternal real time

    I am trying to call from an indicator running on intraday data an external study calculating on daily data. The external study returns three values It seems to work on historical bars but in real time it gets confused, especially at the change of the day.

    The code looks like this:

    var xMyStudy=null;
    var MyStudy10=null;
    var MyStudy11=null;
    var MyStudy12=null;
    var MyVar=-1;
    var aMyArray= new Array(3);
    var bInit=false;

    function main(input1,input2){
    var vState = getBarState();
    if(vState == BARSTATE_ALLBARS)
    {
    if (bInit==false){
    if (xMyStudy == null) xMyStudy = efsExternal( "MyStudy.efs", input1,input2,inv("D") ) ;
    bInit=true;
    }//end bInit

    }//end if FIRST BAR

    if(vState == BARSTATE_NEWBAR)
    {
    if (xMyStudy != null) {
    if (MyStudy10 != null)
    MyVar=MyStudy10[0];
    else if (MyStudy10 == null)
    MyStudy10 = getSeries( xMyStudy, 0 );

    if (MyStudy11 == null)
    MyStudy11 = getSeries( xMyStudy, 1 );
    if (MyStudy12 == null)
    MyStudy12 = getSeries( xMyStudy, 2 );
    } // end xMyStudy !=null


    aMyArray[0]=MyStudy 10.getValue(0);
    aMyArray[1]=MyStudy 11.getValue(0);
    aMyArray[2]=MyStudy 12.getValue(0);

    }//end if EACH BAR

    return aMyArray;

    }//end Main

    My guess is that it is not calling updates to the daily study at the right time.
    Any ideas?????

    Thanks,

  • #2
    I don't know if this will work because there isn't enough information to test it but try this:

    PHP Code:
    var xMyStudy null;
    var 
    MyStudy10 null;
    var 
    MyStudy11 null;
    var 
    MyStudy12 null;
    var 
    MyVar = -1;
    var 
    aMyArray = new Array(3);
    var 
    bInit false;

    function 
    main(input1input2) {
        var 
    vState getBarState();
       
    // if (vState == BARSTATE_ALLBARS) {//redundant
            
    if (bInit == false) {//this block will limit execution to once when the script is first loaded
                
    if (xMyStudy == nullxMyStudy efsExternal("MyStudy.efs"input1input2inv("D"));
                
    MyStudy10 getSeries(xMyStudy0);//assuming MyStudy.efs returns 3 numerical series
                
    MyStudy11 getSeries(xMyStudy1);//these series are called for within the bInit block
                
    MyStudy12 getSeries(xMyStudy2);
                
    bInit true;
            } 
    //end bInit

        //} //end if FIRST BAR
        
    if (xMyStudy == null) return;
        if (
    vState == BARSTATE_NEWBAR) {
            
    aMyArray[0] = MyStudy 10. getValue(0);
            
    aMyArray[1] = MyStudy 11. getValue(0);
            
    aMyArray[2] = MyStudy 12. getValue(0);
        } 
    //end if EACH BAR 

        
    return aMyArray;

    //end Main 
    Wayne
    Last edited by waynecd; 12-07-2015, 08:03 PM.

    Comment

    Working...
    X