Announcement

Collapse
No announcement yet.

Playback and Time...

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

  • Playback and Time...

    Hi Folks.
    I'm using 60 min interval charts and attempting to use playback mode to prove some strategies.

    Is there any way in playback (on one hour charts) to get minutes and seconds during any bar when i request them? I get the correct hour but for minutes and seconds all I get is 0 returned.

    I'm using ...
    var vHour = getHour();
    var vMin = getMinute();
    var vSec = getSecond();

    I've read posts that say it works but i've had no luck whatsoever. Basically I just want to say "do this every 2 minutes and 30 seconds" ..... no problem in real time, playback is the issue.

    Any help would be greatly appreciated.

  • #2
    Folk Chris747,

    Well, based on the period of chart you are using, you are kind of out of luck, since the only time you can obtain in playback is referenced to the beginning of the bar. Since you have chosen 60 minute bars, the minimum time difference that you will be able to discern is 60 minutes.

    Using the date object will only return the current time which has no association with the file that you are playing back.

    As a workaround, you could have another chart in playback at a smaller time interval simultanious to your 60 minute chart. Then broadcast the smaller time interval from the smaller chart using global variables.

    Assuming you go with the workaround option I mentioned I created an efs to broadcast the data you need from a smaller interval chart. In this case, I used a 1 minute chart and named the efs as such. It can be run on any interval however.
    PHP Code:
    /***********************************************
    Provided By : Steve Hare © June 2005                          
    EFS Formula : oneMinuteDataFeed.efs                     
    Version 1.0
    6/4/2005
    */
    function preMain(){
      
    setPriceStudy(true);
     
    setShowTitleParameters(false);
     
    setComputeOnClose();
     
    setStudyTitle("1 minute data feed");
     
    setShowCursorLabel(false);
    }
    function 
    main(){
    //if (getBarState() == BARSTATE_NEWBAR) { 
        
    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);
        
    this.bid getMostRecentBid(n).toFixed(2);
        
    this.ask getMostRecentAsk(n).toFixed(2);

    Here is a receiving efs that grabs the data. I ran this in playback and it worked well. Try the efs and see if the behavior is what you want. You can cut and paste the appropriate steps into your efs.
    PHP Code:
    /************************************************
    Provided By : Steve Hare © June 2005                          
    EFS Formula : sixtyMinuteDataReceiver.efs                     
    Version 1.0
    6/4/2005
    */
    var pData null;
    function 
    preMain(){
      
    setPriceStudy(true);
     
    setShowTitleParameters(false);
     
    //setComputeOnClose();
     
    setStudyTitle("60 minute receiver");
     
    setShowCursorLabel(false);
    }
    function 
    main(){
    //if (getBarState() == BARSTATE_NEWBAR) { 
        
    pData getGlobalValue ("mydata");
        
    debugPrintln ("time = "+pData.hour+":"+pData.minute+":"+pData.second+" bid = "+pData.bid+" ask = "+pData.ask);
        
        
    //or alternatively
        
        
    with (pData){
            
    debugPrintln ("time = "+hour+":"+minute+":"+second+" bid = "+bid+" ask = "+ask);
        }
        
    //}

    Here is a screenshot where you can see the output of the efs from the 60 minute chart in the formula output window.



    I went ahead and uploaded the efs's to my fileshare in this link to Functions

    Comment


    • #3
      Chris747
      In addition to Steve's suggestion and only if you are using version 7.9 (or later) you can use EFS2's ability to access multiple intervals from within the same chart. The enclosed example shows you how you could do it.
      Alex

      PHP Code:
      function preMain() {
          
      setPriceStudy(true);
          
      setStudyTitle("sample");
          
      setShowCursorLabel(false);
      }

      function 
      main() {

          var 
      hh hour(inv(1));
          var 
      mm minute(inv(1));
          
      //var ss = second(inv("1s"));//uncomment this line to see also seconds
                                       //note that this will create a tick based data
                                       //series in the background ie as if opening a 
                                       //tick based chart

          
      debugPrintln(hh.getValue(0)+":"+mm.getValue(0));
          
      //debugPrintln(hh.getValue(0)+":"+mm.getValue(0)+":"+ss);//this if you want to see also seconds

          
      return ;

      Comment


      • #4
        You guys are da bomb !!!

        Thank you very much ...

        Comment

        Working...
        X