tso_trade

Round Numbers Breakouts Smart Formula Signals and Alerts

tso_trade Updated   
This indicator uses Round Numbers breakouts and then uses smart formula with the near Round Numbers to determine best TP (take profit)/SL (stop loss) areas. Furthermore, it calculates win percentage, shows in-profit/in-loss peaks and the price amount result over a customizable date range, which when combined well with the smart formula provides decent profitable outcome. I have decided to write my own backtesting engine as the integrated TradingView strategy one has limitations and has shown inconsistencies when compared to manual backtesting…
There are many settings you can manually change to trade any instrument, any style, any approach and there are presets included for Bitcoin(BTCUSD), FOREX(EURUSD), SPY(S&P500), so you can start trading immediately! Alerts correspond to indicator settings and are turned on with a few clicks. There are 3 tables (each can be shown/hidden) showing everything you need to see/know to calibrate the indicator as you wish.

Labels, lines, tables explanations (everything can be hidden/shown):
- LONG Labels: medium-green: position open, dark-green: SL, bright-green: TP, blue: TP2
- SHORT Labels: medium-red: position open, dark-red: SL, bright-red: TP, purple: TP2
- Gray circles: position entry area | Yellow crosses: SL area
- Green line: Long TP1, Blue line: Long TP2 | Red Line: Short TP1, Purple line: Short TP2
- Grey lines: Round Numbers (customized via “Round Number up/down measure unit” input)
- Yellow labels at end of each week: end of week OVERALL total results
- Red colored background: power segment
- 3 tables: 1) INFO | STATS, 2) SPY Options Calculator, 3) Indicator Settings

