vpirinski

MACD_RSI_trend_following

vpirinski 업데이트됨   
INFO:
This indicator can be used to build-up a strategy for trading of assets which are currently in trending phase.
My preference is to use it on slowly moving assets like GOLD and on higher timeframes, but practice may show that we find more usefull cases.
This script uses two indicators - MACD and RSI, as the timeframe that those are extracted for is configurable (defaults with the Chart TF, but can be any other selected by the user).
The strategy has the following simple idea - buy if any if the conditions below is true:
  • The selected TF MACD line crosses above the signal line and the TF RSI is above the user selected trigger value
  • The selected TF MACD line is above the signal line and the TF RSI crosses above the user selected trigger value
Once we're in position we wait for the selected TF MACD line to cross below the signal line, and then we set a SL at the low of that bar

DETAILS and USAGE:
In the current implementation I find two possible use cases for the indicator:
  • as a stand-alone indicator on the chart which can also fire alerts that can help to determine if we want to manually enter/exit trades based on them
  • can be used to connect to the Signal input of the TTS (TempalteTradingStrategy) by jason5480 in order to backtest it, thus effectively turning it into a strategy (instructions below in TTS CONNECTIVITY section)
    In the example below we see a position opened at the bar after the buy indicator from the script has been triggered, and then later after the SL indicator from the script has been triggered a SL has been set on the lower wick of the closing candle, and the position eventually got closed once the price hit that level. Note that most of the drawing on the example snapshot below are from the TTS indicator following the buy/sell/SL conditions themseves:
Trading period can be selected from the indicator itself to limit to more interesting periods.
Arrow indications are drawn on the chart to indicate the trading conditions met in the script - green arrow for a buy signal indication and orange for LTF crossunder to indicate setting of SL.

SETTINGS:
Leaving all of the settings as in vanilla use case, as both the MACD and RSI indicator's settings follow the default ones for the stand-alone indicators themselves.
The start-end date is a time filter that can be extermely usefull when backtesting different time periods.
Pesonal preference is using the script on a D/W timeframe, while the indicator is configured to use Monthly chart.
The default value of the RSI filter is left to 50, which can be changed. I.e. if the RSI is above 50 we have a regime filter based on the MACD criteria.

EXTERNAL LIBRARIES:
The script uses a couple of external libraries:
  • HeWhoMustNotBeNamed/enhanced_ta/14 - collection of TA indicators
  • jason5480/tts_convention/3 - more details about the Template Trading Strategy below
I would like to highly appreciate and credit the work of both HeWhoMustNotBeNamed and jason5480 for providing them to the community.

TTS SETTINGS (NEEDED IF USED TO BACKTEST WITH TTS):
The TempalteTradingStrategy is a strategy script developed in Pine by jason5480, which I recommend for quick turn-around of testing different ideas on a proven and tested framework
I cannot give enough credit to the developer for the efforts put in building of the infrastructure, so I advice everyone that wants to use it first to get familiar with the concept and by checking
by checking jason5480's profile www.tradingview.com/u/jason5480/
The TTS itself is extremely functional and have a lot of properties, so its functionality is beyond the scope of the current script -
Again, I strongly recommend to be thoroughly epxlored by everyone that plans on using it.
In the nutshell it is a script that can be feed with buy/sell signals from an external indicator script and based on many configuration options it can determine how to execute the trades.
The TTS has many settings that can be applied, so below I will cover only the ones that differ from the default ones, at least according to my testing - do your own research, you may find something even better :)
The current/latest version that I've been using as of writing and testing this script is TTSv48
Settings which differ from the default ones:
  • from - False (time filter is from the indicator script itself)
  • Deal Conditions Mode - External (take enter/exit conditions from an external script)
  • 🔌Signal 🛈➡ - MACD_RSI_trend_following: 🔌Signal to TTSv48 (this is the output from the indicator script, according to the TTS convention)
  • Sat/Sun - true (for crypto, in order to trade 24/7)
  • Order Type​​ - STOP (perform stop order)
  • Distance Method​​ - HHLL (HigherHighLowerLow - in order to set the SL according to the strategy definition from above)
The next are just personal preferenes, you can feel free to experiment according to your trading style
  • Take Profit Targets - 0 (either 100% in or out, no incremental stepping in or out of positions)
  • Dist Mul|Len Long/Short- 10 (make sure that we don't close on profitable trades by any reason)
  • Quantity Method - EQUITY (personal backtesting preference is to consider each backtest as a separate portfolio, so determine the position size by 100% of the allocated equity size)
  • Equity %         - 100 (note above)
릴리즈 노트:
updated the plot shapes to be better associated with price action been attached to bars
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?