OPEN-SOURCE SCRIPT

Simple SuperTrend Strategy for BTCUSD 4H

已更新
Hello guys!, If you are a swing trader and you are looking for a simple trend strategy, you should check this one. Based in the supertrend indicator, this strategy will help you to catch big movements in BTCUSD 4H and avoid losses as much as possible in consolidated situations of the market

This strategy was designed for BTCUSD in 4H timeframe
Backtesting context: 2020-01-02 to 2023-01-05 (The strategy has also worked in previous years)

Trade conditions:

Rules are actually simple, the most important thing is the risk and position management of this strategy

For long:

Once Supertrend changes from a downtrend to a uptrend, you enter into a long position. The stop loss will be defined by the atr stop loss
The first profit will be of 0.75 risk/reward ratio where half position will be closed. When this happens, you move the stop loss to break even.
Now, just will be there two situations:
  • Once Supertrend changes from a uptrend to a downtrend, you close the other half of the initial long position.
  • If price goes againts the position, the position will be closed due to breakeven.


For short:

Once Supertrend changes from a uptrend to a downtrend, you enter into a short position. The stop loss will be defined by the atr stop loss
The first profit will be of 0.75 risk/reward ratio where half position will be closed. When this happens, you move the stop loss to break even.
Like in the long position, just will be there two situations:
  • Once Supertrend changes from a downtrend to a uptrend, you close the other half of the initial short position.
  • If price goes againts the position, the position will be closed due to breakeven.


Risk management

For calculate the amount of the position you will use just a small percent of your initial capital for the strategy and you will use the atr stop loss for this.
Example: You have 1000 usd and you just want to risk 2,5% of your account, there is a long signal at price of 20,000 usd. The stop loss price from atr stop loss is 19,000. You calculate the distance in percent between 20,000 and 19,000. In this case, that distance would be of 5,0%. Then, you calculate your position by this way: (initial or current capital * risk per trade of your account) / (stop loss distance).
Using these values on the formula: (1000*2,5%)/(5,0%) = 500usd. It means, you have to use 500 usd for risking 2.5% of your account.
We will use this risk management for apply compound interest.

Script functions

Inside of settings, you will find some utilities for display atr stop loss, supertrend or positions.
You will find the settings for risk management at the end of the script if you want to change something. But rebember, do not change values from indicators, the idea is to not over optimize the strategy.
If you want to change the initial capital for backtest the strategy, go to properties, and also enter the commisions of your exchange and slippage for more realistic results.

Signals meanings:

L for long position. CL for close long position.
S for short position. CS for close short position.
Tp for take profit (it also appears when the position is closed due to stop loss, this due to the script uses two kind of positions)
Exit due to break even or due to stop loss

Some things to consider

USE UNDER YOUR OWN RISK. PAST RESULTS DO NOT REPRESENT THE FUTURE.
DEPENDING OF % ACCOUNT RISK PER TRADE, YOU COULD REQUIRE LEVERAGE FOR OPEN SOME POSITIONS, SO PLEASE, BE CAREFULL AND USE CORRECTLY THE RISK MANAGEMENT

The amount of trades closed in the backtest are not exactly the real ones. If you want to know the real ones, go to settings and change % of trade for first take profit to 100 for getting the real ones. In the backtest, the real amount of opened trades was of 194.

Indicators used:
  • Supertrend
    *Atr stop loss by garethyeo

This is the fist strategy that I publish in tradingview, I will be glad with you for any suggestion, support or advice for future scripts. Do not doubt in make any question you have and if you liked this content, leave a boost. I plan to bring more strategies and useful content for you!

版本注释
New filter for the strategy: Rsi

Sometimes some positions could be closed due to breakeven and then we loose a trend move. For this reason I decided to add this filter for re enter on the movement:
  • If close is still in a Up Trend (this is given by the SuperTrend indicator), Rsi crosses above oversold zone and the previous position was closed by breakeven, we enter into a long position again, using a new stop loss given by atr stoploss and also a breakeven/take profit of 0.75 points of risk/reward
  • If close is still in a Down Trend (this is given by the SuperTrend indicator), Rsi crosses under overbought zone and the previous position was closed by breakeven, we enter into a short position again, using a new stop loss given by atr stoploss and also a breakeven/take profit of 0.75 points of risk/reward


Strategy as an indicator:
  • Green and Red triangles added as long or short signals
  • Green point added for showing first Take profit and Break even price
  • White point added for showing Stop loss price


Do not forget you can deactivate trades on chart in style options for getting a cleaner view of the strategy.
版本注释
Some bugs fixed
版本注释
Position calculator added

In settings, you can enter the amount in usd of your account and the amount in percentage for risking per trade of the account. You will see this value in green color in the upper left corner that shows the amount in usd to use for risking the specific percentage of your account.
版本注释
A simple change. Now you can choose what´s the stop loss source :)
btcusd4hbtcusdstrategybtcusdtradingChart patternsforecastingprofitablestrategyprofitabletradingsupertrendstrategyswingstrategyswingtradingTrend Analysistrendfollowing

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明