216 views
17
test version, use at your own risk as the study code is very ineficient
Remove from Favorite Scripts Add to Favorite Scripts
study(title="exp", shorttitle="exp", overlay=true)

length00 = input(24)
src = sma(ohlc4, length00)

lo = lowest(low, length00)
hi = highest(high, length00)
//	||---------------------------------------------------------------------------------------------------||
//  ||---   Absolute High and Low	---------------------------------------------------------------------||
hhi = hi > hhi[1] ? hi : nz(hhi[1])
llo = 0 //lo < llo[1] ? lo : nz(llo[1] == 0 ? lo/2 : llo[1])

//	||---------------------------------------------------------------------------------------------------||
//  ||---   split sections based on time frame   --------------------------------------------------------||
//  ||---   Function to calculate section:
csection(base, perv, multi) => base + (perv * multi)
//	||---------------------------------------------------------------------------------------------------||
//  ||---   Function to draw only straight lines    -----------------------------------------------------||
cl(l1, l2, col) => l1 == l2 ? col : na

//	||---------------------------------------------------------------------------------------------------||
//  ||---   Section Percentual value:   -----------------------------------------------------------------||
//  ||---   Monthly, weekly, dayly...   -----------------------------------------------------------------||
m_perv = (hhi - llo) * 0.01
w_perv = m_perv * 0.1
d_perv = w_perv * 0.1

//	||---------------------------------------------------------------------------------------------------||
//  ||---   Monthly section lines:  ---------------------------------------------------------------------||

secm00 = llo
secm01 = csection(llo, m_perv, 10)
secm02 = csection(llo, m_perv, 20)
secm03 = csection(llo, m_perv, 30)
secm04 = csection(llo, m_perv, 40)
secm05 = csection(llo, m_perv, 50)
secm06 = csection(llo, m_perv, 60)
secm07 = csection(llo, m_perv, 70)
secm08 = csection(llo, m_perv, 80)
secm09 = csection(llo, m_perv, 90)
secm10 = hhi

mp00 = src >= secm00 and src <= secm01 ? secm00 : nz(mp00[1])
mp01 = src >= secm01 and src <= secm02 ? secm01 : nz(mp01[1])
mp02 = src >= secm02 and src <= secm03 ? secm02 : nz(mp02[1])
mp03 = src >= secm03 and src <= secm04 ? secm03 : nz(mp03[1])
mp04 = src >= secm04 and src <= secm05 ? secm04 : nz(mp04[1])
mp05 = src >= secm05 and src <= secm06 ? secm05 : nz(mp05[1])
mp06 = src >= secm06 and src <= secm07 ? secm06 : nz(mp06[1])
mp07 = src >= secm07 and src <= secm08 ? secm07 : nz(mp07[1])
mp08 = src >= secm08 and src <= secm09 ? secm08 : nz(mp08[1])
mp09 = src >= secm09 and src <= secm10 ? secm09 : nz(mp09[1])
mp10 = src >= secm09 and src <= secm10 ? secm10 : nz(mp10[1])

//	||---------------------------------------------------------------------------------------------------||
//  ||---   Weekly section lines:   ---------------------------------------------------------------------||
secw00 = src >= secm00 and src <= secm01 ? secm00 :
        src >= secm01 and src <= secm02 ? secm01 :
        src >= secm02 and src <= secm03 ? secm02 :
        src >= secm03 and src <= secm04 ? secm03 :
        src >= secm04 and src <= secm05 ? secm04 :
        src >= secm05 and src <= secm06 ? secm05 :
        src >= secm06 and src <= secm07 ? secm06 :
        src >= secm07 and src <= secm08 ? secm07 :
        src >= secm08 and src <= secm09 ? secm08 :
        src >= secm09 and src <= secm10 ? secm09 : secm00
        
secw10 = src >= secm00 and src <= secm01 ? secm01 :
        src >= secm01 and src <= secm02 ? secm02 :
        src >= secm02 and src <= secm03 ? secm03 :
        src >= secm03 and src <= secm04 ? secm04 :
        src >= secm04 and src <= secm05 ? secm05 :
        src >= secm05 and src <= secm06 ? secm06 :
        src >= secm06 and src <= secm07 ? secm07 :
        src >= secm07 and src <= secm08 ? secm08 :
        src >= secm08 and src <= secm09 ? secm09 :
        src >= secm09 and src <= secm10 ? secm10 : secm10

secw01 = csection(secw00, w_perv, 10)
secw02 = csection(secw00, w_perv, 20)
secw03 = csection(secw00, w_perv, 30)
secw04 = csection(secw00, w_perv, 40)
secw05 = csection(secw00, w_perv, 50)
secw06 = csection(secw00, w_perv, 60)
secw07 = csection(secw00, w_perv, 70)
secw08 = csection(secw00, w_perv, 80)
secw09 = csection(secw00, w_perv, 90)

wp00 = src >= secw00 and src <= secw01 ? secw00 : nz(wp00[1])
wp01 = src >= secw01 and src <= secw02 ? secw01 : nz(wp01[1])
wp02 = src >= secw02 and src <= secw03 ? secw02 : nz(wp02[1])
wp03 = src >= secw03 and src <= secw04 ? secw03 : nz(wp03[1])
wp04 = src >= secw04 and src <= secw05 ? secw04 : nz(wp04[1])
wp05 = src >= secw05 and src <= secw06 ? secw05 : nz(wp05[1])
wp06 = src >= secw06 and src <= secw07 ? secw06 : nz(wp06[1])
wp07 = src >= secw07 and src <= secw08 ? secw07 : nz(wp07[1])
wp08 = src >= secw08 and src <= secw09 ? secw08 : nz(wp08[1])
wp09 = src >= secw09 and src <= secw10 ? secw09 : nz(wp09[1])
wp10 = src >= secw09 and src <= secw10 ? secw10 : nz(wp10[1])

