Announcement

Collapse
No announcement yet.

Import: SI, Backtest Setup

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

  • Import: SI, Backtest Setup

    From this Silicon Investor post:

    From: Dan Duchardt Monday, Mar 24, 2003 10:39 PM

    I was working on some backtesting formulas over the weekend and discovered that the parameter inputs in the backtest setup window are ignored. The only way I can change parameters is to re-define the parameter defaults in the formula code. Is this normal? If so, why are the input fields available at all in the backtest window.
    Dan,

    Could you give a few examples and sample code of what you are referring to? Below are the two possible Backtest Settings that I am aware of.

    In the Back Testing window the Setup button...


    Or in the eSignal Strategy Analyzer the Settings button...
    Regards,
    Jay F.
    Product Manager
    _____________________________________
    Have a suggestion to improve our products?
    Click Support --> Request a Feature in eSignal 11

  • #2
    Re: Import: SI, Backtest Setup

    I guess I used the word "setup" generically and carelessly. What I was talking about is the Paramer input fields in the BackTesting window, like the three fields shown in your first image. My bactesting formula contains input parameters with defaults to handle null inputs. The formulas work fine as studies applied to the chart, and I can change the parameters with "Edit Studies" and see the resulting changes to my chart. But when I run the backtest, any parameters I enter in the Back Testing window are ignored. The test is always run with the default parameters in the formula regardless of what I enter in these fields.

    I've not yet signed up for file sharing, which seems to be a separate thing from the Bulletin Board, so I'll just post some code here (unfortunately not so nicely formatted). Have you tried entering paramaters for the MACD Backtest you used to create your first image? If your system behaves like mine it will ignore them.

    //derived from eSignal Library formula ema.efs; modified initial EMA value

    function preMain() {
    setPriceStudy(true);
    }

    var dLastMA = 0.0;
    var dThisMA = 0.0;
    var dPercent = 0.0;
    var dValue = 0.0;
    var dLastValue = 0.0;

    function main(nInputLength) {
    if(nInputLength == null)
    nInputLength = 21;

    var nBarState = getBarState();

    if(nBarState == BARSTATE_ALLBARS) {
    // reset!
    dPercent = (2.0 / (nInputLength + 1.0));
    dValue = getValue("Close");
    dLastValue = dValue;
    dLastMA = dValue;
    }
    if(nBarState == BARSTATE_NEWBAR) {
    dLastMA = dThisMA;
    dLastValue = dValue;
    }
    dThisMA = dLastMA;

    dValue = getValue("Close");
    if(dValue == null)
    return;

    if (dValue > dLastMA) {
    dThisMA = (dValue - dLastMA) * dPercent + dLastMA;
    if(!Strategy.isLong()) {
    Strategy.doLong("Crossing Up", Strategy.STOP, Strategy.THISBAR, null, dLastMA);
    }
    } else {
    if (dValue < dLastMA) {
    dThisMA = (dValue - dLastMA) * dPercent + dLastMA;
    if(!Strategy.isShort()) {
    Strategy.doShort("Crossing Down", Strategy.STOP, Strategy.THISBAR, null, dLastMA);
    }
    }
    }
    if(Strategy.isLong()) {
    setBarBgColor(Color.RGB(223,255,223));
    } else {
    if(Strategy.isShort()) {
    setBarBgColor(Color.RGB(255,191,191));
    }
    }
    return dThisMA;
    }


    Originally posted by JayF
    [B]From this Silicon Investor post:


    Dan,

    Could you give a few examples and sample code of what you are referring to? Below are the two possible Backtest Settings that I am aware of.

    Comment


    • #3
      Dan
      As an aside you can attach efs files to messages in the Bulletin Board forums.
      Other accepted types of files include the more common graphic formats, zip and doc files.
      Alex

      Comment


      • #4
        Dan
        In the attached image you will see a daily chart of $INDU, 600 bars loaded. On it I ran the efs without changing the nInputLength parameter in the Edit Studies. Chart uses default length of 21
        Then I ran a Back Test and changed the nInputLength parameter to 10 in the Back Testing window. The result is visible in the inset window and as you can see is quite different than what appears on the chart.
        In fact the chart shows no trades in between the short on 1/17 (where the cursor is positioned) and the long of 3/13 whereas the Strategy Analyzer is showing a series of trades in the same period. These trades are consistent with the ones that would appear in the chart if I were to also modify nInputLength in Edit Studies to 10.
        Alex
        Attached Files
        Last edited by ACM; 03-26-2003, 09:56 AM.

        Comment


        • #5
          Well, this is very strange. It seems you have done exactly what is needed to verify the problem, and I agree with your interpretation of your results. Unfortunately, when I do what you did (my # of days is a bit longer; all else is the same) I get the results I have described before. My backtest shows the results for the 21 period default instead of the 10 period input to the backtest window.

          Originally posted by Alexis C. Montenegro
          Dan
          In the attached image you will see a daily chart of $INDU, 600 bars loaded. On it I ran the efs without changing the nInputLength parameter in the Edit Studies. Chart uses default length of 21
          Then I ran a Back Test and changed the nInputLength parameter to 10 in the Back Testing window. The result is visible in the inset window and as you can see is quite different than what appears on the chart.
          In fact the chart shows no trades in between the short on 1/17 (where the cursor is positioned) and the long of 3/13 whereas the Strategy Analyzer is showing a series of trades in the same period. These trades are consistent with the ones that would appear in the chart if I were to also modify nInputLength in Edit Studies to 10.
          Alex

          Comment


          • #6
            I somehow failed to attach the image file. Here it is (I hope):
            Attached Files

            Comment


            • #7
              Dan
              FWIW - and unrelated to the issue of Back Testing not passing through the parameters - you may want to review the strategy as it was posted.
              I have edited the formula to plot the value at which it Buys/Shorts and as you can see on this 5 minute ES chart the strategy goes Short at a price that was never traded ie in proximity of the MA whereas the high of the bar is 15+ points lower.
              Just a heads up in case you had not already noticed this.
              Alex
              Attached Files
              Last edited by ACM; 03-27-2003, 04:49 AM.

              Comment


              • #8
                Good catch Alex

                I am aware of the gap problem and I've been fooling with various ways to deal with it. The formula I posted was just to illustrate the backtest parameter issue, so I kept it simple. I've worked up a No-overnight version that closes out at the end of each day and opens again the next. I've been in another conversation about how best to detect the end of day bar to effect the close.

                Originally posted by Alexis C. Montenegro
                Dan
                FWIW - and unrelated to the issue of Back Testing not passing through the parameters - you may want to review the strategy as it was posted.
                I have edited the formula to plot the value at which it Buys/Shorts and as you can see on this 5 minute ES chart the strategy goes Short at a price that was never traded ie in proximity of the MA whereas the high of the bar is 15+ points lower.
                Just a heads up in case you had not already noticed this.
                Alex

                Comment


                • #9
                  The latest Beta should correct the issue of the backtest parameters not being passed thru.

                  m.
                  Matt Gundersen

                  Comment

                  Working...
                  X