Announcement

Collapse
No announcement yet.

i'm at a complete loss

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

  • i'm at a complete loss

    I've attached two scripts .... secTime to be run on a one second chart (to supply seconds globally to numerous 60 minute charts and timeText to be run on a 60 minute chart.
    I'm pretty sure i'm just being dense, but results from the 60 minute chart are conflicting and i can't see why. The hour is being reported incorrectly relative to the one second chart.
    If anyone has a moment and can tell me where i'm straying off course ... it would be greatly appreciated. By the way and possibly most importantly, this problem rears it's ugly head when I am running playbacks of currency tic files.
    Thanks in advance,
    Chris
    Attached Files

  • #2
    I'm still at a complete loss.......

    Same post .... but forum would not let me post both scripts ....

    60 min script is as follows ...

    var pData = null;

    function preMain(){
    setPriceStudy(true);
    setShowTitleParameters(false);
    setShowCursorLabel(false);
    setColorPriceBars(true);
    }

    function main(){
    if(getGlobalValue("mydata") != null){
    vTime = getValue("Time",0)
    gBarDay = vTime.getDay(0);
    gBarHour = vTime.getHours(0);

    pData = getGlobalValue("mydata");
    vBarYear = pData.year;
    vBarMonth = pData.month;
    vBarMonths = vBarMonth-1;
    vBarDay = pData.day;
    vBarHour = pData.hour;

    if(getBarState( ) == BARSTATE_NEWBAR) debugPrintln("gBarHour is " + gBarHour + ", vBarHour is " + vBarHour + "\n")

    }
    }

    Second script that runs on 1 second chart and passes time variable to script above is as follows ...

    function preMain(){
    setPriceStudy(true);
    setShowTitleParameters(false);
    setComputeOnClose();
    setStudyTitle("1 second data feed");
    setShowCursorLabel(false);
    }
    function main(){
    if(isLastBarOnChart()) setGlobalValue ("mydata", new int_data(0));
    }

    function int_data(n){
    this.year = getYear(n);
    this.month = getMonth(n);
    this.day = getDay(n);
    this.hour = getHour(n);
    this.minute = getMinute(n);
    this.second = getSecond(n);

    myDate = new Date(this.year,this.month-1,this.day,this.hour,this.minute,this.second);

    //debugPrintln("sec chart " + myDate + "\n")

    var txtFlags = Text.ONTOP | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM;

    var mon = (this.month);

    drawTextAbsolute(5, 110, "Date is " + myDate, Color.blue, null, txtFlags, null, 12, "mydatea");
    drawTextAbsolute(5, 90, "Year is " + this.year, Color.blue, null, txtFlags, null, 12, "year");
    drawTextAbsolute(5, 75, "Month is " + mon, Color.blue, null, txtFlags, null, 12, "month");
    drawTextAbsolute(5, 60, "Day is " + this.day, Color.blue, null, txtFlags, null, 12, "day");
    drawTextAbsolute(5, 45, "Hour is " + this.hour, Color.blue, null, txtFlags, null, 12, "hour");
    drawTextAbsolute(5, 30, "Minute is " + this.minute, Color.blue, null, txtFlags, null, 12, "minute");
    drawTextAbsolute(5, 15, "Second is " + this.second, Color.blue, null, txtFlags, null, 12, "second");
    }

    Comment


    • #3
      I don't think you can use the "global values" as you are trying to do when syncing with the playback system (on two charts).

      I've never tried it...

      I might suggest you create a text file and pull in the needed data that way..?

      If you are trying to sync two charts data for backtesting/playback operation, I've found files and global values are a solution. But I know how they work in RT, not in playback mode.

      Wish I could help more.

      B
      Brad Matheny
      eSignal Solution Provider since 2000

      Comment


      • #4
        Thanks for getting back to me Brad,
        I've used the playbacks and globals for a couple of years now and not really had any problems.... but with that said and done, I've narrowed this down a tad and maybe you can suggest a solution.
        The problem ONLY arises when the time is ALMOST right on the hour. While the global is passing the hour and say 59 minutes and some high number of seconds, the vTime.getHours(0) on the sixty minute chart is reporting the next hour.
        I've included an inage file showing this.
        gBarHour is from 60 min chart and vBar info is global from 1 sec chart.

        Here's a slightly modified script to show minutes and seconds.

        var pData = null;

        function preMain(){
        setPriceStudy(true);
        setShowTitleParameters(false);
        setShowCursorLabel(false);
        setColorPriceBars(true);
        }

        function main(){
        if(getGlobalValue("mydata") != null){
        vTime = getValue("Time",0)
        gBarDay = vTime.getDay(0);
        gBarHour = vTime.getHours(0);

        pData = getGlobalValue("mydata");
        vBarYear = pData.year;
        vBarMonth = pData.month;
        vBarMonths = vBarMonth-1;
        vBarDay = pData.day;
        vBarHour = pData.hour;
        vBarMinutes = pData.minute;
        vBarSeconds = pData.second;

        if(getBarState( ) == BARSTATE_NEWBAR) debugPrintln("gBarHour is " + gBarHour + ", vBarHour is " + vBarHour + ", vBarMinutes is " + vBarMinutes + ", vBarSeconds is " + vBarSeconds + "\n")

        }
        }

        Thanks,
        Chris
        Attached Files

        Comment


        • #5
          Well, then it appears your 60 minute chart is AHEAD of the other chart by a full hour.

          Try getting rid of the "0" statement in the 60 minute time functions...

          gBarDay = vTime.getDay();
          gBarHour = vTime.getHours();

          See what this produces??
          Brad Matheny
          eSignal Solution Provider since 2000

          Comment


          • #6
            Hi Brad,
            No, 60 minute is not ahead of the second chart ... they both report the same hour UNTIL a new bar on the 60 minute forms. Then the 60 minute reports the correct hour (as always) but the one second chart is behind by a few seconds (sometimes as much as 30 seconds) and is still reporting the previous hour.
            Chris

            Comment

            Working...
            X