How i create strategies and optimize

Forums ProRealTime English forum General trading discussions How i create strategies and optimize

Viewing 4 posts - 1 through 4 (of 4 total)
  • #71483

    Hello again all traders. I thought i’d give a little “newbie explanation” part 2. (part 1 here: https://www.prorealcode.com/topic/thoughts-on-profitable-trading-systems/)

    And i want to share with you all a detailed explanation of how i work. Please note that this is my way of doing things, inspired by others in this forum and books ive read + podcasts ive listened to.

    I feel like my way of doing this has worked so far for me, and should be able to help you create algos that are not curvefitted. I hope you can learn something from all of this.

    What is curvefitting?

    We all curvefit. To be honest, thats the whole point of algos. You start with a set of data, lets say 10 years of data on 1h Wall st/Dow j. From this data you want to extract as much profits as possible, in any way possible. So we add Rules saying that “Price must be above or under this and that” or “MACD line must cross over signal line” etc. The more rules we use in 1 algo, the more complicated it gets, and the more % curvefitting is going on. If you curvefit too much you “overfit” your model. Meaning that the algo is only good on that spesific data, and as soon as you move to new data, the algo falls apart.

     

    How can we avoid overfiting the algo?

    The way i have made, and still make, algos is by using my own method. Even tho i call it my own, im just gonna guess that people have done this since systematic trading has been a thing..

    Step 1. I go into the market i want to trade and i cherry-pick a great moment in time, a fantastic trade. Lets say i wanna make a trend-following system that tries to wait for a breakout above and ride the trend as long as i can.  And i want to exit when that trend/swing/move is finished. Im gonna choose Wall st 30m market for this example. I have now determined the market i wanna be in, the timeframe i want and the style of trading i want to create in this system. (see photo 1)

    photo1

    Step 2. I create my algo using whatever ideas i have for this system, and for now i just use a random 150 pip stop loss (usually i would want like half of this but i dont wanna fit my model at all except for this 1 cherry picked trade. I dont use any target and i make sure i have an entry + exit using only the standard variables that come with the indicator, to make sure i dont overfit, if im using moving averages i use variables that look good for that spesific trade that im trying to take.. As you can see in photo1 my entry and exit for this cherry-picked “great trade” looks decent. If it can do this 100 times over and over again without loosing too much, then i would be very happy. I now check the entire EQ curve, and it looks decent. (See photo 2)

    photo2

    Step 3. Okay so my example-algo here doesnt look too shabby, its not great but its not exactly bad either. Its a very simple algo using 2 indicators for entry and 1 for exit. Now i go into “optimizing-mode” and i go into only the first 30-50% of the data and i start optimizing the variables on everything at the same time, but only using variables that are “close” to my first varaibles. If i used moving average 10 and 50, i would never ask for Moving average between 5-500 when optimizing. . Now i optimize every variable including stop loss and trailing stop loss and or target.. (See photo 3)

    photo3

    Step 4. When im 100% done optimizing on the 30-50% data, i put down a line where i stopped optimizing and i flip the algo back to 100% of the data, In this example my optimizing havnt rly done all that much and this is clearly not the best algo ever, just wanted to show an example and explain my work-method. See photo 4 for end-results on this example. (if this would have been overfit it would look like photo 5 which is another algo ive made and optimized this way. and you can clearly see the overfitting.)

    photo4

    Step 5. If step 4 shows a good algo i do 1 final optimization on 100% of the data, using only variables that are VERY close. I dont want to add anything to the table now. if i want to add a filter or something, after step 4 is done, i need to take it back to step 3 and go into on 30-50% and add the filter and optimize the filter there. The reason i optimize that final time is that i have fit my algo to data from say 2010 -> 2014, alot has happened the last 4 years and i think its only fair that the model should be able to optimized on both the “old” and the “new” data before you put it in demo. I want to see roughly 10 trades/1-2 months of demo before i go live with them.

    Photo5

    If anything is unclear just ask, if you disagree please specify why you disagree and what you would do/are doing different!

    10 users thanked author for this post.
    #71491

    I might add:

     

    If step 4 looks curvefit and ugly i discard the whole thing and start over on a new idea..

     

    If step 4 looks great and i do the final optimization (step 5) and place it in demo, it dosnt rly matter if those 10 trades are winners or looser b4 going live. All i want is that the algo is actually doing what i want it to do. An algo can and should and will loose a couple of trades here and there.. Thats normal, just look at what the market is doing and say “would my algo have worked here? if the answer is no, and the EQ curve is down, well then thats just normal behaviour then. But if the market is up 10% and ur algo is down 10%, something might be very wrong… (if its a long only strategy)

    1 user thanked author for this post.
    #71493

    Thank you jebus89 for this valuable post! I added every of your screenshots directly into your post for a better and quicker comprehension.

    #71496

    Thank you jebus89 for this valuable post! I added every of your screenshots directly into your post for a better and quicker comprehension.

    Awsome, thanks alot.

Viewing 4 posts - 1 through 4 (of 4 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login