Announcement

Collapse
No announcement yet.

Retrieving [Historical] values in an Array generated with efsInternal

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Retrieving [Historical] values in an Array generated with efsInternal

    This is a continuation of my previous post.

    Alex,

    I will summarize what I understood from other posts, please confirm is true or correct me:

    1. Yes, we can return arrays with efsInternal.
    2. efsInternal will generate a multi-dimesional array that can be accessed only using first "getSeries" to create individual series objects
    3. After those series objects are created, we can retireve historical values using getValue.

    In other words, we cannot access directly the multi-dimensional array created with efsInternal same way we access other arrays we generate.
    For example, if
    var MyEfsInternalStudy = efsInternal("MyFunction");
    generates multiple series, we cannot do
    var MyHistVal_Y_X = MyEfsInternalStudy[x][y],
    where x is the BarIndex and y is the SeriesIndex.
    nor we can use an EFS1 like syntax [as I expected to be available]
    var MyHistVal_Y_X = getSeries(MyEfsInternalStudy.getValue(x),y)
    or something similar, because (a) efsInternal does not return an object but an array and (b) getSeries accepts only one parameter.

    Instead, must do it in two steps [except for the first series]
    Step1: Generate the individual series objects
    var MySubStudy1 = getSeries(MyEfsInternalStudy,0);
    var MySubStudy2 = getSeries(MyEfsInternalStudy,1);
    ...
    var MySubStudyY = getSeries(MyEfsInternalStudy,y);

    Step2: Retrieve historical values for the Y study, as for any other study [using BarIndex, negative value]
    var MyHistVal_Y_X = MySubStudyY.getValue(x),

    Is my understanding correct?
    NOTE: Maybe returning an array of objects with efsInternal [like EFS1 does] is not a bad idea. It would preserve EFS2 ease of use with the flexibility in EFS1.

    Thank you
    Last edited by mbuta; 11-22-2007, 09:41 AM.
    Mihai Buta

  • #2
    Mihai

    Step1: Generate the individual series objects
    var MySubStudy1 = getSeries(MyEfsInternalStudy,0);
    var MySubStudy2 = getSeries(MyEfsInternalStudy,1);
    ...
    var MySubStudyY = getSeries(MyEfsInternalStudy,y);

    Step2: Retrieve historical values for the Y study, as for any other study [using BarIndex, negative value]
    var MyHistVal_Y_X = MySubStudyY.getValue(x),

    Is my understanding correct?
    Your understanding is correct.

    NOTE: Maybe returning an array of objects with efsInternal [like EFS1 does] is not a bad idea. It would preserve EFS2 ease of use with the flexibility in EFS1.
    Actually during the development of EFS2 that and other solutions were tried but they did not return consistent results besides not being as efficient as the solution that was eventually adopted.
    Alex

    Comment


    • #3
      Thank you Alex.

      Unfortunatelly, getSeries is a very time consuming in real time [we went through this before] and not very practical in busy charts [many studies] in real time.
      Last edited by mbuta; 11-26-2007, 05:32 PM.
      Mihai Buta

      Comment


      • #4
        Mihai
        You are most welcome
        Keep in mind that you do not need to retrieve a series on every tick unless you want the formula engine to maintain the plot continuously synchronized on external intervals and/or symbols. You can initialize and retrieve each series once only inside a bInit routine or at BARSTATE_ALLBARS and then just retrieve the values using the getValue() method.
        Alex


        Originally posted by mbuta
        Thank you Alex.

        Unfortunatelly, getSeries is a very time consuming in real time [we went through this before] and not very practical in busy charts [many studies] in real time.

        Comment


        • #5
          Alex, thank you for clarification but this leavs me a little confused [most likely, because I am a novice programmer].
          I thought that "initilize" the series, means actually "extract" the series from the array.
          With what you said in the last post, looks like, after we "initialized" the series, we can "extract" subsequent values [from the array, because I assume efs continues to put the values in the same array], using getValue [which is a method not for arrays, but for objects].

          Am I missing something? Can we really "extract" new values [in real time] directly from that [efsInternal generated] array?
          Because, if true, the performance issue fades away.

          Thank you.
          Mihai Buta

          Comment


          • #6
            Mihai
            You can retrieve each series using the getSeries() function inside a bInit routine or at BARSTATE_ALLBARS
            This will occurr once only (when the formula is first loaded or reloaded) at which point you can retrieve the values from these series objects using the getValue() method
            Alex


            Originally posted by mbuta
            Alex, thank you for clarification but this leavs me a little confused [most likely, because I am a novice programmer].
            I thought that "initilize" the series, means actually "extract" the series from the array.
            With what you said in the last post, looks like, after we "initialized" the series, we can "extract" subsequent values [from the array, because I assume efs continues to put the values in the same array], using getValue [which is a method not for arrays, but for objects].

            Am I missing something? Can we really "extract" new values [in real time] directly from that [efsInternal generated] array?
            Because, if true, the performance issue fades away.

            Thank you.

            Comment


            • #7
              Thank you Alex.
              It is very lear now for historycal values. I will start a new thread for subsequent values in real time.
              Mihai Buta

              Comment


              • #8
                Mihai
                You are most welcome
                As to retrieving real time values you just use the same getValue() method with a bar index of 0 on the same series [that you have already retrieved using getSeries() inside the bInit routine or at ALLBARS] which will return the value currently calculated by the called function or efs
                Alex


                Originally posted by mbuta
                Thank you Alex.
                It is very lear now for historycal values. I will start a new thread for subsequent values in real time.

                Comment

                Working...
                X