Volatility
BTC and ETH Long strategy - version 1I will start with a small introduction about myself. I'm now trading cryto currencies manually for almost 2 years. I decided to start after watching a documentary on the TV showing people who made big money during the Bitcoin pump which happened at the end of 2017.
The next day, I asked myself "Why should I not give it a try and learn how to trade".
This was in February 2018 and the price of Bitcoin was around 11500USD.
I didn't know how to trade. In fact, I didn't know the trading industry at all.
So, my first step into trading was to open an account with a broken. Then I directly bought 200$ worst of BTC . At that time, I saw the graph and thought "This can only go back in the upward direction!" :)
I didn't know anything about Stop loss, Take profit and Risk management.
Today, almost 2 years after, I think that I know how to trade and can also confirm that I still hold this bag of 200$ of bitcoin from 2018 :)
I did spend the 2 last years to learn technical analysis , risk management and leverage trading.
Today (14/05/2020), I know what I'm doing and I'm happy to see that the 2 last years have been positive in terms of gains. Of course, I did not make crazy money with my saving but at least I made more than if I would have kept it in my bank account.
Even if I like trading, I have a full time job which requires my full energy and lots of focus, so, the biggest problem I had is that I didn't have enough time to look at the charts.
Also, I realized that sometimes, neither technical analysis , nor fundamentals worked with crypto currency (at least for short time trading). So, as I have a developer background I decided to try to have a look at algo trading.
The goal for me was neither to make complex algos nor to beat the market but just to automate my trading with simple bot catching the big waves.
I then started to take a look at TV pine script and played with it.
I did my first LONG script in February 2020 to Long the BTC Market. It has some limitations but works well enough for me for the time being. Even if the real trades will bring me half of what the back testing shows, this will still be a lot more than what I was used to win during the last 2 years with my manual trading.
So, here we are! Below you will find some details about my first LONG script. I'm happy to share it with you.
Feel free to play with it, give your comments and bring improvements to it.
But please note that it only works fine with the candle size and crypto pair that I have mentioned below. If you use other settings this algo might loose money!
- Crypto pairs : XBTUSD and ETHXBT
- Candle size: 2 Hours
- Indicator used: Volatility , MACD (12, 26, 7), SMA (100), SMA (200), EMA (20)
- Default StopLoss: -1.5%
- Entry in position if: Volatility < 2%
AND MACD moving up
AND AME (20) moving up
AND SMA (100) moving up
AND SMA (200) moving up
AND EMA (20) > SAM (100)
AND SMA (100) > SMA (200)
- Exit the postion if: Stoploss is reached
OR EMA (20) crossUnder SMA (100)
Here is a summary of the results for this script:
XBTUSD : 01/01/2019 --> 14/05/2020 = +107%
ETHXBT : 01/01/2019 --> 14/05/2020 = +39%
ETHUSD : 01/01/2019 --> 14/05/2020 = +112%
It is far away from being perfect. There are still plenty of things which can be done to improve it but I just wanted to share it :) .
Enjoy playing with it....
Ranged Volume Strategy - evoThis is the strategy version for the ranged volume indicator I published a few days ago.
Long : First yellow break-out after red
Short : First red break-out after yellow
Because this is volume, you want to be using this on an exchange with high volume for the best results. Default settings are not optimized but work great on bitcoins daily chart.
A short explanation of the indicator below:
Dazzling BoltsThis is three moving average based strategy focused on trend-following. Targets and stops are set based on ATR. Following image pictures the strategy with all mas plotted:
Buying conditions are:
►A smoothened moving average (red) is above the exponential moving average (yellow)
►An exponential moving average is above simple moving average (black)
►Low five candles ago was still above the exponential moving average
►Low two candles ago reached below the exponential moving average
►Close of the previous candle was above the exponential moving average
►Ema force is disabled or exponential moving average set candles ago (orange) is still above simple moving average now.
If these conditions are met, Dazzling Bolts will always give you a signal. However, it holds only one position at a time and it will not buy again until it is closed or exited.
There are two ways exiting may happen. Smoothened moving average crosses below simple moving average or it reaches value based on your settings of average true range and its multiplier.
Settings 10/76/200/true/50/true/true/5/5 shows perfect results on EURUSD 15m chart but it does not guarantee the results. It is only 62 trades which is barely a useful statistical source. It is also highly optimized which means its settings filters out bad trades that may be bad only because of randomnation rather than set market behaviour. You need to test it on 200 trades + before using.
Mean Reversion w/ Bollinger BandsThis is a more advanced version of my original mean reversion script.
It employs the famous Bollinger Bands.
This robot will buy when price falls below the lower Bollinger Band, and sell when price moves above the upper Bollinger Band.
I've only tested it on the S&P 500, though you could try it out on other assets to see the backtest performance.
During the recent COVID-19 bear market drop, it produced several buy signals on the S&P which I followed, and made some nice gains so far.
I still think this would make a better investing strategy (buy undervalued / sell over-valued), rather than a trading strategy.
I use this robot for my long term portfolio.
Bollinger Bands Trend StrategyThis is a trading strategy for trend traders.
Buy signals are generated when price closes above upper band.
Sell signals are generated when price closes below lower band.
Good luck.
Pivot Point SuperTrend [Backtest]Hello All,
This is backtesting result of following indicator/strategy. I didn't work on adding other indicators. maybe in the future I can try to combine this with other indicators.
You can visit following link to see "Pivot Point SuperTrend" . by using this backtesting tool, you can test&find better options
There is option "Use Center Line to Close Entry for 50%" . by default it's not enabled. if you enable this option, pivot point center line may push you to close your entry for 50% (can be used as early stoploss/take profit line if you think it's risky)
Enjoy!
[Daveatt] BEST ABCD Pattern Strategy (Trailing SL + TP)Hello traders
This is the strategy version of my ABCD pattern. I added the Trailing Stop and Trailing Profit upon a follower request
I - Concept
I present to you, ladies and gentlemen, the first screener for harmonic patterns .
Starting with an ACBD pattern screener this time!!
I used the calculations from Ricardo Santo's script
In short, he's using fractals (regular or Bill Williams ) for the pattern calculations. A masterpiece !!!
II - Definitions
The ABCD pattern ( AB=CD ) is one of the classic chart patterns which is repeated over and over again.
The ABCD pattern shows perfect harmony between price and time.
The Williams Fractal is an indicator, developed by Bill Williams , that aims to detect reversal points (highs and lows) and marks them with arrows.
Up fractals and down fractals have specific shapes. The Williams Fractal indicator helps users determine in which direction price will develop
💎Strategy filters💎
I included some cool backtest filters:
- Trailing stop with trigger concept coming from this Trailing Stop Strategy
- Trailing profit with trigger coming from this Trailing Profit Strategy
Last words
It works for all asset classes (Forex, crypto, indices, etc...) and does not repaint
All the BEST
Dave
Donchian Channel StrategyLong and Short entries based on the Donchian Channel indicator. The entry can be set to Higher High/Lower Low or the basis line.
FTSMA - Trend is your frendThis my new solid strategy: if you belive that "TREND IS YOUR FRIEND" this is for you!
I have tested with many pairs and at many timeframes and have profit with just minor changes in settings.
I suggest to use it for intraday trading .
VERY IMPORTANT NOTE: this is a trend following strategy, so the target is to stay in the trade as much as possible. If your trading style is more focused on scalping and/or pullbaks, this strategy is not for you.
This strategy uses moving averages applied to Fourier waves for forecasting trend direction.
How strategy works:
- Buy when fast MA is above mid MA and price is above slow MA, which acts as a trend indicator.
- Sell when fast MA is below mid MA and price is below slow MA, which acts as a trend indicator.
Strategy uses a lot of pyramiding orders because when you are in a flat market phase it will close 1 or 2 orders with a loss, but when a big trend starts, it will have profit in a lot of orders.
So, if you analize carefully the strategy results, you will note that "Percent Profitable" is very low (30% in this case) because strategy opened a lot of orders also in flat markets with small losses, BUT "Avg # bars in winning trades" is very high and overall Profit is very high: when a big trend starts, orders are kept open for long time generating big profits.
Thanks to all pinescripters mentioned in the code for their snippets.
I have also a study with alerts. Next improvement (only to whom is interested to this script and follows me): study with alerts on multiple tickers all at one. Leave a comment if you want to have access to study.
HOW TO USE STRATEGY AND STUDY TOGHETER:
1- Add to chart the strategy first, so your workspace will be as clean as possible.
2- Open the Strategy Tester tab at footer of the page.
3- Modify settings to get best results (Profit, Profit Factor, Drawdown).
4- Add study with alerts to your chart with same setting of strategy.
I WILL PROVIDE A DETAILED QUICK INSTALLATION GUIDE WITH THE STUDY!
Please use comment section for any feedback or contact me if you need support.
RWI StrategyA test of the RWI used purely for long/short signals proves surprisingly profitable on 3H and 4H XBTUSD and ETHUSD.
Strategy - Bobo PAPATRHi I've revamped this bot mentioned in the linked idea to make it work with v4 of pine. In doing so there are some very significant changes to how it works. The main one is that it no longer uses traditional daily pivot calculations to calculate the bands. It creates a more dynamic intraday set of pivot points based on recent price action rather than yesterday's ohlc. As published, the bot is tuned for a 15 min time frame. But it actually works well on lower time frames you just need to adjust the lookback periods in settings a bit to re tune it. It's also tuned to ES really but will need tweaking for a different instrument at the very least.
The basic concept is recent price action is used to calculate a 'middle' around which red and green bands are located. Their position or width is largely determined by recent volatility. The middle line is again calculated from recent price action. The three lines from that form a tradeable range with green at the top and red at the bottom. The strategy is simple enough, it shorts as it sinks from outside red, and longs when rising above green. The basic principle being that once you enter that range you have a high probability of hitting the middle before you hit your stop loss. So the basic principle is you are trying to capture the inherent ranginess of liquid indices like S&P 500. That back and forth movement that happens. The bot is capturing this by fading extremes of a recent range but the problem with that is you'dd get murdered in a strong trend. To mitigate that there is a trend calculation running in the background the will prevent trading against firm trends mostly. So the bot should trade mostly in rangy conditions because that is what it is trying to do.
Bot will close issue close signals automatically upon crossing the middle, it also will close automatically at predefined stops or limits. These values are denominated in market mintick values. For example the CFD SPX500 has a mintick of 0.1. Therefore a stop value of 100 will equate to 10 points on the index. If trading the same market via ES1! the mintick value is different - 0.25. So in this case a value of 40 is required to set the stop at 10 points.
Anyway shout if you have questions. Hope it's useful.
TVC:SPX OANDA:SPX500USD
Strategy - Bobo Intraday Swing Bot with filtersThis is an adapted version of my swing bot with additional filters that mean it works quite well on lower timeframes like 1min, 5 mins as long as you adjust the setting accordingly (reduce pivot timescale, band width)
Entry conditions are filtered by an invisible trend calculation running in the background so the bot doesn't repeatedly try and fail to fade a strong trend. It has just about everything you should need for basic use, stop losses and targets, automatically close trade at pivot.
I get good results on rangey instruments like major indices such as SPX / ES that kind of thing. Make sure you understand the minmum tick value of an index so the stop setting on the bot work properly
Hope it's useful!
LUBEThis is a chart meant for 30m BTCUSD but could be used for many other assets, and there are inputs to play with.
I decided on the strange title "LUBE" because I was measuring how many of the previous 500 bars had the current price level already been in. I wanted to discover when the price was in a new zone or an area that it hadn't spent much time in recently... the LUBE zone.
Think of the blue line as showing you the current level friction. If the blue line is high, price is quagmired and not moving quickly. Price could trend sideways for a while before breaking out. A high blue line is a high traffic zone for trading. When the blue line dips low, it's encountering a price zone the asset has not been observed in recently, and this could mean price could break out and move more freely and quickly when it does. We get a trade entry signal if the blue line dips below the bottom white line. The bottom white line is currently set to -10. Think about the lowest the blue line has been recently as 0, and the highest as 100. It is set by default (for BTCUSD 30m chart) to -10 meaning the blue line has to dip a little (-10%) below the lowest it has experienced recently to initiate a trade. This is the LUBE zone. The bottom white line shows that level. Again this is a level lower than the lowest amount of friction experienced in price action for the last 100 bars, but offset by 5 bars showing where that level was at 5 bars ago. We want to dip below that to initiate a trade.
The direction to trade in is determined by a very quick moving weighted moving average (variable name is "fir") to see if the recent trend is up or down. To end a trade, an arbitrary number between 0 and 100 is picked telling us when we are experiencing enough friction again to end the trade. I have it preset to 50 (think of it as 50/100 or half way between the white bars. At a 50% friction level it's time to get out of the trade.
Some shortcomings are missing the bulk of big moves, and experiencing whipsaws where price action zips up and then comes straight back down. Overall the backtest looks sweet enough to use on 2x leverage, experiencing a 17.78% max drawdown at the time of publishing. I wouldn't push the leverage any higher.
To get alerts change the word "strategy" to "study" and delete lines 60-67.
Bot traders using alerts: beware the alert conditions. If a trade goes directly from long to short (which happens rarely), without closing a trade first, it might not act properly. If you use bots to trade, for "LONG" please close any old trades first before putting in instructions to open a leveraged long. To go "SHORT" please remember to close any old trade first as well, and things *should* work out just fine.
Good luck, have fun, and feel free to mess up and butcher this code to your own liking. I'm not responsible if anything bad that happens to you if you use this trading system, or for any bugs you may encounter.
STRAT_STEMWAPHere is the update to the stem matcs strategy.
Here are the additions to the strategy.
1. VWAP tuning
2. Stop Loss adjusting fields now act more appropriate in relation to the super trend values.
3. Split out the volume checks to individual values for short and long
4. A max loss setting. This needs to be adjusted to which security and position size you are trading.
If you are using this on short time frames I suggest that you tweak your settings often.
Percent Trailing Stop %===========
Percent Trailing Stop %
===========
Another Stop Loss Indicator today - our last Fixed SL/TP script went down quite well, this one is for adding a Percent Trailing Stop from Entry Price to your own strategy.
You can ignore the actual entry/exit orders - they're based on a simple MA cross and are therefore NOT relevant, NOT profitable and NOT recommended!
You should be using this code as a way of adding a % Trailing Stop to your own scripts - hope it helps!
You should also notice that a generally considered losing strategy (a simple MA cross) could actually become profitable with careful money management - try combining this Trailing Stop script with our Fixed Stop/Take Profit script for really accurate management of your capital.
-----------
Good Luck and Happy Trading!
Fixed Percent Stop Loss & Take Profit %===========
Fixed Percent Stop Loss & Take Profit %
===========
A neat example of how to set up Fixed Stops and Take Profit as a percent of the entry price.
Yup, that's about it!
You can ignore the actual entry/exit orders - they're based on a simple MA cross and are therefore NOT relevant, NOT really profitable and NOT recommended!
You should be using this code as a way of adding Stops and Takes to your own scripts - hope it helps!
-----------
Good Luck and Happy Trading!
Underworld Hunter Backtesting AlgorhitmThis strategy is built to prove the profitability of my Underworld Hunter indicator . It tests two different strategies. I won't be going into the calculation again since it is part of the original script. I just made a few adjustments.
First one is clearly visual. It plots slimmer twin-coloured lines now and has a different colour for every extreme level. Second is less obvious - I switched Relative Strength Index for Commodity Channel Index.
Extreme levels are as follows: green 100 -► 120, yellow 120 -► 140, orange 140 -► 160, red 160 -► 180 and purple above 180, I will have a special separate algorithm for testing optimal CCI levels someday, in this script, these values are only meant to help you with manual operations and do not influence results of the strategy in any way.
#Trending strategy
The trending strategy opens a position whenever the price leaves the bands and holds it until two consecutive bars are closed within the bands. The picture shows one winning position that hasn't yet been resulted. It also shows a few fakeouts. For this strategy, you want to keep the length below 110, the deviation should be below 2 and you probably want to play lower timeframes.
#Within the bands
The second strategy is pretty much the opposite. It opens a position when the price reaches outer bands and holds it until two consecutive bars are closed within the bands and current bar closes below previous bars low in case of long. It is working on hourly timeframes and you need higher length and deviation to succeed. The picture shows a few positions on EURUSD. Each of them is profitable but would be much higher if you closed it manually when it was time. You need to enable this strategy, which automatically disables the other one.
When using my script, you need to bear in mind that the first strategy doesn't detect optimal levels to close the price. A trend is often followed by a less volatile and boring correction which causes bands to shrink and lower your profits if you don't close manually as it will take longer till bands are reached.
On the other hand, second script literally has no stop-loss. As long as the price is outside the range, it will never close which will cause major drawdowns, unless you control the trade manually. CCI is here to help you with both.
I also recommend combining this with Market Profile (on TW, there is only Volume Profile, which can be used in a similar way) and trading day theory (trending with multiple distributions, trending day, normal day, a variation on a normal day, non-trending day or neutral day). Always keep in mind that it is up to traders to be profitable, indicators can support a good trader, but they will not fix a bad one.
MTF Trailing SL Strategy [QuantNomad]This is a Multi-Timeframe version of my Trailing SL Strategy.
Few weeks ago I published Trailing SL Strategy. There I used only basic Trailing SL to enter positions.
It worked pretty well so I tried to work on it a bit. I thought what if you can use the same ATR TSL on different timeframes and combine them into one signal.
In this strategy you can use only ATR stops and choose 3 other higher timeframes in addition to your current timeframe.
You'll see Trailing SL plotted on the chart form all these timeframes.
Entry Long position if all 4 time-frames agree on long signal.
Exit Long positions when at least 2 time-frames disagree on long signal.
Entry to Short position if all 4 time-frames agree on Short signal.
Exit from Short positions when at least 2 time-frames disagree on Short signal.
Here is the link to my basic Trailing SL Strategy:
Rsi, Ema , Ma and Bollinger Bands for 1 min BtcusdtThis is for 1 min Btcusdt pair.
I am tring to find a way to catch %1 ups and downs.
Basicly it buys when rsi low and minute candle closes under ema,ma and lower bollinger band,
it sells when candle goes over upper bb,low ma, when rsi high.
It sells when rsi high ,candle closes over upper bb,over low ma and does the opposite when buying.
I know it's crowded but still tring to learn what to do ^^
I welcome any suggestions to improve.
It works better with shorts for now.
Don't buy with this !! You might lose big !
Full Candle Outside BB [Bishnu103]Bollinger band defines volatility range based on the current market condition. If a full candle is created outside BB then it is highly volatile and it may reverse to the mean, i.e. middle BB.
Buy - when a green candle is created below lower BB (alert candle) and price goes above high of it.
Buy SL - low of alert candle
Target 1 - middle band
Target 2- upper band
Sell - when a red candle is cerated above upper BB (alert candle) and price goes below low of it
Sell SL - high of alert candle
Target 1 - middle band
Target 2 - lower band
************************************************************************************************************************************************************************************
Disclaimer: This is in-progress strategy. I plan to work further and improve this. So please use this in the live market very carefully and based on your own risk factors.
************************************************************************************************************************************************************************************
Why is it ok to backtest on TradingView from now on!TradingView backtester has bad reputation. For a good reason - it was producing wrong results, and it was clear at first sight how bad they were.
But this has changed. Along with many other improvements in its PineScript coding capabilities, TradingView fixed important bug, which was the main reason for miscalculations. TradingView didn't really speak out about this fix, so let me try :)
Have a look at this short code of a swing trading strategy (PLEASE DON'T FOCUS ON BACKTEST RESULTS ATTACHED HERE - THEY DO NOT MATTER). Sometimes entry condition happens together with closing condition for the already ongoing trade. Example: the condition to close Long entry is the same as a condition to enter Short. And when these two aligned, not only a Long was closed and Short was entered (as intended), but also a second Short was entered, too!!! What's even worse, that second short was not controlled with closing conditions inside strategy.exit() function and it very often lead to losses exceeding whatever was declared in "loss=" parameter. This could not have worked well...
But HOORAY!!! - it has been fixed and won't happen anymore. So together with other improvements - TradingView's backtester and PineScript is now ok to work with on standard candlesticks :)
Yep, no need to code strategies and backtest them on other platforms anymore.
----------------
Having said the above, there are still some pitfalls remaining, which you need to be aware of and avoid:
Don't backtest on HeikenAshi, Renko, Kagi candlesticks. They were not invented with backtesting in mind. There are still using wrong price levels for entries and therefore producing always too good backtesting results. Only standard candlesticks are reliable to backtest on.
Don't use Trailing Stop in your code. TradingView operates only on closed candlesticks, not on tick data and because of that, backtester will always assume price has first reached its favourable extreme (so 'high' when you are in Long trade and 'low' when you are in Short trade) before it starts to pull back. Which is rarely the truth in reality. Therefore strategies using Trailing Stop are also producing too good backtesting results. It is especially well visible on higher timeframe strategies - for some reason your strategy manages to make gains on those huge, fat candlesticks :) But that's not reality.
"when=" inside strategy.exit() does not work as you would intuitively expect. If you want to have logical condition to close your trade (for example - crossover(rsi(close,14),20)) you need to place it inside strategy.close() function. And leave StopLoss + TakeProfit conditions inside strategy.exit() function. Just as in attached code.
If you're working with pyramiding, add "process_orders_on_close=ANY" to your strategy() script header. Default setting ("=FIFO") will first close the trade, which was opened first, not the one which was hit by Stop-Loss condidtion.
----------------
That's it, I guess :) If you are noticing other issues with backtester and would like to share, let everyone know in comments. If the issue is indeed a bug, there is a chance TradingView dev team will hear your voice and take it into account when working on other improvements. Just like they heard about the bug I described above.
P.S. I know for a fact that more improvements in the backtesting area are coming. Some will change the game even for non-coding traders. If you want to be notified quickly and with my comment - gimme "follow".