Announcement

Collapse
No announcement yet.

Avoid daytrading on user specified dates

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

  • Avoid daytrading on user specified dates

    Backtesting my daytrading strategy I want to avoid trading on user specified days (for example the US holidays).

    What I am planning to do is, enter a list of days in my backtesting code like this:

    List with dates not to trade:
    05.25.2006
    07.04.2006 ...

    and add a condition like:

    If date is on the list above, do not trade
    Else check entry condition ...

    How can this be done?

  • #2
    helmutw
    An easy way to do this is shown in the sample code enclosed below
    Alex

    PHP Code:
    var Dates = new Array("6/22/2006","6/5/2006","5/25/2006","6/28/2006");//exclusion dates (see Note)
    var mmddyy getMonth()+"/"+getDay()+"/"+getYear();
    var 
    AllowTrading true;
    for(var 
    i=0i<=Dates.lengthi++){
        if(
    mmddyy==Dates[i]){
            
    AllowTrading false;
        }
    }
    //Note: dates can be in random order

    if(AllowTrading==true){

        
    //trading strategy to be executed


    Comment

    Working...
    X