//	||---------------------------------------------------------------------------------------------------||
//  ||---   Dayly section lines:    ---------------------------------------------------------------------||
secd00 = src >= secw00 and src <= secw01 ? secw00 :
        src >= secw01 and src <= secw02 ? secw01 :
        src >= secw02 and src <= secw03 ? secw02 :
        src >= secw03 and src <= secw04 ? secw03 :
        src >= secw04 and src <= secw05 ? secw04 :
        src >= secw05 and src <= secw06 ? secw05 :
        src >= secw06 and src <= secw07 ? secw06 :
        src >= secw07 and src <= secw08 ? secw07 :
        src >= secw08 and src <= secw09 ? secw08 :
        src >= secw09 and src <= secw10 ? secw09 : secw00
        
secd10 = src >= secw00 and src <= secw01 ? secw01 :
        src >= secw01 and src <= secw02 ? secw02 :
        src >= secw02 and src <= secw03 ? secw03 :
        src >= secw03 and src <= secw04 ? secw04 :
        src >= secw04 and src <= secw05 ? secw05 :
        src >= secw05 and src <= secw06 ? secw06 :
        src >= secw06 and src <= secw07 ? secw07 :
        src >= secw07 and src <= secw08 ? secw08 :
        src >= secw08 and src <= secw09 ? secw09 :
        src >= secw09 and src <= secw10 ? secw10 : secw10

secd01 = csection(secd00, d_perv, 10)
secd02 = csection(secd00, d_perv, 20)
secd03 = csection(secd00, d_perv, 30)
secd04 = csection(secd00, d_perv, 40)
secd05 = csection(secd00, d_perv, 50)
secd06 = csection(secd00, d_perv, 60)
secd07 = csection(secd00, d_perv, 70)
secd08 = csection(secd00, d_perv, 80)
secd09 = csection(secd00, d_perv, 90)

dp00 = src >= secd00 and src <= secd01 ? secd00 : nz(dp00[1])
dp01 = src >= secd01 and src <= secd02 ? secd01 : nz(dp01[1])
dp02 = src >= secd02 and src <= secd03 ? secd02 : nz(dp02[1])
dp03 = src >= secd03 and src <= secd04 ? secd03 : nz(dp03[1])
dp04 = src >= secd04 and src <= secd05 ? secd04 : nz(dp04[1])
dp05 = src >= secd05 and src <= secd06 ? secd05 : nz(dp05[1])
dp06 = src >= secd06 and src <= secd07 ? secd06 : nz(dp06[1])
dp07 = src >= secd07 and src <= secd08 ? secd07 : nz(dp07[1])
dp08 = src >= secd08 and src <= secd09 ? secd08 : nz(dp08[1])
dp09 = src >= secd09 and src <= secd10 ? secd09 : nz(dp09[1])
dp10 = src >= secd09 and src <= secd10 ? secd10 : nz(dp10[1])

//	||---------------------------------------------------------------------------------------------------||
//  ||---   Select Lines based on time frame:   ---------------------------------------------------------||
l00 =   period == "M" ? mp00 :
		period == "W" ? wp00 :
		period == "D" ? dp00 : dp00
l01 =   period == "M" ? mp01 :
		period == "W" ? wp01 :
		period == "D" ? dp01 : dp01
l02 =   period == "M" ? mp02 :
		period == "W" ? wp02 :
		period == "D" ? dp02 : dp02
l03 =   period == "M" ? mp03 :
		period == "W" ? wp03 :
		period == "D" ? dp03 : dp03
l04 =   period == "M" ? mp04 :
		period == "W" ? wp04 :
		period == "D" ? dp04 : dp04
l05 =   period == "M" ? mp05 :
		period == "W" ? wp05 :
		period == "D" ? dp05 : dp05
l06 =   period == "M" ? mp06 :
		period == "W" ? wp06 :
		period == "D" ? dp06 : dp06
l07 =   period == "M" ? mp07 :
		period == "W" ? wp07 :
		period == "D" ? dp07 : dp07
l08 =   period == "M" ? mp08 :
		period == "W" ? wp08 :
		period == "D" ? dp08 : dp08
l09 =   period == "M" ? mp09 :
		period == "W" ? wp09 :
		period == "D" ? dp09 : dp09
l10 =   period == "M" ? mp10 :
		period == "W" ? wp10 :
		period == "D" ? dp10 : dp10

//	||---------------------------------------------------------------------------------------------------||
//	||---	Output:		---------------------------------------------------------------------------------||
plot(l00, color=cl(l00, l00[1], black), linewidth=2)
plot(l01, color=cl(l01, l01[1], black), linewidth=1)
plot(l02, color=cl(l02, l02[1], black), linewidth=1)
plot(l03, color=cl(l03, l03[1], black), linewidth=1)
plot(l04, color=cl(l04, l04[1], black), linewidth=1)
plot(l05, color=cl(l05, l05[1], black), linewidth=1)
plot(l06, color=cl(l06, l06[1], black), linewidth=1)
plot(l07, color=cl(l07, l07[1], black), linewidth=1)
plot(l08, color=cl(l08, l08[1], black), linewidth=1)
plot(l09, color=cl(l09, l09[1], black), linewidth=1)
plot(l10, color=cl(l10, l10[1], black), linewidth=2)


Comments

Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out