Announcement

Collapse
No announcement yet.

Suggested new feature-backtesting

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

  • Suggested new feature-backtesting

    The timeframe for a backtesting study presently is the same for the study calculation as it is for the tradings tabulations. Problem is that many studies, like Moving Averages require the number of bars equal to their interval (a 7 day MA requires 7 days of data before its value rises from zero to a value truly representing 7 days' worth of day in the study. So, backtesting trades calculated in relation toi that 7 day MA --DURING THE FIRST 7 DAYS--while the MA is normalizing,---while be "bad trades". That is, they will be exeuted because they were above/below the study, but, only because the studstudyy was not yet at full njormal value. So, if I want to look at the MA for last two days with a backtest of daily bars that uses a 7 day MA, I really have to begin the backtest study 9 days ago, in order to get the 7day average "ramped up", so I caN THEN MANUALLY SUBTRACT OUT the last two days of trades generatedby the backtest, in order to get valid results.
    SO, please add a new settings option at the beginning of the Backtesting popup window that lets me specify how many intervals worth of Study "timefram" I would like to use to "ramp" up " the studu]ies, before the backtestingprogram begins logging and sampling "trades specified by my Strategy.
    thx, tilmon

  • #2
    Hello Tilmon,

    This type of logic needs to be handled by your formula code. To ensure that your conditions are using valid values you can check for null returns and exit the formula if a valid value has not yet been established. The built-in studies will not return "ramped up" values. They will only begin returning values once the study has processed the full length specified by your parameters.

    PHP Code:
    function main() {
        var 
    nMyValue sma(7inv("D"), 0);
        if (
    nMyValue == null) return;
        
        
    // your strategy logic here
        
        
    return nMyValue;

    The null check on nMyValue prevents any subsequent Strategy logic from executing until the sma() values are valid.

    Alternatively, if you want to specify a number of days to process before allowing your Strategy logic from processing you can use a global counter and count the number of days that have been processed. Then add a condition before your Strategy logic that checks for the specified number of days.

    PHP Code:
    var nDayCntr 1;

    function 
    main() {
        var 
    nMyValue sma(7inv("D"), 0);
        
        if (
    day(0) != day(-1)) {  // new day found
            
    nDayCntr++;  // increment day count by 1.
        
    }
        
        if (
    nDayCntr 9) return;  // exit if less than 9 days have been processed.
        
        // your strategy logic here
        
        
    return nMyValue;


    Originally posted by tilmon
    The timeframe for a backtesting study presently is the same for the study calculation as it is for the tradings tabulations. Problem is that many studies, like Moving Averages require the number of bars equal to their interval (a 7 day MA requires 7 days of data before its value rises from zero to a value truly representing 7 days' worth of day in the study. So, backtesting trades calculated in relation toi that 7 day MA --DURING THE FIRST 7 DAYS--while the MA is normalizing,---while be "bad trades". That is, they will be exeuted because they were above/below the study, but, only because the studstudyy was not yet at full njormal value. So, if I want to look at the MA for last two days with a backtest of daily bars that uses a 7 day MA, I really have to begin the backtest study 9 days ago, in order to get the 7day average "ramped up", so I caN THEN MANUALLY SUBTRACT OUT the last two days of trades generatedby the backtest, in order to get valid results.
    SO, please add a new settings option at the beginning of the Backtesting popup window that lets me specify how many intervals worth of Study "timefram" I would like to use to "ramp" up " the studu]ies, before the backtestingprogram begins logging and sampling "trades specified by my Strategy.
    thx, tilmon
    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