I have always been a big fan of trailing stops. They serve two purposes – lock in some profit and give the market room to vacillate. A pure trailing stop will move up as the market makes new highs, but a ratcheting stop (my version) only moves up when a certain increment or multiple of profit has been achieved. Here is a chart of a simple 30 minute break out on the ES day session. I plot the buy and short levels and the stop level based on whichever level is hit first.
When you program something like this you never know what is the best profit trigger or the best profit retention value. So, you should program this as a function of these two values. Here is the code.
So, basically I set my multiples to zero on the first bar of the trading session. If the multiple = 0 and you get into a long position, then your initial stop will be entryPrice + (0 – 1) * trailAmt. In other words your stop will be trailAmt (6 in this case) below entryPrce. Once price exceeds or meets 7 points above entry price, you increment the multiple (now 1.) So, you stop becomes entryPrice + (1-1) * trailAmt – which equals a break even stop. This logic will always move the first stop to break even. Assume the market moves 2 multiples into profit (14 points), what would your stop be then?
stop = entryPrice + (2 – 1) * 6 or entryPrice + 6 points.
See how it ratchets. Now you can optimized the profit trigger and profit retention values. Since I am keying of entryPrice your first trailing stop move will be a break-even stop.
This isn’t a strategy but it could very easily be turned into one.
Discover more from George Pruitt
Subscribe to get the latest posts sent to your email.
George, would you consider posting this as a strategy?
Hello – yes I will put this into a Strategy and post it.
Thanks,
George
I have a Box function that sets my entry times but I am trying to set my stop strategy to start the session after entry. Not sure how to do. EL dictionary and docs are void of useful examples. Thanks
Hi Harry,
Sorry for the delay – I was out of town.
I am not exactly sure what you mean by “set my stop strategy to start the session after entry.” I agree the online documentation by TradeStation is very slim.
Just let me know and I will see if I can lend a hand.
George
Hello George
Have you posted this into a Strategy as well? I can\\’t find it on your website.
Thanks in advance and all the best
Hello George
Following up on this post as I can\’t find the Strategy on your website. I\’d be greatly interested in it.
Thanks in advance and all the best
Hello Jean – I will put a post in the next few minutes with the source code that replicates the indicator. Notice the similarity between the strategy and the indicator. Thanks for visiting my blog.
Hi George – Thanks! I can\’t wait to test it out!
Hello George,
I wish to convert intraday code for end of day application, but unable to do so. Guidance would be greatly appreciated.
Thank you.
Hi Khalid – I will try and post something this week or next. Using the ratchet stop on daily bars.