Update!
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.