Announcement

Collapse
No announcement yet.

Setting Simple Stop for Backtesting

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

  • Setting Simple Stop for Backtesting

    Hello,

    I have a efs that I use for backtesting where I want to set a simple stop upon position entry.

    Please see the following efs section where the long / short is entered. I want to set a hard stop at the entry point - 30 points. I

    I have tried the examples in other threads and documentation, but could not get the backtest to behave as desired. All help is appreciated.

    Thank you,

    Patrick

  • #2
    efs

    Didnt see the efs post; try again.
    Attached Files

    Comment


    • #3
      Hello pmkedi,


      The formula you posted is somewhat incomplete. For starters you need to add the global variable, study, which should be set the to RSIStudy() object with your desired parameters. At that point, test the formula and see if it generates some trading results. If so, then take a look at the basic explanation I gave in this thread for adding a stop. The difference for you will be the the math used to calculate the stop price. Try to incorporate this into your back testing study. If you still have problems at that point, post your code here and we'll take a look.
      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


      • #4
        Backtesting Results Don't give Actual Stop/Limit values

        In backtesting with Sell/Buy Limits and Sell/Buy Stops, the backtesting results don't seem to give actual values for the limits and stops.

        That is, if I set a stop at -10 points, there are numerous trades where the actual backtesting results show more than 10 point losses.

        It is the same with Limit orders, although I may put in a Limit to sell a long at +10 points, the backtesting results show numerous profits of greater than 10 points.

        I would expect the backtesting module to look at a bar and see if the high was greater than or equal to the limit price, and then in the results give you a profit of the limit that you set.

        Same for a stop, if a bar went less than or equal to the stop that was set, the loss should reflect that stop amount rather than 10 points lower.

        Could you please explain the logic that the backtesting module uses in determining how it triggers a limit or stop execution?

        Thanks.

        Comment


        • #5
          Whizz - If I may jump in I think maybe you are mis-understanding the backtesting functionality in eSignal.

          There is no "backtesting module" as such except for one you write. eSignal provides the ability to do what you are asking, but its not quite as simple as just saying enter here with an x pt stop. You have to write the logic to monitor the price and then exit your position appropriately. Like thus:

          Code:
          if ([trade signal you specify]) {
             Strategy.doLong("entry",Strategy.LIMIT,Strategy.THISBAR,posSize,entryPrice);
             stopPrice = entryPrice - 10;
          }
          
          if (Strategy.isLong()) {
             if (low() <= stopPrice) {
                Strategy.doSell("stopped",Strategy.LIMIT,Strategy.THISBAR,posSize,stopPrice);
             }
          }
          That is an extremely rudimentary (and incomplete) example, but, hopefully, you get the idea. While, this may seem much more complicated than what you were expecting or are used to, it is also extremely powerful because the possibilities are almost endless.

          Good luck.
          Last edited by ebr; 01-27-2005, 12:30 PM.

          Comment


          • #6
            Hello whizz,

            Looks like ebr hit the nail on the head. ebr's explanation of the problem you're having is an excellent description. I already typed up a response so I'm posting anyway, just to give you some more perspective. Hope this helps.

            When using the .STOP or .LIMIT fill constants you must ensure through your formula code that the price you specify is within the range of the bar where the trade is to occur. If you test for a stop breach on a price of 100 be sure to use that same price in your strategy function, or something that is within the range of the bar. If you pass a different price of say 110 that happens to be outside of the range of the bar, that trade will either not occur at all, or report a trade price that is outside the bar's range depending on which side of the actual stop price you specified.

            As long as your validation for the limit or stop price is correct, the Strategy Analyzer report will be accurate.

            I think the problem you might be having is that you are calling the strategy functions when they are not inside a code block that validates a trade condition. When ever you call one of the strategy functions, the formula will try to execute that command on that bar (or next bar when using the NEXTBAR constant). If you call a .doSell or .doCover and specify a price that is outside the bar range, the formula does not keep track of a stop level to test for automatically going forward. That part of the strategy must be coded by you.
            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
              Ok, I understand.
              Thanks for the replies EBR , Jason.
              At least now I don't have to sit there scratching my head trying to figure out what the heck is going on with the backtesting output, lol.

              The STOP and LIMIT functions don't really act like a true STOP or LIMIT function in real trading. Meaning that you execute a buy or sell and then set the stop and limit exits and then wait to see which one executes.

              I've been doing my backtesting with debugPRINT and creating comma delimited files for analysis in EXCEL, and was hoping that I could bypass this kind of thing (checking highs/lows and then executing "manually") by using the LIMIT and STOP functions to simplify the code, but there seems to be little difference other than the spiffier backtesting output files esignal generates.
              Last edited by whizz; 01-27-2005, 01:51 PM.

              Comment


              • #8
                Whizz,

                I worked also with the Backtesting and I got great profits with this tool. But in realtime it was loss.
                Now I am working with the Tick Replay Tool. It´s like realtime-trading. The entry and stop from the "efs" works correct.

                regards
                sams

                Comment


                • #9
                  Sams.

                  I am interested in backtesting with the Tick Replay. Could you please describe your entry/stop methods you use in the "efs" please? Perhaps post the "efs"?

                  Thank you,

                  Patrick

                  Comment


                  • #10
                    pmkedi,

                    I have attached an efs that I have found on this board. It´s a good efs for the Tick Replay Tool and automated trading. It will buy and sell automatically without your stomach.
                    The efs is running with a moving average. You have to add your own indicators and define the buy and sell signals then it will work for you.

                    good luck
                    sams
                    Attached Files

                    Comment

                    Working...
                    X