Announcement

Collapse
No announcement yet.

Questions on 7.9.1 efsInternal [2]

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

  • Questions on 7.9.1 efsInternal [2]

    Q2. Are there any restrictions in mixing studies in function called with efsInternal?
    If not, can anybody help me understand why I get incorrect results in the following setup?

    function main() {
    stAvBar = efsInternal("CalcAvBarF"); //This behaves as expected.
    stBB = new BollingerStudy(Per, Source, Dev);
    stBand = efsInternal("CalcBandF", stBB, stAvBar);

    return stBand.getValue();
    }

    function CalcBandF(BBStudy, AvBarStudy) {
    var BBH = BBStudy.getValue(BollingerStudy.UPPER);
    var BBL = BBStudy.getValue(BollingerStudy.LOWER);
    var Bar = AvBarStudy.getValue();
    return (BBH-BBL)/Bar;
    }

    If I do not create a series, but call the [almost] same function each bar, I get correct results. Here is how:

    function main() {
    stAvBar = efsInternal"CalcAvBarF"); //Same as above
    stBB = New BollingerStudy(Per, Source, Dev); //Same as above
    var AvBar = AvBarStudy.getValue(); //Actually, this is a global var
    var Band = CalcBand(BBStudy, AvBar); //This is ok, but not a series

    return Band;
    }

    function CalcBandF(BBStudy, Bar) {
    //Same calculation and return
    }

    Thank you,
    Mihai
    Mihai Buta

  • #2
    Mihai
    If you want others to look over your code please post working examples as suggested in the Posting Guidelines for EFS Studies Forums
    Alex

    Comment


    • #3
      Alex,

      Thnak you.
      My question was in principle to know that it should work. If yes, then I try to debug it myself before asking for help with my code.

      In this particular case, I solved the problem. Looks like even EFS developers forget to check for nulls, here and there.

      getValue() does not work.
      getValue(0) works fine.

      I will check the other one now, to see if there is any change.
      Note: I wanted to post this last night but system did not work.

      Thank you.

      Mihai
      Mihai Buta

      Comment


      • #4
        Mihai
        It does work (I have verified this using my own script).
        As to getValue() vs getValue(0) both will work and will return the same value (see image below created using the enclosed script)
        Alex

        PHP Code:
        function preMain() {
            
        setPriceStudy(false);
            
        setStudyTitle("CCI");
            
        setCursorLabelName("getValue()"0);
            
        setCursorLabelName("getValue(0)"1);
            
        setDefaultBarFgColor(Color.blue0);
            
        setDefaultBarFgColor(Color.red1);
        }

        function 
        main() {

            var 
        vCCI cci(20);

            return new Array (
        vCCI.getValue(), vCCI.getValue(0))

        Comment


        • #5
          Alex,

          I agree, in principle should work, and many times does work.
          But sometimes it does not and I encoutered that several times already.

          If it helps anybody, I will keep an eye on that and submit the example.

          Mihai
          Mihai Buta

          Comment

          Working...
          X