TradingView
weak_hand
27 мар 2023 г., 09:42

Three-Day Rolling Pivot 

Bitcoin / TetherUSBinance

Описание

The three-day rolling pivot is another pivot concept,
which may be used by intermediate positions, for several days or even weeks.
It can be utilized in many ways, such as to determine an entry point or trailing stop.
As the name suggests, this pivot is based on the last three days.



I learned this concept of the book "The logical Trader" by Mark Fisher.
Kudos go to him!

My version of the Three-Day Rolling Pivot uses actual data!
And all similar scripts I have found so far calculate future data and don't take into account the original data.

I hope this script will help some people to do some better decisions.
And I am pleased to get some advice to make this script even better!


Future data vs original data

Pine Script v5 Reference Manual:
Merge strategy for the requested data position... This merge strategy can lead to undesirable effect of getting data from "future" on calculation on history. This is unacceptable in backtesting strategies, but can be useful in indicators.

e2e4 on Stack Overflow said:
Pine v1-v2's security() function is using the lookahead parameter by default, which could be modified in v3-v5...
stackoverflow.com/questions/71976952/previous-day-high-and-low-using-pine-script-v5

I haven't found a script which put this into account jet.

I leave this option available for people that wanna more speculated data. But it's disabled by default.




Long/Short Example

You can enter Long when the market cross over the upper line (default color is green) and you should put your trailing stop 1-5 ticks below the lower line (default color is red).
The opposite when Shorting, then the market has to cross down the lower line and your trailing stop should be 1-5 ticks above the upper line.


How does this script work:

First it fetches the highest high of ...
yesterday,
the day before yesterday,
and the day before that.
After that the script looks for the highest high of all three.

Next it does the same for previous lowest low.

Last but not least, it fetches the closing price of the last day.

After that it adds all three prices together and divide them by three.
This result in a three day pivot price.

Then it adds the highest high and lowest low of the three last days and divide it by two.
This gives us the second number we need to calculate the differential.

The differential is the gap between the three day pivot price and the second number.
Sometimes the second number is bigger than the three day pivot price so I took that into account too. Other wise the colors plotted would be on the wrong site.

Finally, the script is rounding the numbers to the nearest minimum tick of that security.

Информация о релизе


This was one of my first scripts.
And after I learned many new things I had to do a revisited version.

What has changed ?

The goal of the script hasn't changed, except future calculation/speculation.
The big change is that is was activated by default, and now it isn't.
The option is still there but I changed its name and it is deactivated by default.
Before this my assumption was backward, and I am sorry for that.

Now lines are automaticly drawn from start to end of a daily session.
Therefor I had to put its options into Settings --> Inputs.
Before that it was all under Settings --> Styles and there were two lines you could change only.
Now you can deactivate things like labels on price scale, lines, Linefills (background) under Settings ---> Style,
without interfering on each other.

I also added a simple alarm.
Here you can read how to set up your alert with this script.
The alert will trigger when close crossunder the upper-line and close crossover the lower-line.

If you find any errors please leave a comment.

Happy trading!

Информация о релизе

Changed minor error ony background color.

Информация о релизе

bigbang74 requested an option to change the three day rolling pivot into a three week / month rolling pivot.
You still cant see daily calculations on daily weekly and monthly chart, but now you can see the weekly and monthly calculations on it.

Happy trading!

Информация о релизе

Now it is also possible to change the three day/week/month rolling pivot into a four, five, or six, day/week/month rolling pivot.
Комментарии
mariopetrov1990
This indicator is something from another world. It's almost a cheat. Im using it along Camarilla pivots, weekly/monthly fibs and other tools. You've done an outstanding job for us traders that use static levels and leading indicators. Such a beatiful work you've done here. A milion thanks!
weak_hand
@mariopetrov1990, tyvm, your welcome
bigbang74
hello, is it possible to add a button that shows future periods like other pivot indicators?
bigbang74
Thanks for your efforts :)
weak_hand
@bigbang74, you are welcome
bigbang74
Hi, is it possible to add a selectable timeframe option ? Thanks
weak_hand
@bigbang74, you mean instead of the length of one session, or instead of three days you mean four, five, six, and so on ?
bigbang74
@weak_hand, i mean week, month, quarter, year. I have added TF = input.timeframe(title='Timeframe', defval='D') code and change "D" parametre with TF so i was able to change it to weekly, monthly etc... I don't know much about pinescript. It was a little hard for me to change in this version. It will be also a good option as you stated to change it 3-4-5-6 days etc
weak_hand
@bigbang74, this would result in a new program.
I could change the three day rolling pivot into a six day rolling pivot, for example.
But its still for intraday candles only.

When changing the timeframe for historical data it would calculate on weeks or month of data instead.
In this case I would prefer and recommend pivot points or pivot moving averages.
Ещё