frama gradien (3-05 ) dan (15-1,5) sesuaikan dengan IMACD 5 menit 15

 // This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International  

// https://creativecommons.org/licenses/by-nc-sa/4.0/
// © BigBeluga
// Modified: 5 Lines + Outer Bands narrowed by ~50% + 10 Vertical Dots + Split Colors + White Outer Zones.

//@version=5
indicator("FRAMA Channel [Narrowed Outer Bands]", overlay=true, max_labels_count = 500)

// INPUTS --------------------------------------------------------------------------------------------------------{
int    N         = input.int   (26, title="Length", minval=2, step = 2, group = "Channel")
float  distance  = input.float (1.5, "Bands Distance", step = 0.01, minval = 0.3, group = "Channel")
string price_vol  = input.string("Price", "Signals Data", ["Price", "Average Volume"])
string labl_size  = input.string("Small", "Lables Size", ["Small", "Normal", "Large"])

// Custom Offset Coordinates Inputs
string grp_offset = "Coordinate Offsets"
float  vert_offset = input.float(0.0, "Vertical Offset (Price)", step=0.1, group=grp_offset, tooltip="Geser posisi bulatan ke atas (+) atau ke bawah (-)")
int    horiz_offset = input.int(0, "Horizontal Offset (Bars)", minval=-50, maxval=50, group=grp_offset, tooltip="Geser posisi bulatan ke kiri (-) atau ke kanan (+)")

