RicardoSantos

[RS]Shifted Pivots V1

update: added weekly and monthly pivots, the offset is a average approximation so there may be inconsistency on the date forecasted to be end of week/month.
(using diferent sessions or limited time intervals is not possible).
Skript med en öppen källkod

I sann TradingView-anda har författaren publicerat detta skript med öppen källkod så att andra handlare kan förstå och verifiera det. Hatten av för författaren! Du kan använda det gratis men återanvändning av den här koden i en publikation regleras av våra ordningsregler. Du kan ange den som favorit för att använda den i ett diagram.

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här skriptet i ett diagram?
//@version=2
study(title='[RS]Shifted Pivots V1', shorttitle='SP', overlay=true)
//  ||-----------------------------------------------------------------------------------------------------------------------------||
//  ||  Inputs:
DISPLAY_D = input(title='Show Dayly Pivot Lines?', type=bool, defval=true)
DISPLAY_W = input(title='Show Weekly Pivot Lines?', type=bool, defval=true)
DISPLAY_M = input(title='Show Monthly Pivot Lines?', type=bool, defval=true)

//  ||-----------------------------------------------------------------------------------------------------------------------------||
//  ||  Timeframe Offset:
d_shift = period == '1' ? 1440 :
         period == '3' ? 480 :
         period == '5' ? 288 :
         period == '15' ? 96 :
         period == '30' ? 48 :
         period == '45' ? 32 :
         period == '60' ? 24 :
         period == '120' ? 12 :
         period == '180' ? 8 :
         period == '240' ? 6 :
         period == '480' ? 3 :
         period == '720' ? 2 :
         0

w_shift = period == '1' ? 5 * 1440 :
         period == '3' ? 5 * 480 :
         period == '5' ? 5 * 288 :
         period == '15' ? 5 * 96 :
         period == '30' ? 5 * 48 :
         period == '45' ? 5 * 32 :
         period == '60' ? 5 * 24 :
         period == '120' ? 5 * 12 :
         period == '180' ? 5 * 8 :
         period == '240' ? 5 * 6 :
         period == '480' ? 5 * 3 :
         period == '720' ? 5 * 2 :
         0

m_shift = period == '1' ? 22 * 1440 :
         period == '3' ? 22 * 480 :
         period == '5' ? 22 * 288 :
         period == '15' ? 22 * 96 :
         period == '30' ? 22 * 48 :
         period == '45' ? 22 * 32 :
         period == '60' ? 22 * 24 :
         period == '120' ? 22 * 12 :
         period == '180' ? 22 * 8 :
         period == '240' ? 22 * 6 :
         period == '480' ? 22 * 3 :
         period == '720' ? 22 * 2 :
         0

