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).
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?
//@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)