// Colors
group = "Colors"
color color_up   = input.color(#27e27b, "Above Midline (Green)", group = group, inline = "1")
color color_dn   = input.color(color.rgb(255, 50, 50), "Below Midline (Red)", group = group, inline = "1")
color color_ext  = input.color(color.white, "Outer Bands Zone (White)", group = group)
color color3     = input.color(#a2b5ca, "Neutral", group = group)
var color current_color = color(na)

// Source for FRAMA calculation
series float price = hl2

// Variables for FRAMA calculation
var float Filt   = na
var float Filt1  = na
var float Filt2  = na
var float Filt3  = na
var float Filt4  = na
var int   count1 = na
var int   count2 = na
// }

// UDTs----------------------------------------------------------------------------------------------------------------{
type vars
    float N1
    float N2
    float N3
    float HH
    float LL
    float Dimen
    float alpha

v = vars.new(0., 0., 0., 0., 0., 0., 0.)
// }

// CALCULATIONS----------------------------------------------------------------------------------------------{
series float volatility = ta.sma(high - low, 200)
series float p_vol      = switch price_vol
    "Price"             => close
    "Average Volume"    => math.round(math.sum(volume, 10) / 10, 2)

v.N3 := (ta.highest(high, N) - ta.lowest(low, N)) / N

v.HH := high
v.LL := low
for count = 0 to N / 2 - 1
    if high[count] > v.HH
        v.HH := high[count]
    if low[count] < v.LL
        v.LL := low[count]
v.N1 := (v.HH - v.LL) / (N / 2)

v.HH := high[N / 2]
v.LL := low[N / 2]
for count = N / 2 to N - 1
    if high[count] > v.HH
        v.HH := high[count]
    if low[count] < v.LL
        v.LL := low[count]
v.N2 := (v.HH - v.LL) / (N / 2)

if (v.N1 > 0 and v.N2 > 0 and v.N3 > 0)
    v.Dimen := (math.log(v.N1 + v.N2) - math.log(v.N3)) / math.log(2)

v.alpha := math.exp(-4.6 * (v.Dimen - 1))
v.alpha := math.max(math.min(v.alpha, 1), 0.01)

Filt  := na(Filt) ? price : v.alpha * price + (1 - v.alpha) * Filt[1]
Filt  := ta.sma((bar_index < N + 1) ? price : Filt, 5)

// Menghitung 4 Channel Bands (Garis terluar dipersempit 50% dengan pengali 1.5)
Filt1 := Filt + volatility * distance
Filt2 := Filt - volatility * distance
Filt3 := Filt + volatility * (distance * 1.5) // Dipersempit dari *2 menjadi *1.5
Filt4 := Filt - volatility * (distance * 1.5) // Dipersempit dari *2 menjadi *1.5
// }

// PLOT & NARROWED OUTER BANDS LOGIC--------------------------------------------------------------------------------{
break_up = ta.crossover(hlc3, Filt1) and barstate.isconfirmed
break_dn = ta.crossunder(hlc3, Filt2) and barstate.isconfirmed

// Plot 5 Channels
p0 = plot(Filt,  color = color.new(color_up, 50), editable = false, title = "Midline")
p1 = plot(Filt1, color = color.new(color_up, 20), linewidth = 1, editable = false, title = "Upper Band 1")
p2 = plot(Filt2, color = color.new(color_dn, 20), linewidth = 1, editable = false, title = "Lower Band 1")
p3 = plot(Filt3, color = color.new(color_ext, 40), linewidth = 1, editable = false, title = "Upper Band 2 (Outer)")
p4 = plot(Filt4, color = color.new(color_ext, 40), linewidth = 1, editable = false, title = "Lower Band 2 (Outer)")

// Fill Area antar Channel
fill(p3, p1, Filt3, Filt1, color.new(color_ext, 95), na, editable = false)
fill(p1, p0, Filt1, Filt, color.new(color_up, 95), na, editable = false)
fill(p0, p2, Filt, Filt2, na, color.new(color_dn, 95), na, editable = false)
fill(p2, p4, Filt2, Filt4, color.new(color_ext, 95), na, editable = false)

// Membagi rentang High - Low menjadi 10 bagian + ditambahkan Vertical Offset
float candle_range = high - low
float step_size = candle_range > 0 ? candle_range / 9.0 : 0.0

// Menghitung harga masing-masing titik dengan tambahan offset vertikal
float price_dot0 = low + (step_size * 0) + vert_offset
float price_dot1 = low + (step_size * 1) + vert_offset
float price_dot2 = low + (step_size * 2) + vert_offset
float price_dot3 = low + (step_size * 3) + vert_offset
float price_dot4 = low + (step_size * 4) + vert_offset
float price_dot5 = low + (step_size * 5) + vert_offset
float price_dot6 = low + (step_size * 6) + vert_offset
float price_dot7 = low + (step_size * 7) + vert_offset
float price_dot8 = low + (step_size * 8) + vert_offset
float price_dot9 = low + (step_size * 9) + vert_offset

// Logika Penentuan Warna:
// - Putih jika berada di antara Garis 1 & 2 (Filt1 s.d Filt3) atau antara Garis 4 & 5 (Filt4 s.d Filt2)
// - Hijau/Merah jika berada di area tengah berdasarkan posisi terhadap garis tengah (Filt)
color_func(float p) =>
    bool is_top_outer_zone = (p >= Filt1 and p <= Filt3)
    bool is_bot_outer_zone = (p >= Filt4 and p <= Filt2)
   
    if is_top_outer_zone or is_bot_outer_zone
        color_ext
    else
        p >= Filt ? color_up : color_dn

color col_dot0 = color_func(price_dot0)
color col_dot1 = color_func(price_dot1)
color col_dot2 = color_func(price_dot2)
color col_dot3 = color_func(price_dot3)
color col_dot4 = color_func(price_dot4)
color col_dot5 = color_func(price_dot5)
color col_dot6 = color_func(price_dot6)
color col_dot7 = color_func(price_dot7)
color col_dot8 = color_func(price_dot8)
color col_dot9 = color_func(price_dot9)

// Render 10 Bulatan dengan dukungan Horizontal Offset
plotchar(price_dot0[horiz_offset], title="Dot 1",  char="•", location=location.absolute, color=col_dot0, size=size.small, editable=false)
plotchar(price_dot1[horiz_offset], title="Dot 2",  char="•", location=location.absolute, color=col_dot1, size=size.small, editable=false)
plotchar(price_dot2[horiz_offset], title="Dot 3",  char="•", location=location.absolute, color=col_dot2, size=size.small, editable=false)
plotchar(price_dot3[horiz_offset], title="Dot 4",  char="•", location=location.absolute, color=col_dot3, size=size.small, editable=false)
plotchar(price_dot4[horiz_offset], title="Dot 5",  char="•", location=location.absolute, color=col_dot4, size=size.small, editable=false)
plotchar(price_dot5[horiz_offset], title="Dot 6",  char="•", location=location.absolute, color=col_dot5, size=size.small, editable=false)
plotchar(price_dot6[horiz_offset], title="Dot 7",  char="•", location=location.absolute, color=col_dot6, size=size.small, editable=false)
plotchar(price_dot7[horiz_offset], title="Dot 8",  char="•", location=location.absolute, color=col_dot7, size=size.small, editable=false)
plotchar(price_dot8[horiz_offset], title="Dot 9",  char="•", location=location.absolute, color=col_dot8, size=size.small, editable=false)
plotchar(price_dot9[horiz_offset], title="Dot 10", char="•", location=location.absolute, color=col_dot9, size=size.small, editable=false)

size_label = switch labl_size
    "Small"  => size.small
    "Normal" => size.normal
    "Large"  => size.large

if break_up
    count2 := 0
    count1 += 1
    if count1 == 1
        label.new(x = bar_index, y = Filt2, text = "🢁\n" + str.tostring(p_vol), style = label.style_label_up, textcolor = color_up, color = color(na), size = size_label)

if break_dn
    count1 := 0
    count2 += 1
    if count2 == 1
        label.new(x = bar_index, y = Filt1, text = str.tostring(p_vol) + "\n🢃", style = label.style_label_down, textcolor = color_dn, color = color(na), size = size_label)
// }

Komentar

Postingan populer dari blog ini

Script

Kode taufik (2)