Announcement

Collapse
No announcement yet.

Backtesting problems??

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

  • Backtesting problems??

    There are a few problems that i have been encountering back testing and not sure if they are bugs in the program or my code.

    The first is i have noticed that it will list a buy and a sell on the same time period(i'm running 10 min bars) but it will have a profit that couldn't have been achieved unless it sold a few hours later.

  • #2
    Hello fflaque,

    It's difficult to tell what the specific source of the problem is without seeing your code. Here's a couple things to check for.

    1. Make sure you are not using a Strategy.MARKET/Strategy.THISBAR combo. It's a common mistake made with back testing formulas. What this tells the back tester to do is use the open price of the current bar for the entry. If your formula tests the high, low or close of the bar to trigger an entry, the open of that bar is not a realistic fill.

    2. An entry and exit on the same bar can happen if the stop loss or profit target logic is too tight. Use the debugPrintln(sString) statement inside the code blocks where trades are called to verify that the logic of your conditions are doing what you intended.

    If this doesn't help solve your problems, post your code and I'll help take a closer look at what's going on.
    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


    • #3
      here is another problem i just incurred, as you can see i have a profit target of 10, but lets say i move the profit target to 70 it still gives the same amount of profitable trades which i know is impossible, also it gives an error on the short column even tho this code isn't set up to short, and every single entry has the buy and sell at the same time period.

      Comment


      • #4
        Hello fflaque,

        Please post your code. It's very difficult to pin point the problem without seeing and testing your code.
        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


        • #5
          i was running this on the gbp
          Last edited by fflaque; 07-07-2004, 10:56 AM.

          Comment


          • #6
            Hello fflaque,

            Here's the main problem. You have your entry and exit calls in the same code block. The .doSell() call will execute regardless of the stop price specified. That's why the entry and exit are occurring on the same bar. The Strategy object doesn't test for the breach of the stop price for you in the Strategy.doSell() call. You still need to test for the breach of a stop price in your code before makeing the .doSell() call.

            Here's what I recommend. Separate your entry and exit logic into separate code blocks. When a long entry is triggered, use a global variable, nStop, and set it equal to your stop price.

            Then, in your exit code block, first check to see that you are currently in a long position and then test the close against your stop price. If Strategy.isLong() returns false, the code will go to the "else if" statement and look for a new long entry. Give this a try and be sure to set up nStop as a global variable.

            PHP Code:
                // exit
                
            if (Strategy.isLong() == true) {
                    if (
            close() > nStop) {
                        
            Strategy.doSell("target reach",Strategy.STOPStrategy.THISBARStrategy.ALLnStop);
                    }
                } else if ((
            RSIpast Lowerpast) && (vRSI vLower)) { // entry
                    
            nStop close() + .001;
                    
            Strategy.doLong("Rsi cross"Strategy.CLOSEStrategy.THISBAR);
                } 
            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


            • #7
              thanks i got it working, i just have one more question...i'm running this on a short time period intraday but if i put it to test like say 60-90 days esignal will crash, is there a way to backtest say a time period of 30 days over 4 months ago instead of backtesting the most recent 30 days?

              Comment


              • #8
                Hello fflaque,

                Post your most recent version of the formula and I'll check to see if there is something specific to the code that is causing the crash.

                For back testing a specific time range you can add a check for the date or time of each bar during the test to restrict trades from occurring outside your specified date or time range. Here's an example of what you could add to your formula. Make sure your time template covers the bars for the specified range as well.

                DateRange.efs

                PHP Code:
                /*****************************************************************
                Provided By : eSignal. (c) Copyright 2004

                Restrict formula from back testing outside specified date range.
                *****************************************************************/

                function preMain() {
                    
                setPriceStudy(true);
                    
                setStudyTitle("Date Range");
                    
                setShowCursorLabel(false);
                    

                    var 
                fp1 = new FunctionParameter("startM"FunctionParameter.NUMBER);
                    
                fp1.setName("Start Month");
                    for (var 
                1<=12; ++i) {
                        
                fp1.addOption(i);
                    }
                    
                fp1.setDefault(1);

                    var 
                fp2 = new FunctionParameter("startD"FunctionParameter.NUMBER);
                    
                fp2.setName("Start Day");
                    for (var 
                1<=31; ++i) {
                        
                fp2.addOption(i);
                    }
                    
                fp2.setDefault(1);

                    var 
                fp3 = new FunctionParameter("startY"FunctionParameter.NUMBER);
                    
                fp3.setName("Start Year");
                    for (var 
                010; ++i) {
                        
                fp3.addOption(2004-i);
                    }
                    
                fp3.setDefault(2004);

                    var 
                fp4 = new FunctionParameter("endM"FunctionParameter.NUMBER);
                    
                fp4.setName("End Month");
                    for (var 
                1<=12; ++i) {
                        
                fp4.addOption(i);
                    }
                    
                fp4.setDefault(2);

                    var 
                fp5 = new FunctionParameter("endD"FunctionParameter.NUMBER);
                    
                fp5.setName("End Day");
                    for (var 
                1<=31; ++i) {
                        
                fp5.addOption(i);
                    }
                    
                fp5.setDefault(31);

                    var 
                fp6 = new FunctionParameter("endY"FunctionParameter.NUMBER);
                    
                fp6.setName("End Year");
                    for (var 
                010; ++i) {
                        
                fp6.addOption(2004-i);
                    }
                    
                fp6.setDefault(2004);
                }

                function 
                main(startMstartDstartYendMendDendY) {
                    var 
                barMonth getMonth(0);
                    var 
                barDay getDay(0);
                    var 
                barYear getYear(0);
                    
                    if (
                barYear startY || barYear endY) return;
                    if (
                barMonth startM || barMonth endM) return;
                    if (
                barDay startD || barDay endD) return;
                    
                    
                setBarBgColor(Color.grey);
                    
                    return;



                The gray area of the chart is the date range , 5/1/2004 - 5/31/2004, that would be processed in the Strategy Analyzer if you add your back testing code after the setBarBgColor() function.
                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


                • #9
                  i tried the code that you gave me but it wasn't working, by they way i'm using 10 min interval but it crashes on anything after 60 days
                  Last edited by fflaque; 07-09-2004, 11:11 AM.

                  Comment


                  • #10
                    Hello fflaque,

                    With the formula you posted on a chart of GBP,10 and a time template covering 120 days of data, I'm not experiencing a crash. The back test does take some time to process. For my system it's taking about 32 seconds. You need to let the back test complete. If you start trying to do other things in the software while it's processing you are probably getting a "Not Responding" message from the software. Is that what you mean by crash?

                    One thing that might also help is if you have the time template you need for the back test active in a chart with the symbol and interval you're running the back test on. Then when you start the back test, make sure you select the same symbol, interval, time template, and formula to mirror the advanced chart before you click on "Test."
                    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


                    • #11
                      Jason that is what i was doing before
                      and it still crashes.

                      Comment


                      • #12
                        Hello fflaque,

                        Does the crash report get generated? If so, please submit the crash report for development.

                        What version and build number are you currently using?
                        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


                        • #13
                          i'm using the most current version, what happens is it pauses like its going to process it then it just sits there, i've let it set for 10 min before i pressed ctrl+alt+del and it says program not responding

                          Comment


                          • #14
                            Hello fflaque,

                            It may have something to do with your PC specs. What kind of system do you have?

                            Let's try something else. Instead of testing on 120 days, change your time template to cover a shorter time frame, such 10 days of 10 min data. Run your back test on this time period and see if the back test completes. While it's processing, don't try to give the software any more instructions. Just let it do it's thing until the Strategy Analyzer report completes. If it does, then start extending the time template's period of days and run it again.
                            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


                            • #15
                              i have pentium 2.4 ghz 528 mb ram, yeah i was doing that extending slowly, but at around 90 days it was crashing

                              Comment

                              Working...
                              X