Announcement

Collapse
No announcement yet.

inv() and setIntervalsBackfill(true) problem

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

  • inv() and setIntervalsBackfill(true) problem

    We're trying to determine the market price every 15 seconds from the START of each candle historically on a one hour currency (GBP) chart and are running into two problems. The program is below ...

    PHP Code:
    var bInit false;
    var 
    hourSeries;
    var 
    minuteSeries;
    var 
    secondSeries;
    var 
    openSeries;
    var 
    mySeries;
    var 
    barCount 0;
    var 
    data 0;
    var 
    nodata 0;

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("15S INTERVAL TEST");
        
    setShowTitleParameters(false);
        
    setIntervalsBackfill(true);
    }

    function 
    main() {
        if (!
    bInit) {
                if (!
    mySeries) {
                     
    mySeries efsInternal("subSeries"inv("15s"));
               }
            
    hourSeries getSeries(mySeries0);
            
    minuteSeries getSeries(mySeries1);
            
    secondSeries getSeries(mySeries2);
            
    openSeries getSeries(mySeries3);
            
    bInit true;
        }

        if (
    getBarState() === BARSTATE_NEWBAR) {
            
    barCount getCurrentBarCount();
            
    debugPrintln("NEW CANDLE - " barCount "\n");
            
    239;        //// there are 240 15 second intervals in a one hour candle so each new candle
                        //// we start at the beginning of the previous candle and ask for open price 
                        //// every 15 seconds till the hour is 15 seconds from being over.
            
    while(>= 0){
                var 
    openVar null;
                var 
    hourVar hourSeries.getValue(-n);
                var 
    minuteVar minuteSeries.getValue(-n);
                var 
    secondVar secondSeries.getValue(-n);
                var 
    openVar openSeries.getValue(-n);
                
    debugPrintln(barCount " candle, time is " hour(0) + ":" minuteVar ":"+secondVar  ", open is " openVar "\n");
                
    n--;
            }
            if(
    openVar == nullnodata++;
            if(
    openVar != nulldata++;
            
    debugPrintln(barCount " Candles, " data " with data, " nodata ", without\n");

        }
    }                                                    
    function 
    subSeries() {
        return [
    hour(0), minute(0), second(0), open(0)];

    Problem 1: Only 286 candles of the total 3158 have any data, prior to the last 286 candles, values are returned as null.




    Is this all the data available using "setIntervalsBackfill(true)" ?

    Problem 2: Some of the data returned is incorrect or out of sequence.



    In most instances the data is correct and the problem seems to arise primarily around the beginning of a new candle.
    Any idea what we might be doing wrong or is this a bug in the call or an error in the data.

    Because we are using setIntervalsBackfill(true) , the program can take about 40 minutes to run the first time with every available candles showing on the chart.

    Thank you for any ideas on either or both of these problems.
Working...
X