OPEN-SOURCE SCRIPT

MA8 vs MA55 Multi-TF Crossing Info (dengan Alert Text)

39
//version=5
indicator("MA8 vs MA55 Multi-TF Crossing Info (dengan Alert Text)", overlay=true, max_labels_count=500)

// --- Sumber harga MA ---
src = close

// --- Hitung per TF ---
ma8_1 = request.security(syminfo.tickerid, "1", ta.sma(src, 8))
ma55_1 = request.security(syminfo.tickerid, "1", ta.sma(src, 55))
bull_1 = ta.crossover(ma8_1, ma55_1)
bear_1 = ta.crossunder(ma8_1, ma55_1)
isBuy_1 = ma8_1 > ma55_1

ma8_5 = request.security(syminfo.tickerid, "5", ta.sma(src, 8))
ma55_5 = request.security(syminfo.tickerid, "5", ta.sma(src, 55))
bull_5 = ta.crossover(ma8_5, ma55_5)
bear_5 = ta.crossunder(ma8_5, ma55_5)
isBuy_5 = ma8_5 > ma55_5

ma8_15 = request.security(syminfo.tickerid, "15", ta.sma(src, 8))
ma55_15 = request.security(syminfo.tickerid, "15", ta.sma(src, 55))
bull_15 = ta.crossover(ma8_15, ma55_15)
bear_15 = ta.crossunder(ma8_15, ma55_15)
isBuy_15 = ma8_15 > ma55_15

ma8_60 = request.security(syminfo.tickerid, "60", ta.sma(src, 8))
ma55_60 = request.security(syminfo.tickerid, "60", ta.sma(src, 55))
bull_60 = ta.crossover(ma8_60, ma55_60)
bear_60 = ta.crossunder(ma8_60, ma55_60)
isBuy_60 = ma8_60 > ma55_60

ma8_240 = request.security(syminfo.tickerid, "240", ta.sma(src, 8))
ma55_240 = request.security(syminfo.tickerid, "240", ta.sma(src, 55))
bull_240 = ta.crossover(ma8_240, ma55_240)
bear_240 = ta.crossunder(ma8_240, ma55_240)
isBuy_240= ma8_240 > ma55_240

ma8_D = request.security(syminfo.tickerid, "D", ta.sma(src, 8))
ma55_D = request.security(syminfo.tickerid, "D", ta.sma(src, 55))
bull_D = ta.crossover(ma8_D, ma55_D)
bear_D = ta.crossunder(ma8_D, ma55_D)
isBuy_D = ma8_D > ma55_D

// --- Table pojok kanan atas ---
var table T = na
if barstate.isfirst
T := table.new(position.top_right, 1, 8, border_width=1)

// Helper tampilan status
f_row(tbl, row, tfName, isBuy) =>
bg = isBuy ? color.green : color.red
txt = tfName + " : " + (isBuy ? "BUY" : "SELL")
table.cell(tbl, 0, row, txt, text_color=color.white, bgcolor=bg)

f_row(T, 0, "1m", isBuy_1)
f_row(T, 1, "5m", isBuy_5)
f_row(T, 2, "15m", isBuy_15)
f_row(T, 3, "1h", isBuy_60)
f_row(T, 4, "4h", isBuy_240)
f_row(T, 5, "1D", isBuy_D)

// --- Info crossing terakhir ---
var string lastCross = "Tidak ada crossing baru"
if bull_1
lastCross := "CROSS UP di TF 1m"
if bear_1
lastCross := "CROSS DOWN di TF 1m"
if bull_5
lastCross := "CROSS UP di TF 5m"
if bear_5
lastCross := "CROSS DOWN di TF 5m"
if bull_15
lastCross := "CROSS UP di TF 15m"
if bear_15
lastCross := "CROSS DOWN di TF 15m"
if bull_60
lastCross := "CROSS UP di TF 1h"
if bear_60
lastCross := "CROSS DOWN di TF 1h"
if bull_240
lastCross := "CROSS UP di TF 4h"
if bear_240
lastCross := "CROSS DOWN di TF 4h"
if bull_D
lastCross := "CROSS UP di TF 1D"
if bear_D
lastCross := "CROSS DOWN di TF 1D"

// tampilkan baris khusus "INFO ALERT"
table.cell(T, 0, 6, "INFO: " + lastCross, text_color=color.yellow, bgcolor=color.black)

// --- Alert asli (untuk notifikasi) ---
if bull_1 or bear_1
alert(lastCross, alert.freq_once_per_bar_close)
if bull_5 or bear_5
alert(lastCross, alert.freq_once_per_bar_close)
if bull_15 or bear_15
alert(lastCross, alert.freq_once_per_bar_close)
if bull_60 or bear_60
alert(lastCross, alert.freq_once_per_bar_close)
if bull_240 or bear_240
alert(lastCross, alert.freq_once_per_bar_close)
if bull_D or bear_D
alert(lastCross, alert.freq_once_per_bar_close)

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.