Announcement

Collapse
No announcement yet.

controlling time with Tick data in bt mode

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

  • controlling time with Tick data in bt mode

    I have made several posts and received several responses in recent weeks regarding testing strategies for intraday data, and my need to close trades at End of Day, and not start trades until start of trading next day. Your respones (both Jason and Alexis) as to the usual "getday() != (getDay91)" etc have not worked. I also asked for guidance on constructing a time template for tick data, so that my strategy report results will list the results for each day correctly. Still have problems. Have spent 10 + hours trying to implement your suggestions, with countless trial and error shots at hour(0, minute(), get hour...etc.
    Frustrated by Time Template refusing to take "T" (tick) User Defined time parameters and always kicking back out "Dynamic" 24 hour data. Understand max data for T is 10 days.
    Try it yourself for 10 days Tick data, say 50 Tick interval.
    What I need is "actual trading time" script.
    So, I need help excluding strategies from 00:00:00 hours until 09:30:00 outxs (OPen of Market), then let Strategies sing in rain until Close. Then I need EOD close.ALL. then exclude strategies from running from 16:15:00 hours(e-mini closing time) until 23:59:59 hours. and to continue looping for 10 days, posting the discrete trading results by day in the backtesting reports. Could you build this into something useful like the wonderful recent efs scripts on Donchian trailing stops script. I often get lost when you make reference to code as prose "".....your code here.......} (sone curly bracket somewhere,). It is really super more helpful when a sample full lcode is used, even if short, because it reveals the insertion and closure points for structures propounded in your answers.
    thx &0xBFF in advance 01100100 (see what I mean, out of context code, regardless of language does not always achieve the convergence of inquiry and response initially sought, if it lacks the precision necessary to apply into script. ) :-)



    thx, Tilmon

  • #2
    Tilmon
    With tick based charts (ie intervals T, V, P and S) the Time Template only controls the number of days loaded and not the Start/End times. Unlike interval data (ie minute based charts) which can be downloaded/displayed in size segments tick data is downloaded/displayed only in whole day segments at this time.
    This is why using getDay(0)!=getDay(-1) will not work in your case. It will however work with interval charts as those can be set through the Time Template to start/end at the regular trading hours.
    When using tick based charts (or interval charts that include all sessions) you need to implement a different solution which checks for bar times. Enclosed below is a sample script that shows you how to do this.
    Alex

    PHP Code:
    function main(){
     
        
    //fill in study to be used here
     
        
    var RegularTradingHours = (hour(0)*100)+minute(0)>=930 && (hour(0)*100)+minute(0)<1615;
        var 
    AllowTrading false;
        
        if(
    RegularTradingHours){
            
    AllowTrading true;
        } else {
            
    AllowTrading false;
        }
        
        if(!
    AllowTrading){
            if(
    Strategy.isLong()){
                
    Strategy.doSell("EOD Sell",Strategy.LIMIT,Strategy.THISBAR,Strategy.ALL,close(-1));
            }
            if(
    Strategy.isShort()){
                
    Strategy.doCover("EOD Cover",Strategy.LIMIT,Strategy.THISBAR,Strategy.ALL,close(-1));
            }
        }
        
        if(
    AllowTrading){
            
            
    //fill in conditions for long/short trades and corresponding strategy commands;
        
        
    }
        
        return 
    //fill in return statement


    Originally posted by tilmon
    I have made several posts and received several responses in recent weeks regarding testing strategies for intraday data, and my need to close trades at End of Day, and not start trades until start of trading next day. Your respones (both Jason and Alexis) as to the usual "getday() != (getDay91)" etc have not worked. I also asked for guidance on constructing a time template for tick data, so that my strategy report results will list the results for each day correctly. Still have problems. Have spent 10 + hours trying to implement your suggestions, with countless trial and error shots at hour(0, minute(), get hour...etc.
    Frustrated by Time Template refusing to take "T" (tick) User Defined time parameters and always kicking back out "Dynamic" 24 hour data. Understand max data for T is 10 days.
    Try it yourself for 10 days Tick data, say 50 Tick interval.
    What I need is "actual trading time" script.
    So, I need help excluding strategies from 00:00:00 hours until 09:30:00 outxs (OPen of Market), then let Strategies sing in rain until Close. Then I need EOD close.ALL. then exclude strategies from running from 16:15:00 hours(e-mini closing time) until 23:59:59 hours. and to continue looping for 10 days, posting the discrete trading results by day in the backtesting reports. Could you build this into something useful like the wonderful recent efs scripts on Donchian trailing stops script. I often get lost when you make reference to code as prose "".....your code here.......} (sone curly bracket somewhere,). It is really super more helpful when a sample full lcode is used, even if short, because it reveals the insertion and closure points for structures propounded in your answers.
    thx &0xBFF in advance 01100100 (see what I mean, out of context code, regardless of language does not always achieve the convergence of inquiry and response initially sought, if it lacks the precision necessary to apply into script. ) :-)



    thx, Tilmon

    Comment

    Working...
    X