The script builds a simple indicator for the current timeframe, and it also plots a single line for a higher resolution time frame. I've found good results trading on 15 minutes with a 60 minute higher resolution.
We enter a trade if the higher resolution is in an uptrend, if the current resolution is in an uptrend, and if the current value is less than 50.
We exit a trade when the current value crosses below 80 or the trailing stop loss is hit.
Stop loss is calculated with the input value, Stop Loss Percent. This value represents the percent of capital you're willing to lose before exiting a trade. A stop loss percent of 0.050 means your trade will exit if it falls 5% from the highest high since entering a trade. You will have at least 95% of your original capital left. There is no option to change a trailing stop loss to a set stop loss (in order to keep the code as simple as possible), however, you can turn it off by setting Stop Loss Percent to 1.
I tried to keep the script itself lightweight and very easy to understand, so it's not very customizable in regards to input options. You can change data, as well as the trailing stop percentage. The script can be adjusted to other timeframes, however this requires a small change in the code (details in script comments). Changing just the "Higher Resolution" input will not produce expected results
My hope is that by keeping it lightweight and simple, it will be easier for you to adjust to your specific needs, or work into a larger strategy.
So, my original script had a slight repainting bug that caused it to suffer from hindsight bias. This was great for my backtest results, but not so much for real life. Due to the way I got data from the hourly timeframe, it was possible that a trade that was invalid in realtime could be retrospectively validated. This caused trades to show up on my chart without corresponding alerts.
Unfortunately, fixing this bug really cut into my backtest profitability (no surprise there), so I've given the whole script a bit of a revamp. Unlike last time, the code isn't as 'simple', and I would recommend only using it on a 15min chart with a 60min higher resolution. I've in fact taken out the input setting to change the higher resolution. But I've added other input settings!
You can now customize the stochastic buy and sell thresholds. Trades will enter only if Stochastic %D is below the buy threshold, and trades will exit when stochastic %D crosses under the sell threshold.
You can now choose whether stop loss is trailing or dynamic. I've also flipped the calculation, so a 0.05 stopPercent means that trades will exit if price falls 5% (in my original script, price would need to fall 95% with a value of 0.05)
I've added take profit functionality. Trades will exit, regardless of stochastic data, if prices rises by this percentage. Set this value to 1.0 to effectively turn it off. No trailing option for this, but perhaps in a future update.
This strategy only goes long, and takes into account a 0.1% commission. We enter a trade if a small uptrend is determined in current stochastic data, as well as higher res stochastic data, and if current stochastic %D is below a 'buy threshold'. We exit on three conditions: stop loss, take profit, or current stochastic %D crosses under a 'sell threshold'
I've configured default settings to work well with major crypto, but particularly ETH. I've found that a longer stochastic length as well as a higher D works fairly well across the board, but play around with the input settings for your own personal use. This script is specifically for a 15 minute timeframe. I would not recommend using it on other timeframes without editing the code.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.