tso_trade

[Support and Resistance with Trend Lines] with Backtest (TSO)

tso_trade Telah dikemas kini   
with Backtest (TSO)
===========================================================================
===========================================================================
This indicator serves as a comprehensive full-cycle trading system, providing alerts at each stage of the trade, from opening to closure. The algorithm uses most recent and historical S&R (Support and Resistance) levels with most recent and historical Trend Lines, generating signals for trades when Breaks/Bounces occur (Trade Open Signal triggers can be configured via very customizable indicator Input "Signal Trigger Matrix" settings). With signal for trade open, TP (Take Profit and SL (Stop Loss) levels are calculated as well and marked on the chart including alerts for each action of the trade. The indicator offers a variety of automated approaches for TP (Take-Profit) and SL (Stop-Loss) settings. These include static current/historical S&R (Support and Resistance) levels or S&R/Trend Lines dynamic breaks for TP (Take-Profit) and various SL (Stop-Loss) approaches, including ATR Trailing SL, opposite S&R (Support and Resistance) levels SL, opposite Trend Lines SL and more. This diverse set of tools ensure flexibility in tailoring TP (Take-Profit) and SL (Stop-Loss) parameters to different market conditions, contributing to a more adaptive and robust trading system. Additionally, a series of signal analysis tools, including market sentiment, candle bar analysis, divergence, and volume, enhance the precision of trading signals.

* Works with popular timeframes: 1M, 3M, 5M, 15M, 30M, 45M, 1H.
* Works well with Futures and Indices, can be used to trade Stocks, Crypto and FOREX.
* Includes LIVE alert/labels Breakouts and Bounces signal trigger feature, which can be used for scalping (NOTE: This approach cannot be backtested).
* Every action of the trade is calculated on a confirmed closed candle bar state (barstate.isconfirmed), so the indicator will never repaint.
==============================================================

Indicator examples:
---------------------------------------------------------------------------
Strategy Config: SRTL_MES_15M3Y_EODoff_ALL
Here is a nice example of MES (Micro E-Mini S&P 500 Index Futures) configuration, which uses S&R (Support and Resistance) breakouts as signal trigger with Elliot Wave confirmation and previous S&R historical levels for TP (Take-Profit).
---------------------------------------------------------------------------
An example of an intraday Tesla trade. Also the green arrows will be displayed IMMEDIATELY when Breakout/Reverse Bounce occurs (same an Alert will be triggered immediately).
===========================================================================

Trading open/close/TP/SL labels, plots and colors explanations:
---------------------------------------------------------------------------
>>> S&R (Support and Resistance) levels/lines: orange - support, blue - resistance (can be hidden).
>>> Trend Lines: yellow - support, green - resistance (can be hidden).
>>> Blue labels show resistance breakouts and bounces, light-blue - bullish, dark-blue - bearish
>>> Yellow labels show resistance breakouts and bounces, light-yellow - bullish, dark-yellow - bearish
>>> Green/Red arrows on top/bottom of candle bar will show LIVE breakouts (if turned on)

>>>>> LONG open: green "house" looking arrow below candle bar.
>>>>> SHORT open: red "house" looking arrow above candle bar.
>>>>> LONG/SHORT take-profit target: green/red circles (multi-profit > TP2/3/4/5 smaller circles).
>>>>> LONG/SHORT stop-loss target: green/red + crosses.
>>>>> LONG/SHORT take-profit hits: green/red diamonds.
>>>>> LONG/SHORT stop-loss hits: green/red X-crosses.
>>>>> LONG/SHORT EOD (End of Day | Intraday style) close (profitable trade): green/red squares.
>>>>> LONG/SHORT EOD (End of Day | Intraday style) close (loss trade): green/red PLUS(+)-crosses.
===========================================================================

STATS TABLE ///////////////////////////////////////////////////////////////
---------------------------------------------------------------------------
>>> Trading STATS table on the chart showing current trade direction, Last TP (Take-Profit) Taken, Current Trade PL (profit/loss in price difference from trade open to the very current state).
---------------------------------------------------------------------------

CUSTOM TRADING DATE RANGE /////////////////////////////////////////////////
---------------------------------------------------------------------------
>>>>> This feature can be used to manually set indicator trading range from and to a specific date and time. NOTE: This is not intended for a very long date range backtesting, utilize TradingView Strategy Tester for that.

* Use TradingView “Strategy Tester” to see Backtesting results
NOTE: If Strategy Tester does not show any results with Date Ranged fully unchecked, there may be an issue where a script opens a trade, but there is not enough TradingView power to set the Take-Profit and Stop-Loss and somehow an open trade gets stuck and never closes, so there are “no trades present”. In such case - manually check “Start”/“End” dates or use “Deep Backtesting” feature!
---------------------------------------------------------------------------

INTRADAY ACTIVE TRADING SESSION CONFIGURATION /////////////////////////////
---------------------------------------------------------------------------
>>> Regional Active Trading Session Hours Schedule: If selected - trades will only open during regional active trading session, if 'OFF', there will be no trading schedule and trades will open 24/7.

>>> EOD(End of Day) Close - On/Off: Close the trade if it's still open at the end of active trading session (on the very last candle bar). NOTE: If no region is selected at 'Regional Active Trading Session Schedule' - there will be no EOD(End of Day) Close and trades will run overnight until either SL(Stop-Loss) or TP(Take-Profit) is hit!
>>>>> EOD(End of Day) Close - 1 candle bar before last: This is specifically for stocks as while usually indices can be closed 15minutes after the market closes, for stocks - the last candle bar closes at the same time with the market active trading session, which if closed - trades can't be closed until next day/session! Enable this setting for the trade to close/alert 1 candle bar before the last one, so there is still time to close the trade at the Broker (NOTE: depending on the timeframe, 1 candle bar can be: 15sec, 30sec, 1min, 3min, 5min, 15min, 30min, 45min, 1h).
---------------------------------------------------------------------------

SIGNAL TRIGGER MATRIX ////////////////////////////////////////////////
---------------------------------------------------------------------------
>>> Trading Engine: This setting turns on TradingView Strategy trading engine for backtesting.

>>> Market Session Only: With this setting turned on, all signal trigger Breaks/Bounces will be hidden during Pre/Post market time.

>>> Plot S&R Levels/Lines: Plot S&R (Support and Resistance) on chart. Note: historical levels/lines will only be plotted if hit (Break/Bounce).

>>> Plot Trend Lines Levels/Lines: Plot Trend Lines levels/lines on chart. Note: historical levels/lines will only be plotted if hit (Break/Bounce).

>>> Use S&R Current Levels | Use S&R Historical Levels | Use Trend Lines Current Levels | Use Trend Lines Historical Levels |: Choose which levels should be used for Breaks/Bounces to be captured on. If all triggers are turned on/checked - whatever happens 1st wins the trigger.

>>> Breaks | Bounces: 'Breaks': Turn on Breaks through levels/lines signal trigger. | 'Bounces': Turn on Bounces off levels/lines signal trigger.

>>> Signal: Regular | Signal: S&R Combo | Signal: TL Combo | Signal: S&R + TL Combo | Signal: Repeat Action |: Trade open signal trigger execution approach MATRIX (If 1 or more turned on at the same time - whatever comes first will be the trade signal trigger). 'Regular': A single Break/Bounce must occur on a closed bar for signal trigger. 'S&R Combo': A combination of 2 Current + Historical S&R (Support and Resistance) Break/Bounce must happen in the same direction on same bar for signal trigger. 'TL Combo': A combination of 2 Current + Historical Trend Lines Break/Bounce must happen in the same direction on same bar for signal trigger. 'S&R + TL Combo': a combination of ANY S&R and Trend Line Break/Bounce must happen in the same direction on same bar for signal trigger. 'Repeat Action': Initial and then confirmation (2nd/3rd/etc. consecutive occurence) Break/Bounce must occur on same level/line for signal trigger.

>>> Historical - Look Back (# of days): How far back (in # of days) will historical S&R/Trend Lines will be used for Trade Open signals/TP/SL/etc.

>>> Historical - Look Back Invalidation (# of days): IF THERE IS TOO MUCH HISTORICAL LEVELS/LINES ON CHART - LOWER THIS SETTING + MAKE SURE IT'S SMALLER THAN 'Historical - Look Back (# of days)'. With big Look back period (5+ days) - it can become very messy with too many historical levels/lines. To clear oldest historical levels/lines - set Look Back Invalidation # of days to less than Historical Look Back # of days. (After X # of Look Back Invalidation days - older levels/lines will become invalidated and no longer used for opening trades/TP (Take-Profit)/SL (Stop-Loss), while newer levels/lines will still be discovered.

>>> S&R/Trend Lines - Support/Resistance combined into 1 entity: Every level or a line becomes simply a level or a line, regardless if it originally was a support or resistance. By default, depending on the level/line originally being support or resistance - the signal direction will be such as: Resistance is broken > LONG / bounced > SHORT; Support is broken > SHORT / bounced > LONG; with this setting on, either level or line can be both broken or bounced off in ANY direction, trade open direction will depend on current market sentiment only.
---------------------------------------------------------------------------

S&R CONFIGURATION ////////////////////////////////////////////////
---------------------------------------------------------------------------
>>> S&R Search - Left Bars (current): This setting is for calculating optimal S&R (Support and Resistance) levels (in combination with below - Right Bars).

>>> S&R Search - Right Bars (current): This setting is for calculating optimal S&R (Support and Resistance) levels (in combination with above - Left Bars).

>>> S&R Search - Custom Resolution (current): This is a custom timeframe setting specifically for S&R Search, it disregards current chart timeframe. This is great to use for scalping, for example: with main chart set to 1min and the custom timeframe set to 3min or 5min - there will be stronger support/resistance levels with more detailed price action.

>>> S&R Search - Left Bars (historical): This setting is for calculating optimal S&R (Support and Resistance) levels (in combination with below - Right Bars).

>>> S&R Search - Right Bars (historical): This setting is for calculating optimal S&R (Support and Resistance) levels (in combination with above - Left Bars).

>>> S&R Search - Custom Resolution (historical): This is a custom timeframe setting specifically for S&R Search, it disregards current chart timeframe. This is great to use for scalping, for example: with main chart set to 1min and the custom timeframe set to 3min or 5min - there will be stronger support/resistance levels with more detailed price action.

>>> S&R - Historical S&R Levels - Extend to the right: Extend all S&R lines to the right.

>>> S&R (Current/Historical) - Live Breakout/Bounce - ALERT/SHOW: NOTE: Alert wlil trigger immediately at price Breaking thru or Bouncing off level/line and an arrow above/below the bar will show the direction of breakout/bounce. If on that same live bar - price comes back causing the Breakout/Bounce become no longer valid - the arrow will disappear as the condition of the Break/Bounce will no longer be valid.
---------------------------------------------------------------------------

TREND LINES CONFIGURATION ////////////////////////////////////////////////
---------------------------------------------------------------------------
>>> Show: Trend Line development (where it 'did not exist' yet): It takes 2 pivots to develop a trend line, pivot is established at least 3 candle bars later from where the pivot is. With this setting turned on - it will plot dashed lines where trend lines originated connecting the 1st and 2nd pivot point up to where the trend line became established (where in reality you would now be able to draw a certain trend line). Established already generated trend line are plotted with a solid line.

>>> Trend Lines - Line Slope Confirmation: LONG breakout will only be shown if trend line is goind downslope \. SHORT breakout will only be shown if trend line is goind upslope /.

>>> Trend Lines - Search - Left Bars (current): This setting is for calculating optimal Trend Lines.

>>> Trend Lines - Search - Right Bars (current): This setting is for calculating optimal Trend Lines.

>>> Trend Lines - Custom Resolution (current): This is a custom timeframe setting specifically for S&R Search, it disregards current chart timeframe. This is great to use for scalping, for example: with main chart set to 1min and the custom timeframe set to 3min or 5min - there will be stronger support/resistance levels with more detailed price action.

>>> Trend Lines - Search - Left Bars (historical): This setting is for calculating optimal Trend Lines.

>>> Trend Lines - Search - Right Bars (historical): This setting is for calculating optimal Trend Lines.

>>> Trend Lines - Custom Resolution (historical): This is a custom timeframe setting specifically for S&R Search, it disregards current chart timeframe. This is great to use for scalping, for example: with main chart set to 1min and the custom timeframe set to 3min or 5min - there will be stronger support/resistance levels with more detailed price action.

>>> Trend Lines - Historical Trend Lines - Extend to the right: Extend all Trend Lines to the right.

>>> Trend Lines (Current/Historical) - Live Breakout/Bounce - ALERT/SHOW: NOTE: Alert will trigger immediately at price Breaking thru or Bouncing off level/line and an arrow above/below the bar will show the direction of breakout/bounce. If on that same live bar - price comes back causing the Breakout/Bounce become no longer valid - the arrow will disappear as the condition of the Break/Bounce will no longer be valid.
---------------------------------------------------------------------------

TAKE-PROFIT/STOP-LOSS CONFIGURATION ///////////////////////////////////////
---------------------------------------------------------------------------
>>> TP (Take-Profit) System: 'S&R Static Current/Historical': TP (Take-Profit) is calculated using current/historical S&R (Support & Resistance) levels at trade open and remains static. 'S&R/Trend Lines Dynamic Breaks': TP (Take-Profit) is fully dynamic and will be trigger at price above trade open price and with Breakout occurence (S&R or Trend Line current/historical breakout).

>>> TP (Take-Profit) # of targets: It is wise to divide the trade into several profit targets. With this setting - up to 5 TP (Take-Profit) targets can be approached. The trade will be equally divided up by the selected # of TP (Take-Profit) targets.

>>> SL (Stop-Loss) System: 'ATR-Trailing-SL': SL (Stop-Loss) is trail-following the ATR (Average True Range) line, NOTE: If at signal trigger, ATR will be against the trade direction - trade open signal will be skipped; 'S&R-Static-SL': SL (Stop-Loss) is set at trade open per optimal most recent S&R level and remains there until trade closes; 'TrendLines-Static-SL': SL (Stop-Loss) is set at trade open per optimal most recent trend line and remains there until trade closes; 'TrendLines-Dynamic-SL': SL (Stop-Loss) will be set per current opposite trend line and follow it until trade is open.; 'Oppos-Sig-Trd-in-Loss': SL (Stop-Loss) will trigger at opposite signal with trade currently at loss.

>>> SL (Stop-Loss) - On/Off: Without SL (Stop-Loss), unless EOD (End of Day) Close is turned on - there will be no SL (Stop-Loss) at all!
---------------------------------------------------------------------------

MARKET SENTIMENT CONFIRMATION ///////////////////////////////////////
---------------------------------------------------------------------------
>>> Market Sentiment: Signal is confirmed per Market Sentiment direction. If Market Sentiment is turned off - whatever signal comes 1st will be the trade open trigger.
---------------------------------------------------------------------------

SIGNAL ANALYSIS AND CLEANUP ///////////////////////////////////////////////
---------------------------------------------------------------------------
>>> Signal Cleanup - Bar Color: Include Bar Color (bullish/bearish) confirmation, LONG signal will only be opened if signal bar is green/bullish, SHORT if red/bearish.

>>> Signal Cleanup - Bar Directional Structure: Skip opposite bar structure types signals (For example: bearish green hammer).

>>> Signal Cleanup - Bar Doji Skip: Skip doji (indecisive) candles signals.

>>> Signal Cleanup - EWO (Elliott Wave Oscillator): Include EWO (Elliott Wave Oscillator), LONG will only be opened if EWO is bullish / SHORT if EWO is bearish.

>>> Signal Cleanup - VWAP (Volume-Weighted Average Price): Include VWAP (Volume-Weighted Average Price), LONG will only be opened if price is above VWAP / SHORT if price is below VWAP.

>>> Signal Cleanup - MA (Moving Average) Confirmation: Include MA (Moving Average), LONG will only be opened if MA is bullish / SHORT if MA is bearish.

>>> Signal Cleanup - ATR (Average True Range): Include ATR (Average True Range) confirmation, LONG will only be opened if ATR is bullish / SHORT if ATR is bearish.

>>> Signal Cleanup - Divergence(RSI + MACD): Include Divergence (RSI + MACD) confirmation, LONG will only be opened if Divergence is bullish / SHORT if Divergence is bearish.

>>> Signal Cleanup - Volume % Strength: Include Volume strength/percentage confirmation, LONG/SHORT will only be opened with strong Volume matching the signal direction | By default, strong Volume percentage is set to 150% and weak to 50%.

>>> Signal Cleanup - Volume Above Average: Include Volume Above Moving Average (Volume closing bar closes above volume moving average) confirmation, LONG/SHORT will only be opened with Volume above average - Volume closed bar color must match the closed price color (bullish/bearish direction) + Volume bar must be closed above volume MA line).
---------------------------------------------------------------------------
===========================================================================
||||||||||||||||||||||||||||||||||| *** ||||||||||||||||||||||||||||||||||| *** |||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||| *** ||||||||||||||||||||||||||||||||||| *** |||||||||||||||||||||||||||||||||||
TP System - VERY IMPORTANT INFO!
-------------------------------------------------------------------------------------------------------------------
"TP PERCENTAGE" - amount by which current trade/position needs to be reduced/partially closed/sold.
-------------------------------------------------------------------------------------------------------------------
TP System: Dynamic
"TP PERCENTAGE" - will always be the same amount (trade/position size divided by the # of take-profit(TP) targets) and percentage to be closed will always be of the ORIGINAL trade/position.
-------------------------------------------------------------------------------------------------------------------
TP System: Static
"TP PERCENTAGE" - will always be the same amount IF take-profit(TP) targets are hit 1-by-1 (TP1 > TP2 > TP3 > TP4 > TP5), otherwise it will vary and unless it is a 1st take-profit(TP1), the REMAINING trade/position size will always be smaller than original and therefore the percentage to be closed will always be of the REMAINING trade/position and NOT the original one!
-------------------------------------------------------------------------------------------------------------------

"TP PERCENTAGE" CheatSheet (these are the only percentages you may see)
-----------------------------------------------------------------------
TP PERCENTAGE---Close/Sell Amount-------------Example (trade size: 50 stocks)
20%-------------trade size * 0.2--------------50 * 0.2 = 10 stocks
25%-------------trade size * 0.25-------------50 * 0.25 = 12.5(~13) stocks
34%-------------trade size * 0.34-------------50 * 0.34 = 17 stocks
40%-------------trade size * 0.4--------------50 * 0.4 = 20 stocks
50%-------------trade size * 0.5--------------50 * 0.5 = 25 stocks
60%-------------trade size * 0.6--------------50 * 0.6 = 30 stocks
66%-------------trade size * 0.66-------------50 * 0.66 = 33 stocks
75%-------------trade size * 0.75-------------50 * 0.75 = 37.5(~38) stocks
80%-------------trade size * 0.8--------------50 * 0.8 = 40 stocks
100%------------trade size--------------------50 = 50 stocks
-----------------------------------------------------------------------

If for any reason a portion of the current/remaining trade closed at such occurrence was slightly wrong, it is not an issue. Such occurrences are rare and with slight difference in partial TP closed is not significant to overall performance of our algorithms.
||||||||||||||||||||||||||||||||||| *** ||||||||||||||||||||||||||||||||||| *** |||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||| *** ||||||||||||||||||||||||||||||||||| *** |||||||||||||||||||||||||||||||||||
===========================================================================

Alert Settings (you don’t have to touch this section unless you will be using TradingView alerts through a Webhook to use with trading bot)
---------------------------------------------------------------------------
Here is how a LONG OPEN alert looks like.
NOTE: Each label , , etc. is customizable, you can change the text of it within indicator Input settings.

ALERT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
COIN: BTCUSD
TIMEFRAME: 15M
LONG: OPEN
ENTRY: 20000
TP1: 20500
TP2: 21000
TP3: 21500
TP4: 22500
TP5: 23500
SL: 19000
Leverage: 0
---------------------------------------------------------------------------

Here is how a TP1 alert will look with 5 TPs breakdown of the trade.
NOTE1: Next to TP1 taken it will show at which price it was triggered.
NOTE2: Next to "TP Percentage" it shows how much of the CURRENT/ACTIVE/REMAINING trade needs to be closed.
NOTE2: If TP2/3/4/5 comes before TP1 - the alert will tell you exactly how many percent of the trade needs to be closed!

ALERT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
COIN: BTCUSD
TIMEFRAME: 15M
LONG: TP1
TP1: 20500
TP Percentage: 20%
---------------------------------------------------------------------------

Here is how an alert will look for LONG - STOP-LOSS.
ALERT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
COIN: BTCUSD
TIMEFRAME: 15M
ENTRY: 20000
LONG: SL
SL: 19000
---------------------------------------------------------------------------

Here is how an alert will look for LONG - EOD (End of Day) In Profit close.
ALERT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
COIN: BTCUSD
TIMEFRAME: 15M
LONG: EOD-Close (profit)
ENTRY: 20000
EOD-Close: 21900
===========================================================================

Adding Alerts in TradngView
---------------------------------------------------------------------------
-Add indicator to chart and make sure the correct strategy is configured (check Backtesting results)
-Right-click anywhere on the TradingView chart
-Click on Add alert
-Condition: Select this indicator by it’s name
-Immediately below, change it to "alert() function calls only", as other wise there will be 2 alerts for every alert!
-Expiration: Open-ended (that may require higher tier TradingView account, otherwise the alert will need to be occasionally re-triggered)
-Alert name: Whatever you desire
-Hit “Create”
-Note: If you change ANY Settings within the indicator – you must DELETE the current alert and create a new one per steps above, otherwise it will continue triggering alerts per old Settings!
===========================================================================

Good Luck! (NOTE: Trading is very risky, past performance is not necessarily indicative of future results, so please trade responsibly!)
---------------------------------------------------------------------------
NOTE: There seems to be a strange glitch when strategy is running live, it will show "double-take" take-profits labels on the chart. This is not affecting the script logic and backtesting results, if you simply change the timeframe real quick to something else then back - it will no longer show the duplicate orders... this must be some sort of a glitch as every alert was thoroughly tested to make sure everything is working!
Nota Keluaran:
* Updating image
Nota Keluaran:
* Another attempt to update the indicator so it shows the actual indicator as for some reason it keeps uploading blank chart...
Nota Keluaran:
* Minor fix
Nota Keluaran:
* Chart update
Nota Keluaran:
* Added an option to hide all the default Breaks/Bounces labels
Nota Keluaran:
* Minor fix
Nota Keluaran:
* Minor fix
Nota Keluaran:
* Cosmetic fix

Trading like a machine!
Skrip jemputan sahaja

Akses ke skrip ini adalah terhad kepada pengguna yang diberikan akses oleh penulis dan kebiasaannya memerlukan pembayaran. Anda boleh menambahkannya kepada senarai kegemaran anda, tetapi anda hanya dapat menggunakannya setelah meminta izin dan mendapatkannya dari penulis. Sila hubungi tso_trade untuk lebih maklumat atau rujuk arahan penulis seperti di bawah.

TradingView tidak mencadangkan untuk membayar untuk sesuatu skrip dan menggunakannya sehingga anda adalah 100% mempercayai penulisnya dan memahami bagaimana skrip itu berfungsi. Dalam banyak kes, anda boleh mencari alternatif sumber terbuka yang bagus secara percuma di Skrip Komunitikami.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.

Arahan penulis

Video guide: Video Guide Coming Up Soon! Please message me directly via TradingView for trial access or any other questions.

Ingin menggunakan skrip ini pada carta?

Amaran: sila baca sebelum memohon akses.