Announcement

Collapse
No announcement yet.

Questions about data from high(), low() and close()

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

  • Questions about data from high(), low() and close()

    I have been writing a new script and have found that when the main is called it takes a certain period of time for calls to high(), low() and close() to return valid data.

    I used the following script to produce this...

    ---------------------------------------------
    var it=0;

    function preMain() {
    setPriceStudy(false);
    setStudyTitle("CCI Test");
    setCursorLabelName("CCI", 0);
    setDefaultBarFgColor(Color.blue, 0);
    setPlotType(PLOTTYPE_HISTOGRAM,0);
    setDefaultBarThickness(1,0);
    addBand(100, PS_SOLID, 2, Color.black,"Upper");
    addBand(-100, PS_SOLID, 2, Color.black,"Lower");
    }

    function main() {
    it+=1;
    debugPrintln("high: " + high(0) + ", low: " + low(0) + ", iteration: " + it);
    return cci(20);
    }

    ---------------------------------------------

    Around iteration 1315 the real values are being returned - on all previous calls values ranging from +/- 5 are returned.


    Has anybody any idea why this might be happening?

    Thanks.

  • #2
    intradezone
    FWIW at my end the script is returning the correct values from the first bar/iteration (see enclosed screenshot)
    You may want to provide some more details as to how you are running the script (preferably including a screenshot illustrating the issue)
    Alex




    Originally posted by intradezone
    I have been writing a new script and have found that when the main is called it takes a certain period of time for calls to high(), low() and close() to return valid data.

    I used the following script to produce this...

    ---------------------------------------------
    var it=0;

    function preMain() {
    setPriceStudy(false);
    setStudyTitle("CCI Test");
    setCursorLabelName("CCI", 0);
    setDefaultBarFgColor(Color.blue, 0);
    setPlotType(PLOTTYPE_HISTOGRAM,0);
    setDefaultBarThickness(1,0);
    addBand(100, PS_SOLID, 2, Color.black,"Upper");
    addBand(-100, PS_SOLID, 2, Color.black,"Lower");
    }

    function main() {
    it+=1;
    debugPrintln("high: " + high(0) + ", low: " + low(0) + ", iteration: " + it);
    return cci(20);
    }

    ---------------------------------------------

    Around iteration 1315 the real values are being returned - on all previous calls values ranging from +/- 5 are returned.


    Has anybody any idea why this might be happening?

    Thanks.

    Comment


    • #3
      strange hi lo close open data feed

      Hi Alex,

      Thanks for your reply; much appreciated.

      In your screenshot it is interesting to note that there is significant variance (away from true price value) on Iteration 2; your script shows exactly what we are finding...

      The way we are running our script is to place the efs file in the local dir and then right click on the chart (real time data fed) and then select the script to run. Pretty much the usual way I hope.

      Unforunately we are baffled as to why the data feed seems to show 'spurious' price values on hi lo close open until a large number of ticks has passed??

      Do you have any further ideas?

      Thanks in advance,
      Matt and Warwick.

      Comment


      • #4
        Re: strange hi lo close open data feed

        Matt and Warwick

        In your screenshot it is interesting to note that there is significant variance (away from true price value) on Iteration 2;
        I am not sure what you mean with this. Iteration 2 is reporting the values of the second oldest bar in the chart and again (as far as I can see) these values are correct. In the screenshot enclosed below the vertical cursor is on the second bar in the chart and the High and Low values reported in the Formula Output Window are the same as those reported in the Cursor Window

        Unforunately we are baffled as to why the data feed seems to show 'spurious' price values on hi lo close open until a large number of ticks has passed??
        When you load the script on a chart it will first process all the historical bars on the chart executing main() once per bar. So your iteration counter will begin on the first bar and increment by one on each historical bar. Then it will increment by one on each tick as it processes real time data. Similarly the values reported in the Formula Output Window will be first those of the historical bars until the current bar is processed after which it will report the real time values
        If you want the script to execute only once it reaches the most current bar on the chart then add the following line of code at the beginning of the main() function
        if(getCurrentBarIndex()<0) return;
        This will interrupt the execution of main() until it reaches the most current (ie last) bar on the chart
        Alex




        Originally posted by intradezone
        Hi Alex,

        Thanks for your reply; much appreciated.

        In your screenshot it is interesting to note that there is significant variance (away from true price value) on Iteration 2; your script shows exactly what we are finding...

        The way we are running our script is to place the efs file in the local dir and then right click on the chart (real time data fed) and then select the script to run. Pretty much the usual way I hope.

        Unforunately we are baffled as to why the data feed seems to show 'spurious' price values on hi lo close open until a large number of ticks has passed??

        Do you have any further ideas?

        Thanks in advance,
        Matt and Warwick.

        Comment


        • #5
          ahh... all becomes clear, thanks

          Hi Alex,

          Things are becoming clear now, your explanation (and code fragment) really help.

          We did not previously understand how the environment worked (ie, that the historical data was being processed at script initialisation in that way). This explains some other 'seemingly strange' results we obtained earlier in the day... We can now move forward with confidence.

          We will begin again in the morning with your suggestions.

          Kind regards,
          Matt and Warwick.
          Perth, Western Australia.

          Comment


          • #6
            Matt and Warwick
            You are most welcome
            If you are not yet familiar with the efs environment you may want to review the Tutorials that are available here and in which you can find specific information regarding efs
            Hope this helps
            Alex


            Originally posted by intradezone
            Hi Alex,

            Things are becoming clear now, your explanation (and code fragment) really help.

            We did not previously understand how the environment worked (ie, that the historical data was being processed at script initialisation in that way). This explains some other 'seemingly strange' results we obtained earlier in the day... We can now move forward with confidence.

            We will begin again in the morning with your suggestions.

            Kind regards,
            Matt and Warwick.
            Perth, Western Australia.

            Comment

            Working...
            X