Announcement

Collapse
No announcement yet.

Backtesting external signals

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

  • Backtesting external signals

    I have a couple of systems (not in eSignal) that generate trading signals. I eyeball the chart and time and sales to work out where I would have entered and exited the trade, if I want to look at the results for 3 or 4 different trailing stops I have to calculate it all manually.

    Is there some way I can import the signals into eSignal (via excel, csv, or txt file) and then just run a backtest with a trailing stop EFS?

    One of the systems is for stocks and each signal is for a different stock, the other system is for a single emini.

    I think this has been dealt with before I just can't find it!

    Thanks

    Bill

  • #2
    Hello Bill,

    Importing external data to be charted in an Advanced Chart is not possible, which would be required in order to run a back testing formula on this data.
    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
      Jason

      Thanks for the reply, as an alternative could I use a simple EFS along the lines of " if date is XXXXXX and time is XX:XX buy at market"

      I could then edit it with each signal, labourious but not as bad as doing the whole thing manually.

      If this is possible where would I look for sample "code" to cut and paste from, I would need to apply a fixed stop until a percentage breakeven point followed by a percentage trailing stop at a percentage profit target.

      Thanks

      Bill

      Comment


      • #4
        Hello Bill,

        Yes, this can be accomplished. You would create some formula parameters using the FunctionParameter Object. There is also some info on coding parameters in the Beginner Tutorials, see tutorial #3, Introduction to preMain() and main(), section 4.

        For your conditions inside main() the functions you would use to compare the bar times to the input parameters are the Series Functions, hour(), minute(), second(), day(), month() and/or year().
        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
          Jason

          Thanks for that.

          I also have an encrypted efs that I had assumed could not be backtested (it can't be backtested in it's own right).

          It marks a chart with a buy or sell signal and produces a triggered alert list.

          Can I use efsExternal to pull the signals (from the encrypted.efs) into a backtesting efs?

          I could then run various tests to find the best indicators to confirm the signals, ie buy or sell on signal alert only if indicator one shows xyz.

          Does the encrypted efs need to be loaded onto the chart or does the efsExternal command run it?

          How would I use efsExternal to just give me a listing of the variables in the Formula Output window?

          Thanks

          Bill

          Comment


          • #6
            Hello Bill,

            Originally posted by BVA
            Jason

            Thanks for that.

            I also have an encrypted efs that I had assumed could not be backtested (it can't be backtested in it's own right).

            It marks a chart with a buy or sell signal and produces a triggered alert list.

            Can I use efsExternal to pull the signals (from the encrypted.efs) into a backtesting efs?
            In this thread, there is a detailed code example illustrating how to create a series from an encrypted EFS. Any specific signals or alerts generated by an encrypted EFS cannot be imported into a custom formula. These are generated by custom conditions within the code, which are most likely proprietary conditions. If you know what the logic is for these conditions you could code them into your custom EFS. However, there isn't a method for decoding custom conditions inside an encrypted formula if that is what you are attempting to do.

            I could then run various tests to find the best indicators to confirm the signals, ie buy or sell on signal alert only if indicator one shows xyz.
            Once you have the external formula's series created in your custom formula, you can test any conditions against those seires that you would like. You can also add other built-in or custom studies to be included in your conditions.

            Does the encrypted efs need to be loaded onto the chart or does the efsExternal command run it?
            The encrypted EFS does not need to be loaded onto the chart. The calling EFS just creates a series for each item (or series) that is in the encrypted formula's return statement.

            How would I use efsExternal to just give me a listing of the variables in the Formula Output window?

            Thanks

            Bill
            The efsExternal() function cannot access the custom variables used in an encrypted formula. There isn't any code or data that can be accessed from an encrypted formula other than the returned data series that are in the formula's return statement.
            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
              Jason

              This looks promising, I don't think I am up to programming this myself so will have to find someone to do it for me.

              First if possible I would like to find out what data is output from the external efs, at present all I can get is null. It might be that the output does not contain what I want in which case I will not need an efs consultant.

              Is it possible for you to show me an example that will write all the output (data series?) from my external efs to a txt file. I have found all the examples for efsExternal, getSeries and writeToFile.efs but its beyond my abilities to cut and paste them together in a way that works (and believe me I have tried).

              Any help would be much appreciated.

              Bill

              Comment


              • #8
                Hello Bill,

                Originally posted by BVA
                Jason

                This looks promising, I don't think I am up to programming this myself so will have to find someone to do it for me.
                Visit the following link for a list of EFS Consultants.

                First if possible I would like to find out what data is output from the external efs, at present all I can get is null. It might be that the output does not contain what I want in which case I will not need an efs consultant.
                To find out what data is output by an encrypted formula all you need to do is apply it to a chart. Any data series that are plotted on the chart by the formula are the data series that efsExternal() would be able to retrieve from an external formula.

                Is it possible for you to show me an example that will write all the output (data series?) from my external efs to a txt file. I have found all the examples for efsExternal, getSeries and writeToFile.efs but its beyond my abilities to cut and paste them together in a way that works (and believe me I have tried).

                Any help would be much appreciated.

                Bill
                Unfortunately, cutting and pasting will not always get you to your destination. Especially with something as advanced as the formula you're describing. In order to code your own custom studies you really need to learn the basics of programming with JavaScript. Once you have a grasp of the basic programming concepts, which you can learn about in our JavaScript video series, incorporating EFS specific functions into custom formulas will become a much easier task. Using the writeToFile.efs code example, you could use the myData variable and assign the current value of the efsExternal() series to it, which would write that data to a text file.

                PHP Code:
                /*********************************
                Provided By : eSignal. (c) Copyright 2003
                *********************************/
                function preMain() {
                    
                setPriceStudy(true);
                    
                setShowCursorLabel(false);
                }

                var 
                ExtStudy null;
                var 
                mySeries1 null;
                var 
                myData 0//  example data

                function main() {
                    if(
                ExtStudy==null)
                    {
                        
                ExtStudy efsExternal("/Advanced/Arps Crown Jewels/Arps Triple Trender.efs");
                        
                mySeries1 getSeries(ExtStudy,1);
                    }

                    var 
                = new File("myfile.txt");  //the file will be created in:  eSignal/FormulaOutput/
                    //if (getBarState() == BARSTATE_NEWBAR) {
                    //    myData += 1;  
                    //}
                    
                    
                myData mySeries1.getValue(0);
                 
                    
                a.open("at+");   // Opens and appends the file
                    //a.open("wt+"); // Opens and overwrites the file
                    
                if(!a.isOpen()) {
                        
                debugPrintln("Could not open file!");
                    } else {
                        
                a.writeln(" build a text string, " myData " more text etc. ");
                    }
                    
                a.close();

                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
                  slightly related issue

                  Hi, all --

                  I notice that when I call an external script with either callFunction() or efs(), the data is not only used within the current script, but also output via the Formula Output window.

                  Is there a way to avoid this? Not only is it extra overhead for the processor, but when one is using the Formula Output window for debugging or script fine-tuning, one has to search through the extraneous data to find the information desired...

                  Thanks.

                  Comment


                  • #10
                    Osteve
                    To my knowledge the only way to output data to the Formula Output Window is through a debug statement.
                    Remove or comment out any debug statements you may have in the calling efs AND in the called efs as these will also print to the Formula Output Window
                    Alex

                    Comment

                    Working...
                    X