If you decide to fully customize the indicator yourself, on the very top - under “PRESETS” select “MANUAL”! NOTE: If you select any of the pre-set presets, only GLOBAL settings can be changed, the rest of the settings will be “frozen” until you switch it to “MANUAL”!
- Global Settings are self-explanatory and mainly observational, show/hide, etc.
- Manual TP2 (Multi-Take-Profit) Settings:
>>>>> Include TP2 System? Turn on/off multi-profit system, with this unchecked, every trade will either end with SL or with TP1.
>>>>> TP2 System: NEAREST/FORMULA, NEAREST – after TP1 is taken > next TP2 will be a round number price target nearest to where TP1 was taken (sometimes it can be very near, sometimes further away…), FORMULA – 2nd round number price target will be optimally selected based on the distance behind and ahead of TP1 area. For TP2 – FORMULA would be the most logical choice as with multi-take-profit setting turned on – you’d want to ride it out as far as possible.
>>>>> TP1/TP2 division type: 1) Each price target (TP1, TP2) will be ½ of the position 2) TP1 will be 2/3 of the position and TP2 will be the remaining 1/3.
>>>>> TP2 hit type: “close” > candle has to close on top/crossing the price target line, “touch” > once candle touches the price target – you will be immediately alerted to take the partial profit (if you will use such setting – you will need to take the partial profits as soon as you receive the alert.
>>>>> TP1 > Back to Entry hit type: similar to TP2, “close” > candle close, “touch” > candle touch. Please note: this is a very tricky setting as if you use “close” option – your profitable trade may become a loss if a huge candle will close against your position eliminating your TP1 profit, however often the price will touch and cross the entry area to only bounce and continue with your position direction for even bigger profits… so experiment with the date range results to see what works best for your instrument/setting/strategy.
>>>>> TP2 count towards trades count: this can be a bit confusing, but it is simply how should TP2 be treated towards trades count. The indicator will show you Win Percentage and Win % is obtained from winning trades count divided by total trades count. While TP2 is not “a new trade”, it expands the profit of the trade. This is an experimental setting to count TP2 as the whole winning trade, ½ of a trade, or not count it at all.

- Manual Signals/TP1 Settings:
>>>>> TP1/TP2 offset: this one is really cool, with this feature you can hunt these conditions when the price comes very near the profit target area, but never touches it. With this setting turned on and with a good offset amount – you will be able to catch these for TP1 and TP2!
>>>>> TP1/TP2 offset amount: just what the title says, please be careful with this as this number varies significantly depending on the instrument you will be trading. Examples: 1) For SPY 0.1 would be $0.10 offset - if TP1 is $400 and price hits $399.90 > TP1 considered taken/signal shown/alert) | 2) For EURUSD, it is very different and if wrong will show TP1 immediately at position open, typical good offset for EURUSD is: 0.0005 | 3) For BTCUSD, 10 - $10 offset, if TP is $15,000 > $14,990, etc.
>>>>> Round Number up/down measure unit (in dollars $): this one is very important if you will be using “MANUAL” selection to build your own setup as it is very different for every instrument. For SPY, round numbers are single dollars or even half-dollar 50 cent numbers: 1 or 0.5 (350, 351, 352, etc. or 350.50, 351, 351.50, 352, etc.), while for Bitcoin (BTCUSD) a single unit ($1) is too small to be a round number as Bitoin moves much faster and wider every second and it would have to be at least 50 ($50) to make sense. Similar for FOREX (EUR/USD) a single 1 unit ($1) will be too big as EURUSD will never move a whole $1 in 15 minutes or even a day.. and would have to be something like 1.05500. You can easily determine if this number makes sense for your instrument by observing the grey Round Number lines which will correspond based on this setting. You can also visually observer if the price of the instrument appreciates these round numbers.
>>>>> Close Position Before Market Closes: just what the title says. Indicator will close the position 15 minutes before market closes (US session), update backtesting stats, alert you.
>>>>> Close Position Before Power Hour: 3PM – 4PM ET is the last hour of US trading session, where sudden move in any direction can happen with huge volatility, while sometimes nothing will happen at all… Many try to avoid it, so if you wish to avoid it as well - turn this on and it will alert you to close your positions 15 minutes before Power Hour starts, backtesting/stats will be adjusted accordingly.
>>>>> Skip OVERSIZED candles in signals: turn on this setting to skip signals, which happen to fall on big candles. This is basically a protection from huge volatility moves, which usually happen during financial news/events and if you are not a fan of these – you can set this option for indicator to not open anything based on the candle size.
>>>>> Color OVERSIZED candles: this will help you calibrate the size of the OVERSIZED candles if you decide to use this setting and overall visually see them.
>>>>> OVERSIZED candle size: OVERSIZED candle size must be input as it varies significantly. Please note: for each instrument – the size number is completely different, as for SPY: 2 would mean any candle bigger than $2 distance will be considered OVERSIZED, for Bitcoin it would have to be several hundred dollars, like 400-500. For FOREX, this would have to be a decimal, for EURUSD something like 0.0005. It’s best to experiment visually with this setting depending on the instrument you will be trading while setting up the size. To see a typical huge unusual candle – look up financial calendar for something like FOMC meeting, then measure the candle input it into this setting.
>>>>> OVERSIZED candle size calculation type: this is just more flexibility for your preference. If you wish to calculate the size of the candle based on the open/close – select “BODY”, if you wish to use high/low – select “STICKS (from tip to tip)”. Hard to say which one is better, so it is up to you to decide.
>>>>> Include EMA in signal formula: LONG signals will only be shown only if above EMA, SHORT if below EMA. EMA length is of course customizable in below.
>>>>> Skip opposite candle types in signals: signals where the candle color confirms the direction of the trade, but the candle type is opposite (like a green colored bearish hammer for example) will be avoided (such candles can be very uncertain/deceptive).
>>>>> Skip doji: signals where the signal candle is doji (uncertain) will be avoided.
>>>>> TP1 hit type/system: same thing as TP2 hit type/system.
>>>>> SL hit type/system: same as TP1 and TP2 types/systems.
>>>>> Intraday Session Signals Active Time in ET: time range during the day when indicator will show signals (open trades, alert you, etc.). This is specifically for intraday trading. You can turn it off completely by selecting a BLANK option.
>>>>> Intraday TP/SL Active Time in ET: same as above, but for taking profits/stop losses.

*** To add the alerts
-Right-click anywhere on the TradingView chart
-Click on Add alert
-Condition: Select this indicator by it’s name
-Alert name: Whatever you want
-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!

