Announcement

Collapse
No announcement yet.

Custom roperties for builtin studies objects

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

  • Custom roperties for builtin studies objects

    I am trying to define some new methods [not properties] to builtin studies [like cci, for example].
    I tried same property, same syntax, as described in documentation.
    I could do it for EFS1 studies [CCIStudy], but not for EFS2 studies [cci].

    Can anyone explain why this can hapen?
    The only thing I can think of is that [I assume] cci is already defined as a "prototype" of CCIStudy and cannot define "prototype-to-prototype".

    Thank you.

    Note: Sorry for the "typo" in title.
    Last edited by mbuta; 08-21-2012, 09:15 PM.
    Mihai Buta

  • #2
    To clarify here is the sample code:

    //var rCCI = CCIStudy.prototype;
    //rCCI.XX getter = function() { return this.getValue(CCIStudy.CCI)/2; }; //This works fine when later called for any declared CCIStudy
    //var vCCI3 = new CCIStudy(3, "Close"); => vCCI3 .XX returns correct value.

    Same thing for cci does not
    //var rCCI1 = cci.prototype;
    //rCCI1.XX1 getter = function() { return this.getValue(0)/2; };
    //var vCCI3 = cci(3); => vCCI3 .XX1 returns null.
    Mihai Buta

    Comment


    • #3
      From what I am seeing the reason your second example is not working is because you are not using the object constructed by the cci() function.
      If you run a simple debug check on vCCI3 you will see that while the CCIStudy() function constructs an object called CCIStudy the cci() function constructs an object called Series and not cci. BTW I believe this is explained [at least in my understanding of it] in this article in the EFS KnowledgeBase and is applicable also to any other efs2 function that creates a series.
      Hence all you need to do is replace cci.prototype with Series.prototype and your code will work as expected
      Alex



      P.S. I also sent you a Private Message with a alternative/simplified version of the above

      Originally posted by mbuta View Post
      To clarify here is the sample code:

      //var rCCI = CCIStudy.prototype;
      //rCCI.XX getter = function() { return this.getValue(CCIStudy.CCI)/2; }; //This works fine when later called for any declared CCIStudy
      //var vCCI3 = new CCIStudy(3, "Close"); => vCCI3 .XX returns correct value.

      Same thing for cci does not
      //var rCCI1 = cci.prototype;
      //rCCI1.XX1 getter = function() { return this.getValue(0)/2; };
      //var vCCI3 = cci(3); => vCCI3 .XX1 returns null.

      Originally posted by mbuta View Post
      I am trying to define some new methods [not properties] to builtin studies [like cci, for example].
      I tried same property, same syntax, as described in documentation.
      I could do it for EFS1 studies [CCIStudy], but not for EFS2 studies [cci].

      Can anyone explain why this can hapen?
      The only thing I can think of is that [I assume] cci is already defined as a "prototype" of CCIStudy and cannot define "prototype-to-prototype".

      Thank you.

      Note: Sorry for the "typo" in title.

      Comment


      • #4
        It seems that this example no longer works with ver 12.xx.
        Does getter still work with the newer versions?

        The following code returns error:
        "line 2: SyntaxError: missing ; before statement rCCI1.XX1 getter = function() { return this.getValue(0/2; };"
        PHP Code:
        var rCCI1 Series.prototype;
        rCCI1.XX1 getter = function() { return this.getValue(0/2; };
        var 
        vCCI3 cci(3);
        function 
        main(){
           return 
        vCCI3.XX1;

        Comment

        Working...
        X