Announcement

Collapse
No announcement yet.

Background / drawdown challenges

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

  • Background / drawdown challenges

    All,

    Firstly, can I say that I appreciate all those who have been helping the new users on this forum. I’ve been attempting to develop backtest scripts now for a couple of months, and without these forums I would be extremely lost.

    Secondly, I have attached my first script there. I would greatly appreciate if one of the more advanced users on the forum could take some time to give it a peer review? Of course, I’m happy for the feedback to be posted to the forum so that any other newcomers could benefit from the feedback I receive.
    The strategy description is as follows: It is focused on intra-day trading, looking at price excursion away from the morning session day high / low. It is designed to be the basis for trading the afternoon session of the NYSE (New York Stock Exchange) based on the morning session high / lows. Once the price has moved outside of the day high / low, it then looks for the first move back towards that range (i.e. if the price is now above the morning high, the strategy looks to enter after the first negative bar back towards the day range).

    Unfortunately, from early back tests the strategy is flawed. However, I think much of the code contained within might be reuseable. For example, the entry & exit code with minor adjustments. In the end coding the strategy become a learning exercise.

    Some key points of note:

    • I have been running this script consistency against HPQ (NYSE) over the last couple of months while I’ve been developing it
    • The backtest should be run on a 5 min bar chart – I’ve personally been using candlestick charts though I don’t think it matters if it is a standard bar chart
    • I have been using standard settings in the strategy analyser (i.e. 100 contracts / shares, 0 commission / slippage, etc)

    Two of the areas that I’ve had a challenge with while building the script were:

    Background colouring
    I can’t seem to get the background to colour appropriately. I’m to understand from reading the forums that this is not working in this build version of Esignal. However, I have also tried colouring the bars themselves to mark entry points, this doesn’t seem to be working either. I’m a little confused how the chart is updated while it is static. That is, when using a chart for backtesting purposes it appears to me to be necessary to load all the necessary data (in this case it is intra-day 5 min bars up to 120 days). Only then will the backtest run across all that data. I’m a little confused on how Esignal updates that static chart when running a backtest? Is the background & bar colouring functionality only aimed at playback and real time strategy analysis?

    Exits / drawdown
    I’ve found challenging is reconciling the stop-loss exits with the drawdown numbers reported in the strategy analyser. For example, if you run this script against HPQ you will find trades on the 30/04/08 and 01/05/08 (N.B. dates in European format). In each of those traded you will note that the maximum drawdown on each of those trades is drawdown which is significantly over and above the stop loss points in the strategy. However, the actual reported exit point is correct. This is worrisome; I think what is happening is that the Strategy Analyser is reporting that the position is open all the way through the bar, but then closing out the position when bar closes – but reporting that the trade is being held all throughout the development of the bar, when it should be reporting the position as closed when the stop kicks in.

    Any help or guidance more experienced members of the forum could offer would be greatly appreciated.

    Kind regards,

    Dan

  • #2
    Problems posting files to this forum

    All,

    I’ve just tried to attached my file to this post; then drafting the post it allowed me to attach a file, however is disappeared when posting it. Now if I edit the post there is no option to attach a file, has anyone had any problems with this or can you offer any advice?

    Thanks,

    Dan

    Comment


    • #3
      file

      2nd attempt
      Attached Files

      Comment


      • #4
        Re: Background / drawdown challenges

        Hello drolles,

        Originally posted by drolles
        ...

        Two of the areas that I’ve had a challenge with while building the script were:

        Background colouring
        I can’t seem to get the background to colour appropriately. I’m to understand from reading the forums that this is not working in this build version of Esignal. However, I have also tried colouring the bars themselves to mark entry points, this doesn’t seem to be working either. I’m a little confused how the chart is updated while it is static. That is, when using a chart for backtesting purposes it appears to me to be necessary to load all the necessary data (in this case it is intra-day 5 min bars up to 120 days). Only then will the backtest run across all that data. I’m a little confused on how Esignal updates that static chart when running a backtest? Is the background & bar colouring functionality only aimed at playback and real time strategy analysis?
        The background coloring was a bug in 10.0. This will be fixed in the next release. Regarding price bar coloring, you just need to set this up properly. In preMain() you need to add setColorPriceBars(true). You may also want to specify a default price bar color in preMain() using setDefalutPriceBarColor(). The background and bar coloring will also be applied to the historical bars when the formula is applied to the chart. For a more detailed explanation of how formulas process the bar data please take a look at the EFS tutorials.

        Exits / drawdown
        I’ve found challenging is reconciling the stop-loss exits with the drawdown numbers reported in the strategy analyser. For example, if you run this script against HPQ you will find trades on the 30/04/08 and 01/05/08 (N.B. dates in European format). In each of those traded you will note that the maximum drawdown on each of those trades is drawdown which is significantly over and above the stop loss points in the strategy. However, the actual reported exit point is correct. This is worrisome; I think what is happening is that the Strategy Analyser is reporting that the position is open all the way through the bar, but then closing out the position when bar closes – but reporting that the trade is being held all throughout the development of the bar, when it should be reporting the position as closed when the stop kicks in.
        The Strategy Analyzer does not have a way of knowing the time during the bar at which you instruct the analyzer to record a trade. Back testing is based largely on assumptions. For drawdown calculations being made for each position, the analyzer has no way of knowing that your trades are occurring at the open. The drawdown numbers are based off of the max high (or min low) of the bar from the entry bar to the exit bar. If the exit bar has the max value, this is what gets used for the drawdown calculation. For your particular strategy that records the exit at the open of a bar, the drawdown numbers may not always be accurate.
        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,

          Thank you very much for your reply.

          I’ve now had some time to do some more analysis and testing of this background color problem. I’ve now tried to use existing examples from this web site (e.g. http://kb.esignalcentral.com/display...se&r=0.7771984 – BtSimpleMA.efs) with background coloring. This does not color the chat with the dark green specified in the code. Therefore, I’m not sure if this could be a problem in my code given it is happening with example code from the site. You mentioned that this was a defect in 10.0, does it still exist as a defect? Is there a list of known problems with the development environment kept somewhere? Or are there some settings somewhere else required to ensure this functionality works?

          I have to admit I’m a little disappointed at the functionality of the strategy analyser mentioned in your reply. I would have through the it should have the ability to integrate with the efs code to ensure it tracked the positions as specified by the strategy being tested. Are we able to log this as a defect in the defect log? Could you point me towards the specific documentation on the functionality of the Strategy Analyser? I can only find this general introduction from the existing documentation.

          My other disappointment is with the development environment; Is there a roadmap for the efs development environment? Can you please point me towards the documentation that details when this is going to be upgraded with the basics of a development environment (e.g. variable inspection in debug mode)?

          Or if there are no plans to upgrade the development environment can you please share with us some best practice on development? For example, I have noticed that there are some references in the documentation to the ability to integrate with .dll written in C++. Do most serious backtesting developers use something like Visual Studio to develop the dlls in then integrate with E-signal? Though, I would have thought debugging would be a little troublesome given one would require the functionality of Esignal to execute the backtesting.

          I appreciate your help.

          Kind regards,

          Dan

          Comment


          • #6
            Dan

            I've now tried to use existing examples from this web site (e.g. http://kb.esignalcentral.com/display...se&r=0.7771984 - BtSimpleMA.efs) with background coloring. This does not color the chat with the dark green specified in the code.
            FWIW at my end the background color appears to be the one defined in the script ie darkgreen (see enclosed screenshot captured when running the BTSimpleMA.efs)

            You mentioned that this was a defect in 10.0, does it still exist as a defect?
            The bug Jason was referring to was not related to the colors themselves but to the fact that the background color was applied on top of the price bars. This was resolved in version 10.1 and [if I remember correctly] the fix was listed in its readme file
            Alex

            Comment


            • #7
              Alex,

              I appreciate your reply.

              Thanks also for testing the same script.

              I have now tested this on an exactly the same chart that you have in your picture ($INDU) – Daily. With exactly the same script that we have both used. My definitely didn’t colour when long. It has not drawn the MA either.

              I’ve gone back to basics and reread the introduction to backing testing (http://kb.esignalcentral.com/display...96&r=0.3029138) to ensure I was following the correct process for applying a script. That is:

              1. Open the chart (in this case a Dow Industrials Daily) – this brings in the data to be tested
              2. Right click bring in the back testing script (in this case the one we have referenced – BtSimpleMA.efs)
              3. Then hit the test button

              Is that how you got the chart coloured as you show in your picture?

              Is there some setting that I am missing? Does one have to enable this functionality somewhere on the chart?

              I have looked at the colour settings when looking at the advanced chart properties. I found some colour settings, but nothing that references dynamic colouring.

              Any suggestions would be appreciated. Thanks again for your reply and the clarification on the bug.

              Kind regards,

              Dan

              Comment


              • #8
                Dan

                1. Open the chart (in this case a Dow Industrials Daily) - this brings in the data to be tested
                2. Right click bring in the back testing script (in this case the one we have referenced - BtSimpleMA.efs)
                3. Then hit the test button
                Based on your description it would seem that you are not actually loading the script in the chart but only running it in the Back Tester in which case it will not plot the average or color the background. For the latter to happen you need to load the efs in the chart
                Alex


                Originally posted by drolles
                Alex,

                I appreciate your reply.

                Thanks also for testing the same script.

                I have now tested this on an exactly the same chart that you have in your picture ($INDU) – Daily. With exactly the same script that we have both used. My definitely didn’t colour when long. It has not drawn the MA either.

                I’ve gone back to basics and reread the introduction to backing testing (http://kb.esignalcentral.com/display...96&r=0.3029138) to ensure I was following the correct process for applying a script. That is:

                1. Open the chart (in this case a Dow Industrials Daily) – this brings in the data to be tested
                2. Right click bring in the back testing script (in this case the one we have referenced – BtSimpleMA.efs)
                3. Then hit the test button

                Is that how you got the chart coloured as you show in your picture?

                Is there some setting that I am missing? Does one have to enable this functionality somewhere on the chart?

                I have looked at the colour settings when looking at the advanced chart properties. I found some colour settings, but nothing that references dynamic colouring.

                Any suggestions would be appreciated. Thanks again for your reply and the clarification on the bug.

                Kind regards,

                Dan

                Comment


                • #9
                  Alex,

                  Thanks very much for your reply.

                  I’ve played with this for some time yesterday. You are correct. As per my interpretation of the documentation I had been applying this to the chart as a backtest script, expecting it to colour the chart. However, as you correctly point out, this will not work. The script must be applied to the chart to colour it as script (i.e. Right click on the chart, Formula -> Backtest -> then relevant script).

                  Can I make a suggestion, is that this is addressed in the documentation and made explicitly clear that these are two different routes?

                  Kind regards,

                  Dan

                  Comment


                  • #10
                    Dan,

                    Thank you for the suggestion and we'll update the documentation to reflect running the backtester with studies on the chart and only implementing them in the backtester.

                    AveryH
                    eSignal Support

                    Comment

                    Working...
                    X