Announcement

Collapse
No announcement yet.

backtest problem

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

  • backtest problem

    Please, if anyone can assist. I am running a simple backtest efs and it produces no trading results?

    What did we do wrong? I have attached the file for your review.

    Thanks
    Attached Files

  • #2
    I'm going to try to help, but you have some issues with how this is all setup.

    First, you have to remember you're developing arrays of ems data. Arrays can only be accessed by pointing to the array item you want.

    Like myarray[1] or myarray[0]. This selects the array item you want to evaluate/use.

    In your code, the biggest problem I see is you are not comparing array items correctly and your logic is forcing a "return false" oddly.

    For example, this function
    PHP Code:
    function isFastOverlapVslow() {
        var 
    0;            // Fast MA index
        
    var over false;
        var 
    under false;
        
        for (
    i=0;i<fastMA.length;i++) {
                
            if ( 
    fastMA[i].getValue(0) >= vslowMA ) {
                
    over true;
            } else if ( 
    fastMA[i].getValue(0) <= vslowMA ) {
                
    under true;
            }
           
            if ( 
    over && under ) {
                return 
    true;
            }
        }
        
        return 
    false;


    needs to be corrected if you want to compare the fastma to the slowma. Like this..

    PHP Code:
    function isFastOverlapVslow() {
        var 
    0;            // Fast MA index
        
    var over false;
        var 
    under false;
        
        for (
    i=0;i<fastMA.length;i++) {
                
            if ( 
    fastMA[i] >= vslowMA[i] ) {
                
    over true;
            } else if ( 
    fastMA[i] <= vslowMA[i] ) {
                
    under true;
            }
           
            if ( 
    over && under ) {
                return 
    true;
            }
        }
        
        return 
    false;


    I also question your logic in regards to what you are trying to accomplish. It appears you are trying to check all of the emas to see if they cross up, down or if they overlap?

    You might want to consider ordering your comparisons and structure an object to deliver the final analysis results.
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Thanks Doji3333. We're clearly on a bit of a learning curve. You are absolutely correct about the array reference and I did find that issue after the posting.

      Unfortunately, that's not the end of it. There seems to be an issue in referencing the ema object

      Consider this very simple script:

      function main() {

      debugPrintln("main 0");

      var ema10 = ema(10);

      debugPrintln("main 1");

      var a = ema10.getValue(0);

      debugPrintln("main 2: " + a);
      }

      Here is the Formula Output after checking the syntax:

      \esignal_q_simple.efs, line 9: TypeError: ema10 has no properties

      main 1
      main 0


      Any thoughts? I get the feeling that I must be missing something very simple.

      Comment


      • #4
        For anyone reading this thread, we discovered that esignal does not seem to run correctly under Vista. When we changed to Windows 7 our current issues were resolved.

        Comment


        • #5
          beverlycloak,

          Your handling of "arrays of series objects" (fastMA, slowMA) is fine.

          However, I think you want a zero in all the places you use close(). Otherwise, it returns a series object (which may just happen to work in your case). For example, I'd use:
          PHP Code:
          entryPrice close(0); 
          More importantly, I think "vslowMA" is messed up.
          PHP Code:
          vslowMA null;
          ...
          if ( 
          fastMA[i].getValue(0) <= vslowMA ) {
          ...
          // Very slow exponential moving average
          vSlowMA=ema(55); 
          JavaScript variables are case sensitive. Case for vslowMA needs to be the same everywhere. Also the conditional should be (although it may work as is):
          PHP Code:
          if ( fastMA[i].getValue(0) <= vslowMA.getValue(0) ) { 
          eSignal works fine on Vista. However, changing to Windows 7 may have changed the JavaScript engine, which just might have been more forgiving of your coding errors. Who knows...
          Last edited by shortandlong; 01-14-2010, 12:13 PM.

          Comment


          • #6
            I'm not sure what happens if there are less than 10 bars and you call ema(10). The return may be undefined. When first scanning a chart this always happens. You may need to have main() return until at least the 10th (or in your case the 55th) bar.

            Regardless, I'd avoid buys/sells with the Strategy object until you have at least a minimum number of bars (55).

            (While a sma needs a certain number of bars to be accurate, the computation of ema is more nebulous. The minimum number of bars needed can be hard to figure out.)
            Last edited by shortandlong; 01-14-2010, 12:26 PM.

            Comment


            • #7
              Thanks shortandlong.

              It turned out that the problem was actually related to Vista but someone suggested a fix for that in another thread. Your points are also well taken.

              Comment


              • #8
                ...interesting. Although I have problems with the Strategy Analyzer Graphs (nothing is displayed), I've never had a problem with an EFS before on Vista (and I'm running as a non-Administrator with UAC on). That said, I've only played with the Strategy object - haven't done anything serious with it yet.

                Looks like once I get serious about the Strategy Analyzer I'll need to run eSignal as an Administrator and/or XP compatibility mode. I seriously hope I don't have to turn off UAC, though...

                (If I get ambitious, I might try using "Process Monitor" - a software analysis tool - to isolate the specific files/registry entries that are causing the problem.)

                Would be nice if eSignal would fix this, since to my knowledge it's the only reason that eSignal needs to be run as an Administrator on Vista (and probably Windows 7).
                Last edited by shortandlong; 01-15-2010, 01:30 PM.

                Comment

                Working...
                X