10 Comments
User's avatar
Cagan Tunc's avatar

Kodun "Projected Volume" için revize edilmiş hali aşağıdadır. Son dönemde ben bu versiyonu kullanmaya başladım.

//@version=5

indicator("Volume Comparison - Projected Volume-REV01", overlay=false)

// User-configurable inputs

length = input.int(50, "Moving Average Period", minval=1, tooltip="Period for calculating the average volume")

multiplier = input.float(2.0, "Volume Multiplier", minval=0.1, step=0.1, tooltip="Multiplier for comparing volume to average volume")

// Calculate projected volume for the current bar

time_period = ((time_close - time) / 1000)

time_passed = ((timenow - time) / 1000)

time_left = ((time_close - timenow) / 1000)

volume_per_second = 0.0

raw_volume_projected = float(volume) // Keep original projected volume

display_volume_projected = float(volume) // For display with unit conversion

uP = ''

if time_left > 0

volume_per_second := time_passed > 0 ? (volume / time_passed) : 0 // Prevent division by zero

raw_volume_projected := (volume + (volume_per_second * time_left))

display_volume_projected := raw_volume_projected

if display_volume_projected >= 1000 and display_volume_projected < 1000000

display_volume_projected := display_volume_projected / 1000

uP := 'K'

else if display_volume_projected >= 1000000 and display_volume_projected < 1000000000

display_volume_projected := display_volume_projected / 1000000

uP := 'M'

else if display_volume_projected >= 1000000000

display_volume_projected := display_volume_projected / 1000000000

uP := 'B'

// Calculate average volume based on actual volume

avg_volume = ta.sma(volume, length)

// Calculate threshold with unit conversion for display

threshold = avg_volume * multiplier

display_threshold = threshold

uT = ''

if threshold >= 1000 and threshold < 1000000

display_threshold := threshold / 1000

uT := 'K'

else if threshold >= 1000000 and threshold < 1000000000

display_threshold := threshold / 1000000

uT := 'M'

else if threshold >= 1000000000

display_threshold := threshold / 1000000000

uT := 'B'

// Comparison: Use raw (unscaled) projected volume

is_high_volume = raw_volume_projected >= avg_volume * multiplier

// Label results

label.new(bar_index, display_volume_projected, is_high_volume ? "True" : "False",

color=is_high_volume ? color.green : color.red,

style=label.style_label_down,

textcolor=color.white)

// Display results in a table

var table t = table.new(position.top_right, 2, 3, border_width=1)

if barstate.islast

table.cell(t, 0, 0, "Projected Volume", bgcolor=color.gray, text_color=color.white)

table.cell(t, 1, 0, str.tostring(display_volume_projected) + uP, bgcolor=color.gray, text_color=color.white)

table.cell(t, 0, 1, "Threshold (Avg Vol * Mult)", bgcolor=color.orange, text_color=color.white)

table.cell(t, 1, 1, str.tostring(display_threshold) + uT, bgcolor=color.orange, text_color=color.white)

table.cell(t, 0, 2, "Condition", bgcolor=is_high_volume ? color.green : color.red, text_color=color.white)

table.cell(t, 1, 2, is_high_volume ? "True" : "False", bgcolor=is_high_volume ? color.green : color.red, text_color=color.white)

// Alarm conditions

alertcondition(is_high_volume, title="Projected Volume High", message="Projected volume is at least {{multiplier}}x the average volume")

alertcondition(not is_high_volume, title="Projected Volume Low", message="Projected volume is below {{multiplier}}x the average volume")

Expand full comment
Sarper's avatar

Merhaba kod için teşekkürler ancak Mismatched input 'volume_per_second' expecting 'end of line without line continuation' şeklinde bir hata alıyorum. Çözümü hakkında bilginiz var mıdır ? İyi akşamlar.

Expand full comment
burak's avatar

Mismatched input 'volume_per_second' expecting 'end of line without line continuation' hatasını ben de alıyorum.

Expand full comment
Cagan Tunc's avatar

Ben böyle bir hata almıyorum. Akşam tekrar kontrol edip yazarım.

Expand full comment
Cagan Tunc's avatar

Tekrar kontrol ettim. Bende bir hata vermiyor...

Expand full comment
Şehriban Özdemir's avatar

Farklı konulardaki yol göstericiliğiniz için çok teşekkür ederim..Deneyeceğim..

Expand full comment
Eray's avatar

Değerli bir paylaşım oldu benim için. Teşekkür ederim Çağan bey.

Expand full comment
Fatih's avatar

Çağan bey bilgiler için teşekkürler.

Expand full comment
Aydın Güllüdağ's avatar

Çağan Bey , paylaşım için çok teşekkürler emeğinize sağlık , bu arada TW yıllık yenilemede PREMIUM da paketi mobilden mi web ten mi yeniliyorsunuz? Fiyatlaması çok farklı çıkıyor ? sizin tercihiniz nasıl oluyor ?

Expand full comment
Fatıh koseoglu's avatar

Emeklerine sağlık Cağan

Expand full comment