OPEN-SOURCE SCRIPT

(IK) Stoch-60-15

Aggiornato
This strategy uses 60 minute and 15 minute stochastic data to determine entry and exit; it only executes long trades. I've only used this on BTC/USD, but I imagine the concepts employed should hold for any ticker

The script builds a simple Stochastic indicator for the current timeframe, and it also plots a single stochastic 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 stochastic is in an uptrend, if the current resolution stochastic is in an uptrend, and if the current stochastic value is less than 50.

We exit a trade when the current stochastic 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 stochastic 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.
Note di rilascio
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.
Note di rilascio
small bug fix in the trailing stop calculation
BTCcryptocryptotradingLONGmtfmulti-timeframeOscillatorstrailingstopTrend Analysis

Script open-source

In pieno spirito TradingView, l'autore di questo script lo ha pubblicato open-source, in modo che i trader possano comprenderlo e verificarlo. Un saluto all'autore! È possibile utilizzarlo gratuitamente, ma il riutilizzo di questo codice in una pubblicazione è regolato dal nostro Regolamento. Per aggiungerlo al grafico, mettilo tra i preferiti.

Vuoi usare questo script sui tuoi grafici?


Anche su:

Declinazione di responsabilità