Announcement

Collapse
No announcement yet.

EFS Performace Monitor with getGlobalValue(0

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

  • EFS Performace Monitor with getGlobalValue(0

    Hi,

    I've run several tick replay tests using the EFS Performance Monitor to compare plotting several 3 min interval moving averages on a 55T chart.

    The comparisons are:

    creating series of the MAs using sym("ES #F, 3") in a 55T chart
    vs using getGlobalValue(...) to retrieve values and plot them on a 55T chart from a 3 min chart.

    Question:

    1- Since getGlobal() can only retrieve real time values (so the values retrived are constant throughout the tick playback): Are the results of the EFS Performance tests reliable?

    2- Is it possible to only plot the real time data without the horizontal lines plotted through historical bars (shown in the following image). Using the following has no effect.
    PHP Code:
    if(getBarState()== BARSTATE_ALLBARS) return; 
    Thanks,
    Wayne
    Attached Files
    Last edited by waynecd; 01-21-2010, 01:51 AM.

  • #2
    In case it is helpful here are some efs' I used in the tests:

    PHP Code:
    //SETGLOBALVALUE
    debugClear();

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("MA Set Globals");
        
    setShowTitleParameters(false);
    }
    var 
    bInit false
    var 
    myStudy0 null
    var 
    myStudy1 null
    var 
    myStudy2 null
    var 
    myStudy3 null
    var 
    myStudy4 null
    var 
    myStudy5 null

    function 
    main(){
        if ( 
    bInit == false ) { 
            if(
    myStudy1 == nullmyStudy1 sma(10);
            if(
    myStudy2 == nullmyStudy2 sma(15);
            if(
    myStudy3 == nullmyStudy3 sma(20);
            if(
    myStudy4 == nullmyStudy4 sma(25);
            if(
    myStudy5 == nullmyStudy5 sma(30);
          
    bInit true
        }
        
    setGlobalValue("vMA1",myStudy1.getValue(0));
        
    setGlobalValue("vMA2",myStudy2.getValue(0));
        
    setGlobalValue("vMA3",myStudy3.getValue(0));
        
    setGlobalValue("vMA4",myStudy4.getValue(0));
        
    setGlobalValue("vMA5",myStudy5.getValue(0));

    PHP Code:
    //GETGLOBALVALUE TEST1
    function preMain(){
    setPriceStudy(true);
    }
    var 
    bInit false;

    function 
    main(){
    //    if(getBarState() == BARSTATE_ALLBARS) return; //doesn't stop lines from plotting in historical bars   

        
    if(bInit==false){
            
    setDefaultBarFgColor(Color.RGB(128,0,0),0);
            
    setDefaultBarFgColor(Color.blue,1);
            
    setDefaultBarFgColor(Color.RGB(1270221),2);
            
    setDefaultBarFgColor(Color.green,3);
            
    setDefaultBarFgColor(Color.RGB(01280),4);
            
    setDefaultBarFgColor(Color.RGB(2551920),5);
            
    setDefaultBarThickness(2,0);
            
    setDefaultBarThickness(3,1);
            
    setDefaultBarThickness(4,2);
            
    setDefaultBarThickness(4,3);
            
    setDefaultBarThickness(3,4);
            
    setDefaultBarThickness(2,5);
            
    setDefaultBarStyle(PS_SOLID,0);
            
    setDefaultBarStyle(PS_SOLID,1);
            
    setDefaultBarStyle(PS_SOLID,2);
            
    setDefaultBarStyle(PS_SOLID,3);
            
    setDefaultBarStyle(PS_SOLID,4);
            
    setDefaultBarStyle(PS_DOT,5);
            
    bInit true;
        }
        
    xMA1 getGlobalValue"vMA5" );
        
    xMA2 getGlobalValue"vMA4" );
        
    xMA3 getGlobalValue"vMA3" );
        
    xMA4 getGlobalValue"vMA2" );
        
    xMA5 getGlobalValue"vMA1" );

        return new Array(
    xMA1,xMA2,xMA3,xMA4,xMA5,xMA5);


    PHP Code:
    //GETGLOBALVALUE TEST2
    function preMain(){
    setPriceStudy(true);
    }
    var 
    bInit false;
    var 
    MAs,xMA1,xMA2,xMA3,xMA4,xMA5;
    function 
    main(){
    //    if(getBarState() == BARSTATE_ALLBARS) return; //doesn't stop lines from plotting in historical bars   

        
    if(bInit==false){
            
    setDefaultBarFgColor(Color.RGB(128,0,0),0);
            
    setDefaultBarFgColor(Color.blue,1);
            
    setDefaultBarFgColor(Color.RGB(1270221),2);
            
    setDefaultBarFgColor(Color.green,3);
            
    setDefaultBarFgColor(Color.RGB(01280),4);
            
    setDefaultBarFgColor(Color.RGB(2551920),5);
            
    setDefaultBarThickness(2,0);
            
    setDefaultBarThickness(3,1);
            
    setDefaultBarThickness(4,2);
            
    setDefaultBarThickness(4,3);
            
    setDefaultBarThickness(3,4);
            
    setDefaultBarThickness(2,5);
            
    setDefaultBarStyle(PS_SOLID,0);
            
    setDefaultBarStyle(PS_SOLID,1);
            
    setDefaultBarStyle(PS_SOLID,2);
            
    setDefaultBarStyle(PS_SOLID,3);
            
    setDefaultBarStyle(PS_SOLID,4);
            
    setDefaultBarStyle(PS_DOT,5);
            
    MAs=efsInternal("getvalues");
            
    xMA1=getSeries(MAs,0);
            
    xMA2=getSeries(MAs,1);
            
    xMA3=getSeries(MAs,2);
            
    xMA4=getSeries(MAs,3);
            
    xMA5=getSeries(MAs,4);
            
    bInit true;
        }

        return new Array(
    xMA1,xMA2,xMA3,xMA4,xMA5,xMA5);
    }
    function 
    getvalues(){
        
    x1 getGlobalValue"vMA1" );
        
    x2 getGlobalValue"vMA2" );
        
    x3 getGlobalValue"vMA3" );
        
    x4 getGlobalValue"vMA4" );
        
    x5 getGlobalValue"vMA5" );
        return new Array(
    x1,x2,x3,x4,x5,x5);
        

    PHP Code:
    //SYM()
    debugClear();

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Test MA sym()");
        
    setShowTitleParameters(false);
    }
    var 
    bInit false
    var 
    myStudy0 null
    var 
    myStudy1 null
    var 
    myStudy2 null
    var 
    myStudy3 null
    var 
    myStudy4 null
    var 
    myStudy5 null
    var 
    Symbol null;
    var 
    Interval 3;
    function 
    main(){
        if ( 
    bInit == false ) { 
            
    setDefaultBarFgColor(Color.RGB(128,0,0),0);
            
    setDefaultBarFgColor(Color.blue,1);
            
    setDefaultBarFgColor(Color.RGB(1270221),2);
            
    setDefaultBarFgColor(Color.green,3);
            
    setDefaultBarFgColor(Color.RGB(01280),4);
            
    setDefaultBarFgColor(Color.RGB(2551920),5);
            
    setDefaultBarThickness(2,0);
            
    setDefaultBarThickness(3,1);
            
    setDefaultBarThickness(4,2);
            
    setDefaultBarThickness(4,3);
            
    setDefaultBarThickness(3,4);
            
    setDefaultBarThickness(2,5);
            
    setDefaultBarStyle(PS_SOLID,0);
            
    setDefaultBarStyle(PS_SOLID,1);
            
    setDefaultBarStyle(PS_SOLID,2);
            
    setDefaultBarStyle(PS_SOLID,3);
            
    setDefaultBarStyle(PS_SOLID,4);
            
    setDefaultBarStyle(PS_DOT,5);
            if(
    Symbol == nullSymbol getSymbol();
            if(
    Interval == "Default" || Interval == nullInterval getInterval();
            var 
    vSymbol Symbol+","+Interval;
            if(
    myStudy1 == null){
            
    myStudy1 sma(10,sym(vSymbol));
            
    myStudy1 getSeries(myStudy1);
            }
            if(
    myStudy2 == null){
            
    myStudy2 sma(15,sym(vSymbol));
            
    myStudy2 getSeries(myStudy2);
            }
            if(
    myStudy3 == null){
            
    myStudy3 sma(20,sym(vSymbol));
            
    myStudy3 getSeries(myStudy3);
            }
            if(
    myStudy4 == null){
            
    myStudy4 sma(25,sym(vSymbol));
            
    myStudy4 getSeries(myStudy4);
            }
            if(
    myStudy5 == null){
            
    myStudy5 sma(30,sym(vSymbol));
            
    myStudy5 getSeries(myStudy5);
            }
          
    bInit true
        }
        return new Array(
    myStudy1,myStudy2,myStudy3,myStudy4,myStudy5,myStudy5);

    Last edited by waynecd; 01-21-2010, 12:47 AM.

    Comment


    • #3
      Hi,

      To clarify.

      When I ask: if the EFS Performance are tests reliable I mean in the context of getGlobal returning a constant value over all historical values.

      1- Since getGlobal() can only retrieve real time values (so the values retrived are constant throughout the tick playback): Are the results of the EFS Performance tests reliable?
      wayne

      Comment


      • #4
        wayne,

        I did a lot of experimenting with set/getGlobalValue() awhile back.

        At first, I called setGlobalValue() and getGlobalValue() everytime main() was called. Then I realized objects passed to setGlobalValue() and returned by getGlobalValue() are by reference.

        If you call setGlobalValue(..., object), retrieve it from another EFS script via getGlobalValue(), and then modify the object in the first EFS script, the second EFS script will see the modified object!

        So now I think of set/getGlobalValue() as shared memory.

        For example:
        PHP Code:
        // Script 1

        var bInited false;

        var 
        myArray = [012];

        main () {
            if (! 
        bInited) {
                
        setGlobalValue ("myArray"myArray);
                
        myArray[1] = 9;
                
        bInited true;
            }

        PHP Code:
        // Script 2

        var bInited false;

        var 
        myArray null;

        main () {
            if (! 
        bInited) {
                
        myArray getGlobalValue ("myArray");
                
        debugPrintln ("myArray = " myArray);
                
        myArray[2] = 11;
                
        bInited true;
            }

        If you run Script 1 and then Script 2, even though myArray was modified after setGlobalValue, Script 2 will print out:

        myArray = 0,9,2

        If you run Script 2 a second time it will print out:

        myArray = 0,9,11

        Yep, even the EFS script that calls getGlobalValue can change the Global object without calling setGlobalValue! ...shared memory.

        Given the above, you might want to reconsider how you're using set/getGlobalValue(). You really only need to call set/getGlobalValue() once in your EFS.

        Caveats:

        1) Although everything in JavaScript is an object, I don't think numbers can be modified, only replaced. So, for all practical purposes numbers are passed by value and set/getGlobalValue must be called everytime. However, a 1-element Array can be used to get around this.

        2) I haven't tested set/getGlobalValue with Series Objects, custom objects, objects modified using prototype, etc.
        Last edited by shortandlong; 01-21-2010, 11:02 AM.

        Comment


        • #5
          Hi shortandlong,

          Great info, finally got it to work.

          Thanks,

          Wayne
          Last edited by waynecd; 01-21-2010, 03:45 PM.

          Comment

          Working...
          X