OPEN-SOURCE SCRIPT

Swing Boxes

Hey, folks!
Sorry for not posting anything for such a long time. Don't have enough ideas and resources to get inspiration, so trying to brainstorm good stuff in my free time from university studies.

But despite my absence more I now have 300+ people subscribed to me! Thanks, guys, for keeping interest for my work, as I still do value each boost on my script, for real :)
So here is new script , enjoy!


Swing Boxes is pretty simple indicator, which plots signals with "boxes", that help you determine price targets.


What is the idea behind?
I wanted to make indicator, that could help me make swing trades with nice accuracy (as all we want, lol), and for signal criteria I decided to use highs and lows of the price. Then I started coding some ideas to see which of them could be worthy. And, actually, Swing Boxes appeared to be good. But the thing is, that I didn't intend to build them, they appeared as an anomaly from my code :)
I started to explore this anomaly (it looked super cool, but was repainting hard) to fix it and I succeeded, now Swng Boxes don't repaint.

The main idea is that when price goes above it's highest value of p-bars back or below it's lowest value p-bars back, then there is a some god probability, that price will continue to follow current direction.

And the things about Swing Boxes is that when there is a good trend movement, the boxes become super small to track price movement and when price breaks out in the counter-trend direction, then you will be able to almost perfectly catch a top or a bottom! But most of the signals won't be so high-quality, so don't think that is this some holy grail to trade swing-trading, because it is not.


Signal logic

Quick hint:
- epsilon(variable e) = ATR * ATR_Factor. It is used to determine box's sensitivity to price changes.
  • If previous close is higher than variable, which contains previous HIGHEST value (variable h in the code), then update the this variable by taking up-to-date highest value and add epsilon(e) to it;
  • If previous close is lower than variable, which contains previous LOWEST value (variable l in the code), then update the this variable by taking up-to-date lowest value and substract epsilon(e) from it.

Variables decribed above (h and l) are box's top and bottom respectively, so if price cross them, it is logical to update it is value.


Settings and what is what
  • Swing Box Period - numbers fo bars in the past to find highest and lowest price from. The bigger the input, the bigger the boxes will be;
  • ATR Period;
  • ATR Factor - multiplier for ATR, determines sensitivity for price changes. The bigger this input, the more accurate signals will be, but less the probability that the signal will be on the top or a bottom.
  • Show Boxes? - when chosen, plots box's top and bottom. Used to determine price targets.
  • Show Baseline? - when chosen, plot's baseline, which midline between box's top and bottom.


How to use?
This indicator plots green and red triangles by default.
- Green triangle --> Buy;
- Red triangle --> Sell;

As I've said before, many signals from indicator will probably be garbage, so you need to tune settings for youself, so it could satisfy you.

You can enable showing boxes to see box's top and bottom. Box's bottom --> your entry, top --> your profit target.
If you find a way to sort bad signals, you will be able to trade with super cool RR, because the signal from Swing Boxes appear to be a good one, there is almost 95% probability, that price will not even come close to your stop loss, so you can trade with super small stop-losses! Smaller stop-loss --> smaller risk --> smaller loss --> bigger profit, it is that easy.

Also you can enable baseline to use at as your 1st TP, and box's top/bottom as 2nd TP, closing 25% on TP1 and the rest on TP2 (but that is just mine recommendation, you can use different RM (risk-management), if you want).
Also you can use baseline as your S/R (Support/Resistance) line, test it out on your charts.

And please, hear me out: as all other indicators out here on the TradingView, Swing Boxes ARE NOT meant to be traded in solo! Many bad signal can go in a row, so PLEASE find your way to filter out bad signals with other indicators.

You can see here the example of a garabge-class signal in a row, so be don't be deluded!
https://www.tradingview.com/x/cb6mHfjz/

I do hope that somebody will suggest and idea to improve this thing, as I personally don't have enough time to think about it because of my university studies, but I will probably try it make this thing better throughout the time.


And that's it for now, folks! If you have any ideas for scripts, strategies or anything else, feel free to DM me or leave a comment, I will check it.

Hope you will find this script useful.
Take your profits!
- Tarasenko Fyodor
bottomboxesconceptlevelsoptionsPivot points and levelssignalssupportswingtarasenkoTOP

Skrip sumber terbuka

Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai sumber terbuka supaya pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara percuma, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Ingin menggunakan skrip ini pada carta?


Juga pada:

Penafian