Announcement

Collapse
No announcement yet.

Convert Array to a Series object

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

  • Convert Array to a Series object

    Is there a way to convert an array into a series object?

    On a bar chart I am generating a Renko series in an array. I only add values to the array as new Renko bricks are needed. I would like to use this array as an input to indicator series such as sma(). But the indicators will only take a series object as input.

    I have tried calling a function using efsInternal each time I add a brick to the array, but it gets really slow. It does generate a series, but the performance is unacceptable. It seems to essentially reload the chart every time I call efsInternal.

    Is there a faster way to do this?

    It seems like there should be a series method to add values to a series. Like the reverse of getValue().

    Thanks,

    Steve

  • #2
    Re: Convert Array to a Series object

    Hello Steve,

    Originally posted by smeyer55
    Is there a way to convert an array into a series object?

    On a bar chart I am generating a Renko series in an array. I only add values to the array as new Renko bricks are needed. I would like to use this array as an input to indicator series such as sma(). But the indicators will only take a series object as input.
    There isn't a method for converting an array into a series object. A series object is a enhanced array that contains data for each bar in the chart. If your renko array has an array element that corresponds with each bar, then you should be able to place the logic inside a function called by efsInternal(). The called function may return a single value or an array of values.

    If the elements of your renko array do not have a corresponding element for each bar in the chart, then you're probably not going to be able to place this array into series object form. In order to calculate an sma of your renko array you will need to code this manually.

    I have tried calling a function using efsInternal each time I add a brick to the array, but it gets really slow. It does generate a series, but the performance is unacceptable. It seems to essentially reload the chart every time I call efsInternal.

    Is there a faster way to do this?
    What is probably happening here is that you are passing a different set of values as parameters in the efsInternal() call. This will generate a new instance of a series object each time a new set of parameter values are passed to it. It's not reloading the formula, but each initialization of the newest series is processing all of the data in the chart. It's the same as reinitializing a sma() series a number of times each with a different length value. A series created using efsInternal() should only be allowed to initialize once.

    PHP Code:
    var mySeries null;

    function 
    main() {
        if (
    mySeries == nullmySeries efsInternal("function"params);
        ....

    It seems like there should be a series method to add values to a series. Like the reverse of getValue().

    Thanks,

    Steve
    Only the logic used within the called function by efsInternal() can be used to add values to it's corresponding series. The values in the return statement of the called function determines the values added to the series.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Thanks for explaining how efsInternal works Jason. It helped me understand what was going on.

      You are correct that I was passing different variables to the efsInternal function.

      Unfortunately, returning a value for each bar doesn't generate the correct indicators. If a Renko box lasts for 10 bars, the 10 period sma of the Renko series goes flat because it uses the same 10 values instead of 10 boxes back.

      Looks like I have to do some coding of indicators.

      Thanks for the help.

      Steve

      Comment


      • #4
        You're most welcome.
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment

        Working...
        X