If you wish to try this out for a week or so – please write me directly and I will give you access.
Release Notes:
- Fixed the end of week stats display on 1M and 3M timeframes so it does not display it a bunch of times
*** There seem to be an issue with TP1 > back to Entry / TP1 / TP2 labels/alerts not triggering and labels only display after refreshing the browser, troubleshooting to see what causes it
Release Notes:
* Repaired bunch inconsistencies inside functions for TP1/back to entry/SL
Release Notes:
* More bug fixes
Release Notes:
* Added barstate.isconfirmed check for each "close" setting as it seems like there is a big glitch of positions register hitting TP1, when it was not actually hit per script settings (it would be hit LIVE, while candle must CLOSE crossing TP1), there is also a support case with tradingview on this
Release Notes:
* Also confirmed "touch" functions, each with: "barstate.isrealtime == true"
Release Notes:
* barstate.isrealitime and barstate.islast > causing issues with LIVE TP1/SL > removed it
Release Notes:
* LIVE "touch" alerts are now working as well, there is still an issue where during LIVE "touch" TP1 or SL > it will show the label exactly when it happens, but then label disappears... the position gets closed by the script and alert is working, but for the labels to re-appear - you have to refresh tradingview.com or if you are using TradingVIew Desktop - switch to a different timeframe > then back. Working with tradingview.com support on this
Release Notes:
* Re-arranged the whole script, as "touch" settings had inconsistency issues, which are now resolved!
Release Notes:
* Another fix on multi-profit system to capture if "touch" settings is selected for everything and after TP1 > price comes back to Entry on that very same candle
Release Notes:
// NOTE: If all "touch" settings will be used and TP1-hit candle will be big enough to touch TP1 line and position open price at the same time:
// it will consider TP1 and TP1 > Back to Entry hit even though Back to Entry was never hit AFTER TP1 (position will be closed after TP1)
// unfortunately there is no way of tracking it that precise in pinescript
// this should not significantly throw off trading stats, but the profits statistics will be slightly less
Release Notes:
* Updated labels to look smaller and cleaner + now you can hover your mouse cursor over each trading action label to obtain additional info
Release Notes:
* Updated PRESETS
Release Notes:
* Fixed a minor bug
Release Notes:
* TP1 > Back to Entry "touch" label always displayed fixed
Release Notes:
* Full video guide for this indicator: www.youtube.com/watch?v=-almivvd...
Release Notes:
* NOTE: You may get a repaint warning when setting up the alerts!

Here is why: If you will use indicator with "touch" settings, when price is hitting your price target (TP1) or your stop-loss (SL) per "touch" setting (if selected) > the condition is true, it will show the label of TP1 and you will receive an alert, which is set to trigger "Once Per Bar". If on that same candle bar, the price goes backwards and the condition for TP1 is no longer true > technically the label will disappear, making the TP1 condition no longer true, which basically is repainting, however - per indicator rules > you are considered to have taken the TP1 already, so while technically it does repaint > in reality it does not affect your trading results or the indicator stats!
Release Notes:
* Added risk/reward ration to the stats table
Release Notes:
* Added tooltips to labels to show where exactly position was opened, TP/SL/EOD hit. Also moved end of day label showing total 1 hour later as otherwise if would not account for EOD closed position if such happens, calculations were still correct, but could be confusing
Release Notes:
* Added TP1 and TP2 multiplier settings for more flexibility + organize stats table a little better
Release Notes:
* Fixed an issue with "touch" TP and SL not showing on chart until refreshed, this is a TV engine issue, but should be fixed now with counters updated only with barstate.isconfirmed
* Fixed an issue with end of day label total results showing multiple times on 5M timeframe
Release Notes:
* Removed debug additional alerts (those were only used for debugging)
* Cleaned up labels, so they show minimum > cleaner chart, also with label tips (hover mouse over labels for additional info) there is no need for so much inside the actual labels
Release Notes:
* FOREX will now show PIPS for total amount results and high/low peaks
Release Notes:
* Fixed a minor issue with candle order counters
Release Notes:
* added barstate.isconfirmed additional checks where neccessarry
Release Notes:
* Fixed table issue where it would not always show current status when TP1 was taken
Release Notes:
* Added an input setting for TP1/TP2 display, now you can use either StepLine or Circles, NOTE: found out from testing that when using backtesting since like today or yesterday - it may not show you TP1/TP2 lines (TV glitch), but should always show with Circles!
Release Notes:
* Minor multi-profit calculations fix
Release Notes:
* Slightly adjusted position open replacing ta.crossover/under to close >/< | more trades and significantly better backtesting results!
Release Notes:
* Minor fix
Release Notes:
* Seems like TradingView pushed some sort of an update, which broke date format display, which in turn started failing the whole indicator/script... fixed it

Trading like a machine!
Invite-only script

Access to this script is restricted to users authorized by the author and usually requires payment. You can add it to your favorites, but you will only be able to use it after requesting permission and obtaining it from its author. Contact tso_trade for more information, or follow the author's instructions below.

TradingView does not suggest paying for a script and using it unless you 100% trust its author and understand how the script works. In many cases you can find a good open-source alternative for free in our Community Scripts.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Author's instructions

Full video guide for this indicator: www.youtube.com/watch?v=-almivvd...

Want to use this script on a chart?

Warning: please read before requesting access.