Announcement

Collapse
No announcement yet.

No Value - offsetSeries / getSeries of a variable

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

  • No Value - offsetSeries / getSeries of a variable

    If I use the following code, historical indicator-values are perfect, but at the moment of realtime working, there is only a horizontal line (see pic).

    for performance saving, I use setComputeOnClose, intrabar-values are not needed.

    PHP Code:
    function preMain()
    {
        
    setComputeOnClose();
    }


    function 
    main()

        return 
    offsetSeries(efsInternal("myCalc2"),2);



    function 
    myCalc() {return (sma(8)+sma(3))/2;}
    function 
    myCalc2() {return sma(2efsInternal("myCalc"));} 
    Attached Files
    Franz

  • #2
    Franz
    I would not recommend using setComputeOnClose() regardless of the issue we discussed in another thread
    If you are using setComnputeOnClose() to try to make your code more efficient then there are better ways IMHO to accomplish that. See the example enclosed below which is considerably more efficient than the one you posted even if it is not using setComputeOnClose()
    Alex

    PHP Code:
    function preMain(){
        
    //setComputeOnClose();
    }
     
    var 
    myVar0 null;
    function 
    main(){ 
        if(
    myVar0==nullmyVar0 offsetSeries(efsInternal("myCalc2"),2);
        return 
    myVar0.getValue(0);

     
    var 
    mySMA1 null;
    var 
    mySMA2 null;
    function 
    myCalc(){
        if(
    mySMA1==nullmySMA1 sma(8);
        if(
    mySMA2==nullmySMA2 sma(3);
        if(
    mySMA1.getValue(0)==null||mySMA2.getValue(0)==null) return;
        var 
    myVar1 = (mySMA1.getValue(0)+mySMA2.getValue(0))/2;
        return 
    myVar1;
    }
     
    var 
    myVar2 null;
    function 
    myCalc2(){
        if(
    myVar2==nullmyVar2 sma(2efsInternal("myCalc"));
        return 
    myVar2.getValue(0);

    Comment


    • #3
      Alex,

      thank you again for the outstanding help!

      if(...==null) works very well with only very few calls!

      setComputeOnClose() = history, I delete the line.
      Franz

      Comment


      • #4
        Franz
        You are most welcome
        Alex

        Comment

        Working...
        X