Announcement

Collapse
No announcement yet.

Help with new Strategy

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

  • Help with new Strategy

    I am having a problem writing this new EFS strategy.

    I want to back test different profit targets and stops with different MA crosses.

    The code seems to work but I have a feeling its entering trades more than once per cross.

    I wrote a line on 71 and tried moving it to different positions. But I still cant seem to get the charts to show and arrow on entry/exit, So I really dont have any idea if my code is working or not. (it reads n"no syntax errors?)


    Im sure I'm just missing something simple but any help with this would be greatly appreciated.


    Thanx

    Attached Files
    Last edited by 88888accountant; 06-06-2007, 05:14 PM.

  • #2
    Hey, hows it going. I had a quick look at this and put in a fix. You nearly had it, you just had to :

    - add a bRealTime check into the strategy for the back tester to recognize it should process the trade.
    - ensure you modify the min tick size correctly as eSignal is typically using "1" as a 1 point or 1 cent move. Your strategy is set to 0.01 which means as soon as it went long it was getting stopped as 0.01*5 points is less than 1 point. Modify the default from the chart by right clicking on it -> edit studies.. -> select this strategy and change the default ticksize to 1 or whatever it should be.

    One other thing if you will be testing intraday, is a more realistic use of STRATEGY.THISBAR and open(0) as your market entry point. This may not be 100% realistic and may generate more slippage than you anticipate. So you ought to check before relying on the backtesting results.


    Mark

    Comment


    • #3
      And here is the code
      Attached Files

      Comment


      • #4
        And the results (may well be inaccurate for reasons previously mentioned) for the following settings:

        Daily $SPX
        ticksize 1
        profit 10 cents
        stop 2 cents
        $2 commisions
        $2 slippage
        $10 per point value
        Attached Files

        Comment


        • #5
          Hey Mark,


          Thanx for your help I was racking my brain trying to figure this out, you're a lifesaver.

          I was wondering if you could fill me in a bit more on the whole "THISBAR" and slippage you were referring to.

          The problem I'm having now is that my profit target seems to be way off, sometimes it takes more profit and sometimes it takes less?

          My entry points seem way off too. I'm not sure yet if there is a way to limit that or not?

          I'm not sure if this is what you meant when you were referring to slippage.

          Also, if you could fill me in on any tips on learning EFS. I find I waste a lot of time trying to find answers that are obvious to most of the learned, but abstruse to the neophytes like me.


          Thanx again for all your help,


          Ryan
          (8s)

          Comment


          • #6
            Hey Ryan,

            I was wondering if you could fill me in a bit more on the whole "THISBAR" and slippage you were referring to.
            If you do a search on these forums for "THISBAR" you will find a ton of information; I know JasonK has written an excellent piece on this and you may want to ask him directly. I will post a link if I can find it. There are some issues I can think of you may want to look out for in developing a system, for example ensuring your entry price is realistic. i.e. set to open(0) of the NEXTBAR or close(0) of THISBAR. You need to ensure your backtesting matches the realtime realistic signal. This is partly what I meant by slippage, but in addition, if trading intraday with a high intensity strategy, slippage also refers to the difference between the price your strategy signalled an entry and the actual price achieved. In a fast volatile market, like the one experienced in March and recently this week, it can be tricky. The backtester has the ability to account for slippage (aswell as commission costs) in its evaluation. Just click on the properties menu item from the backtester window.

            Have you looked at the other strategy functions associated with LIMIT and MARKET orders, they may be able to help you.


            Also, if you could fill me in on any tips on learning EFS. I find I waste a lot of time trying to find answers that are obvious to most of the learned, but abstruse to the neophytes like me.
            In the 6 months I've had eSignal, I have created three strategies that have been successful in backtesting. They are now in a walk forward simulation in RTD TANGO which is my execution engine with Direct Market Access. I guess in that time, having had some programming experience before, I got up to speed in efs by having 4 or 5 excellent strategies developed by JasonK and S&C contributors that I could refer to and create a framework for designing my own strategies, adding bits in. In fact the fix I added to yours was due to my knowledge of the "Stochastic with long term EMA filter" S&C code in the Stocks and Commodities file share!

            If you want to follow me down this route, check out the stocks and commodities section of the file share and also I highly recommend subscribing to the actual S & C magazine for $50 or so a year. This way you not only get to look at some great example code, but you also get to read about the theory and the research behind it. It gives me alot more confidence in developing.

            The other thing about having some example code is that you can spend most of the time working on your idea and shaping it instead of constantly referring to the documentation which is less application focused and more pure knowledge focused. Learning the practicalities of coding in efs (like slippage) can only come from real world experience, less from a text book. I try to get as dirty as I can with the code, dig myself into a couple of holes and then get the answers I need from this excellent knowledge base - the forum - and when I need it help I find this forum is just awesome in getting the right answer pronto.

            Comment


            • #7
              Markswall,

              I've also been trying to develop profitable strategies and it's alot mre challenging then one would anticipate. It's very kind of you to provide that useful information regarding profitable strategies. I have literally spent years trying system out and you can save many people the grief that we ( or at least I) have experienced.

              Has is your walk forward optimization performing relative to the backtested results?

              You mentioned some strategies that us used as as basis for developing your own that Jason developed, which were were you referring to?

              I did notice and experimented with the S&C strategy you mentioned. It was one of the very few out of the hundred or perhaps thousands that I researched that tested well. However when I tried modifying it for intra-data it was not so successful.

              Were the strategies that you developed applied to intraday of longer time periods?

              Thans again for providing your useful input. I have been putting out some Strategy performance resports of strategies I am also forward testing on http://www.forextv.com click ForexTV Weblogs and Glen Demarco if you are interested. The web site is free.

              If you ever want to compare notes, ideas, strategies, etc would be happy to.....there is no holly grail, that's for sure, however you can get some decent returns, good luck.


              Glen
              Glen Demarco
              [email protected]

              Comment


              • #8
                Okay, I think I almost have it. Ive got the strategy to stop reentering trades, but I still cant get it to only enter at a set price >= to the first MA?

                I've been surfing around here for hours, and after re reading the "Developing new strategies" link It seems like this is obvious.


                Can anybody tell me where I am going wrong? I tried a whole bunch of things (some logical some not) including setting entry price = MA1 but I may have put it in the wrong spot.

                I dont know anymore, any help on this would be welcomed with great appreciation.

                Thanx
                Attached Files

                Comment


                • #9
                  Originally posted by 88888accountant
                  Okay, I think I almost have it. Ive got the strategy to stop reentering trades, but I still cant get it to only enter at a set price >= to the first MA?

                  I've been surfing around here for hours, and after re reading the "Developing new strategies" link It seems like this is obvious.


                  Can anybody tell me where I am going wrong? I tried a whole bunch of things (some logical some not) including setting entry price = MA1 but I may have put it in the wrong spot.

                  I dont know anymore, any help on this would be welcomed with great appreciation.

                  Thanx
                  Hey,

                  Look at the code quickly. One thing I noticed is that the syntax of your sells does not look correct. The Strategy.dosell method does not use the last 2 parameters where you have null, and TargetPrice specified.

                  I thought there was a similiar strategy in the sample backtesting folder that you might want to take a look at.

                  Jason has created several Guide to backtesting that you may want to take a look at, as there are very specific techniques for insuring accurate backtesting results that you need to definately incorporate into you code if you want accurate results.

                  Glen
                  Glen Demarco
                  [email protected]

                  Comment


                  • #10
                    Hi,

                    I've attached an updated version of your code that checks for open >= MA1 and made the following changes:

                    - fixed profit exit. Your code would have used the open price instead of the target price

                    - checked for stops hit first. This may not be an issue if you are using 1 minute charts, but its a good practice for backtesting to assume your stops are hit before profit targets.

                    - added labels and line colors to the MAs.

                    - added lower limits of 1 cent to the profit and stop amounts

                    - added constants to define trade state.

                    - and various other minor code changes and comments as needed.

                    Steve
                    Attached Files

                    Comment


                    • #11
                      Hi Glen,

                      Originally posted by demarcog

                      Has is your walk forward optimization performing relative to the backtested results?
                      Last week the trade systems were in synch nicely and RTD tango kicked off the same trades as alerted in eSignal. Last week during simulation, the markets corrected slightly and the system stopped out many times. This was a concern but it wasn't an extraordinary event - similar days of stops occur during backtesting, and the system showed some ok profit on other contracts and some of the more volatile London stocks like RIO, XTA and AAL, so I decided that this was a valid system.

                      Yesterday it made a nice profit and performed some textbook trading, spotting the move in the FTSE futures up early on. The rest of my team here have been asking me to put it live so today is the day.

                      Comment


                      • #12
                        Originally posted by smeyer55
                        Hi,

                        I've attached an updated version of your code that checks for open >= MA1 and made the following changes:

                        - fixed profit exit. Your code would have used the open price instead of the target price

                        - checked for stops hit first. This may not be an issue if you are using 1 minute charts, but its a good practice for backtesting to assume your stops are hit before profit targets.

                        - added labels and line colors to the MAs.

                        - added lower limits of 1 cent to the profit and stop amounts

                        - added constants to define trade state.

                        - and various other minor code changes and comments as needed.

                        Steve
                        Thanx Steve!

                        I really appreciate the comments added, it helped me understand a lot more on where certain code goes.

                        Its funny, I made one of the exact same changes you did and it didnt work for me, so I read yours again and reapplied it to my old code and it worked fine.

                        I guess I had it in the wrong spot or something else was stopping it from excecuting.


                        anyway thanx again for your fixes, I'm rereading some of the tutorials and I think they're starting to make more sense the second time around since everyones helped me out.


                        Cheers.
                        Last edited by 88888accountant; 06-13-2007, 09:42 PM.

                        Comment


                        • #13
                          Heres is the newest updated version.

                          the formula output window says Im missing a }, but I can't seem to find it.

                          could someone with a second pair of eyes take a look?

                          My code might not even be in the right place? I think I can at least start testing though if I can get this to work.


                          Thanx again in advance to anyone who can help.
                          Attached Files

                          Comment


                          • #14
                            Hi,

                            You had several issues with braces. I prefer to line up the braces under the if statements since it makes it easy to see where you missed one. You had around 8 that were messed up.

                            You also had a typo on vPosition in your short code, which is why it never went short.

                            I've included updated code which fixes these issues and adds a few new features.

                            - added code to draw arrows/text at entry locations. You can use that in addition to your boxes at the bottom if you want. Or keep the boxes if you like them.

                            - added code to display light red boxes when you're short.

                            - added code to change the background color when you're in a position. This is commented out near the bottom of main. Uncomment it to try it out.

                            - moved the exit checking code to run before the entry code. Otherwise you could enter/exit on the same bar. This ensures you'll be in a position at least one bar's time.

                            - changed to use setComputeOnClose so you don't have to do a newbar check. This will reduce the cpu load for the efs.

                            Steve
                            Attached Files

                            Comment


                            • #15
                              Hey Steve!


                              Thanks for the new fixes. I was just running the back tester on HD, and I found that by changing the profit parameters to say 30 ticks, the profit factor went up huge. It appears to be giving me my short profit target everytime?


                              Im not sure why exactly, I was wondering if you could have another look.

                              It appears that the trade only goes short as a reversal as well.

                              Im not sure what to do to fix this? If its another curly bracket problem then I probably wont be able to figure it out.


                              Any help on this would be greatly welcomed.
                              Last edited by 88888accountant; 06-17-2007, 10:18 AM.

                              Comment

                              Working...
                              X