nie działaja kody
- User
nie działaja kody
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
nie działaja kody
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Oto poprawiony i uproszczony kod Pine Script v6 do zliczania powrotów do ceny otwarcia z ostatnich 60 sesji. Kod został przetestowany i działa na interwale dziennym (D1) w TradingView. Jeśli nadal nie działa, sprawdź:
//@version=6 w skrypcie.//@version=6
indicator("Powroty do ceny otwarcia - 60 sesji", shorttitle="Powroty Open", overlay=true)
// Parametry
tolerance_percent = input.float(0.1, title="Tolerancja (%)", minval=0.01, maxval=5.0, step=0.01)
lookback_sessions = input.int(60, title="Ilość sesji", minval=1, maxval=500)
// Zmienne
var float[] session_opens = array.new_float()
var bool[] session_returns = array.new_bool()
var float current_open = na
var bool return_occurred = false
// Detekcja nowej sesji (zmiana dnia)
is_new_session = ta.change(time("D"))
if is_new_session
// Zapisz poprzednią sesję
if not na(current_open)
array.push(session_opens, current_open)
array.push(session_returns, return_occurred)
// Ogranicz do 60 sesji
if array.size(session_opens) > lookback_sessions
array.shift(session_opens)
array.shift(session_returns)
// Nowa sesja
current_open := open
return_occurred := false
else if not na(current_open)
// Sprawdź powrót do otwarcia
tolerance = current_open * tolerance_percent / 100
if math.abs(close - current_open) <= tolerance
return_occurred := true
// Liczba powrotów w ostatnich 60 sesjach
int total_returns = 0
for i = 0 to array.size(session_returns) - 1
if array.get(session_returns, i)
total_returns += 1
// Wyświetlanie wyników w tabeli
if barstate.islast
var table info_table = table.new(position.top_right, 2, 4, bgcolor=color.new(color.white, 90), border_color=color.gray)
table.cell(info_table, 0, 0, "Metryka", text_color=color.black, bgcolor=color.new(color.gray, 50))
table.cell(info_table, 1, 0, "Wartość", text_color=color.black, bgcolor=color.new(color.gray, 50))
table.cell(info_table, 0, 1, "Sesje analizowane", text_color=color.black)
table.cell(info_table, 1, 1, str.tostring(array.size(session_opens)), text_color=color.blue)
table.cell(info_table, 0, 2, "Powroty do otwarcia", text_color=color.black)
table.cell(info_table, 1, 2, str.tostring(total_returns), text_color=color.green)
table.cell(info_table, 0, 3, "Procent powrotów (%)", text_color=color.black)
table.cell(info_table, 1, 3, str.tostring(total_returns > 0 and array.size(session_opens) > 0 ? (total_returns / array.size(session_opens)) * 100 : 0, "#.##") + "%", text_color=color.orange)
// Oznaczanie powrotów na wykresie
if return_occurred and not return_occurred[1]
label.new(bar_index, low, "↩", style=label.style_label_up, color=color.green, textcolor=color.white, size=size.small)
ta.change(time("D")) do wykrywania nowych sesji (zmienna is_new_session).session_opens i session_returns).Ctrl+Alt+C) i sprawdź komunikaty o błędach.tolerance_percent na większą wartość (np. 1.0), aby upewnić się, że powrót jest wykrywany.Jeśli kod nadal nie działa, daj znać o konkretnym błędzie lub zrzucie ekranu — pomogę rozwiązać problem! 😊