//  ||-----------------------------------------------------------------------------------------------------------------------------||
//  ||  Request security data:
d_high  = not DISPLAY_D ? na : security(tickerid, 'D', high)
d_low   = not DISPLAY_D ? na : security(tickerid, 'D', low)
d_pivot = not DISPLAY_D ? na : security(tickerid, 'D', hlc3)
w_high  = not DISPLAY_W ? na : security(tickerid, 'W', high)
w_low   = not DISPLAY_W ? na : security(tickerid, 'W', low)
w_pivot = not DISPLAY_W ? na : security(tickerid, 'W', hlc3)
m_high  = not DISPLAY_M ? na : security(tickerid, 'M', high)
m_low   = not DISPLAY_M ? na : security(tickerid, 'M', low)
m_pivot = not DISPLAY_M ? na : security(tickerid, 'M', hlc3)
//  ||-----------------------------------------------------------------------------------------------------------------------------||
//  ||  Calculate pivots:
//  ||      SR1:
d_resistance1 = not DISPLAY_D ? na : (d_pivot * 2) - d_low
d_support1    = not DISPLAY_D ? na : (d_pivot * 2) - d_high
w_resistance1 = not DISPLAY_W ? na : (w_pivot * 2) - w_low
w_support1    = not DISPLAY_W ? na : (w_pivot * 2) - w_high
m_resistance1 = not DISPLAY_M ? na : (m_pivot * 2) - m_low
m_support1    = not DISPLAY_M ? na : (m_pivot * 2) - m_high
//  ||      SR2:
d_resistance2 = not DISPLAY_D ? na : (d_pivot - d_support1) + d_resistance1
d_support2    = not DISPLAY_D ? na : d_pivot - (d_resistance1 - d_support1)
w_resistance2 = not DISPLAY_W ? na : (w_pivot - w_support1) + w_resistance1
w_support2    = not DISPLAY_W ? na : w_pivot - (w_resistance1 - w_support1)
m_resistance2 = not DISPLAY_M ? na : (m_pivot - m_support1) + m_resistance1
m_support2    = not DISPLAY_M ? na : m_pivot - (m_resistance1 - m_support1)
//  ||      SR3:
d_resistance3 = not DISPLAY_D ? na : (d_pivot - d_support2) + d_resistance2
d_support3    = not DISPLAY_D ? na : d_pivot - (d_resistance2 - d_support2)
w_resistance3 = not DISPLAY_W ? na : (w_pivot - w_support2) + w_resistance2
w_support3    = not DISPLAY_W ? na : w_pivot - (w_resistance2 - w_support2)
m_resistance3 = not DISPLAY_M ? na : (m_pivot - m_support2) + m_resistance2
m_support3    = not DISPLAY_M ? na : m_pivot - (m_resistance2 - m_support2)
//  ||-----------------------------------------------------------------------------------------------------------------------------||
//  ||  Outputs:
//  ||      P:
plot(title='DP', series=d_pivot, color=change(d_pivot)!=0?na:black, linewidth=1, offset=d_shift)
plot(title='WP', series=w_pivot, color=change(w_pivot)!=0?na:black, linewidth=1, offset=w_shift)
plot(title='MP', series=m_pivot, color=change(m_pivot)!=0?na:black, linewidth=1, offset=m_shift)
//  ||      SR1:
plot(title='DR1', series=d_resistance1, color=change(d_resistance1)!=0?na:black, linewidth=1, offset=d_shift)
plot(title='DS1', series=d_support1   , color=change(d_support1)!=0?na:black   , linewidth=1, offset=d_shift)
plot(title='WR1', series=w_resistance1, color=change(w_resistance1)!=0?na:black, linewidth=1, offset=w_shift)
plot(title='WS1', series=w_support1   , color=change(w_support1)!=0?na:black   , linewidth=1, offset=w_shift)
plot(title='MR1', series=m_resistance1, color=change(m_resistance1)!=0?na:black, linewidth=1, offset=m_shift)
plot(title='MS1', series=m_support1   , color=change(m_support1)!=0?na:black   , linewidth=1, offset=m_shift)
//  ||      SR2:
plot(title='DR2', series=d_resistance2, color=change(d_resistance2)!=0?na:black, linewidth=1, offset=d_shift)
plot(title='DS2', series=d_support2   , color=change(d_support2)!=0?na:black   , linewidth=1, offset=d_shift)
plot(title='WR2', series=w_resistance2, color=change(w_resistance2)!=0?na:black, linewidth=1, offset=w_shift)
plot(title='WS2', series=w_support2   , color=change(w_support2)!=0?na:black   , linewidth=1, offset=w_shift)
plot(title='MR2', series=m_resistance2, color=change(m_resistance2)!=0?na:black, linewidth=1, offset=m_shift)
plot(title='MS2', series=m_support2   , color=change(m_support2)!=0?na:black   , linewidth=1, offset=m_shift)
//  ||      SR3:
plot(title='DR3', series=d_resistance3, color=change(d_resistance3)!=0?na:black, linewidth=1, offset=d_shift)
plot(title='DS3', series=d_support3   , color=change(d_support3)!=0?na:black   , linewidth=1, offset=d_shift)
plot(title='WR3', series=w_resistance3, color=change(w_resistance3)!=0?na:black, linewidth=1, offset=w_shift)
plot(title='WS3', series=w_support3   , color=change(w_support3)!=0?na:black   , linewidth=1, offset=w_shift)
plot(title='MR3', series=m_resistance3, color=change(m_resistance3)!=0?na:black, linewidth=1, offset=m_shift)
plot(title='MS3', series=m_support3   , color=change(m_support3)!=0?na:black   , linewidth=1, offset=m_shift)