Announcement

Collapse
No announcement yet.

Playback and Time Quandry

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

  • Playback and Time Quandry

    Howdy folks,

    I've got a tricky problem, at least as far as my abilities and experience with "time" allows.

    I use the following code on a 5 second chart to get time to my ten minute trading charts and it works fine in both real time and while doing playbacks of tic files.
    PHP Code:
    function preMain(){
    setPriceStudy(true);
    setShowTitleParameters(false);
    setComputeOnClose();
    setStudyTitle("1 second data feed");
    setShowCursorLabel(false);
    }
    function 
    main(){
    setGlobalValue ("mydata", new int_data(0));


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

    I use the following code in my 10 minute charts to get the time from the 5 second charts. I do this as i need minutes and seconds which of course the 10 minute charts won't provide. I know that i can use "getMinute(inv("5s"))" and i do for real time but it slows playbacks down and doesn't solve my problem anyhow.
    PHP Code:
    var THT;
    var 
    TLT;
    var 
    TH null;
    var 
    TL null;
    var 
    TSTH;
    var 
    TSTL;
    var 
    txtFlags Text.ONTOP Text.RELATIVETOLEFT Text.RELATIVETOBOTTOM;

    function 
    preMain(){
        
    setPriceStudy(true);
        
    setShowTitleParameters(false);
        
    setShowCursorLabel(false);
        
    setColorPriceBars(true);
        
    setDefaultPriceBarColor(Color.black);
    }

    function 
    main()
    {
        if(
    getSymbol() == "$PLAYBACK"){
            
    pData getGlobalValue("mydata");
            
    vBarYear pData.year;
            
    vBarMonth pData.month;
            
    vBarDay pData.day;
            
    vBarHour pData.hour;
            
    vBarMinutes pData.minute;
            
    vBarSeconds pData.second;
            
    myDate = new Date(pData.year,pData.month-1,pData.day,pData.hour,pData.minute,pData.second);
        }
        if(
    TH == null || high() > TH){
            
    TH high();
            
    THT myDate;
        }
        if(
    TL == null || low() < TL){
            
    TL low();
            
    TLT myDate;
        }
        
    TSTH = (myDate.getTime() - THT.getTime())/60000;
        
    TSTL = (myDate.getTime() - TLT.getTime())/60000;
        
    drawTextAbsolute(50050"High is " TH ", High Date = " THT ", since high is " TSTH 
                        
    " minutes, Low is " TL ", Low Date = " TLT ", since low is " TSTL 
                        
    " minutes"Color.bluenullText.BOLD txtFlags"Verdanna"22, ("timer"));
        
    drawTextAbsolute(50020"Currently it is " myDateColor.bluenullText.BOLD txtFlags"Verdanna"22, ("timernow"));


    This works fine in both real time and playback .... my problem is when I fast forward or "jump" through the tic file. When i do this, i do get the correct highs and lows but the time that they occured at is always the last tic of the playback tic file. Does anyone have any ideas on how I can track the high and low and the time at which they occured while doing a "jump through" of a tic file ?

    Much appreciated ...
    Chris

  • #2
    Re: Playback and Time Quandry

    Hello Chris,

    Originally posted by Chris747
    ...

    This works fine in both real time and playback .... my problem is when I fast forward or "jump" through the tic file. When i do this, i do get the correct highs and lows but the time that they occured at is always the last tic of the playback tic file. Does anyone have any ideas on how I can track the high and low and the time at which they occured while doing a "jump through" of a tic file ?

    Much appreciated ...
    Chris
    The reason this happens is because the "jump" action initiates a reload of both studies. They reinitialize one study at a time. They do not reload in synchronization with each other based on time stamps as they execute while in play mode. When the reload of the formula running on the 5S chart occurs first, the last value assigned to your mydata global object via setGlobalValue() contains the last bar's time from the 5S chart. Historical values are not maintained with a setGlobalValue()/getGlobalValue() routine. When your study on the 10 minute chart reloads the getGlobalValue() method is retrieving the same value on each bar execution during the reload. When the historical high and low are found the value of mydata does not correspond to the historical values that were overwritten by the setGlobalValue() method in the other study.

    What you need to do, is look at the 5S interval within your study that is running on the 10 minute chart with the use of inv("5S"). The benefit of using this function when creating multiple time frame series is that the data between the intervals is synchronized for you by EFS. You do not need the formula running on the 5S chart or the setGlobal.. / getGlobal... routine, which only works in real time or in play mode with tick replay. When your conditions on the 10 minute chart find a new high or low, drill down to the 5S bars within the 10 minute bar using a high and low series of the 5S interval. Create a loop that compares the time stamps of the 5S bars to the current 10 minute bar's time stamp to find the 5S bar with the same high or low value of the 10 minute bar. You can find a code example of this type of routine in this thread.
    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
      Hi Jason,
      I can't thank you enough .... worked perfectly ...not sure how i couldn't get it to work when i first tried to use inv(). Thanks !!!

      Chris

      Comment


      • #4
        You're most welcome Chris.
        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