Initial commit - BTC Trading Dashboard

- FastAPI backend with PostgreSQL database connection
- Frontend dashboard with lightweight-charts
- Technical indicators (SMA, EMA, RSI, MACD, Bollinger Bands, etc.)
- Trading strategy simulation and backtesting
- Database connection to NAS at 20.20.20.20:5433
- Development server setup and documentation
This commit is contained in:
DiTus
2026-02-25 22:10:30 +01:00
commit c7ee5135ae
55 changed files with 9172 additions and 0 deletions

86
src/TV/HTS.pine Normal file
View File

@ -0,0 +1,86 @@
//@version=5
indicator(title='HTS p1otek (Fixed)', overlay=true )
// Helper function to return the correct timeframe string for request.security
// Note: We let Pine Script infer the return type to avoid syntax errors
getAutoTFString(chartTFInMinutes) =>
float autoTFMinutes = chartTFInMinutes / 4.0
// Use an existing time resolution string if possible (D, W, M)
if timeframe.isdaily
// 'D' timeframe is 1440 minutes. 1440 / 4 = 360 minutes (6 hours)
// We return "360" which Pine Script accepts as a resolution
str.tostring(math.round(autoTFMinutes))
else if timeframe.isweekly or timeframe.ismonthly
// Cannot divide W or M timeframes reliably, return current timeframe string
timeframe.period
else
// For standard minute timeframes, use the calculated minutes
str.tostring(math.round(autoTFMinutes))
// Inputs
// FIXED: Changed input.integer to input.int
short = input.int(33, "fast")
long = input.int(144, "slow")
auto = input.bool(false, title = "auto HTS (timeframe/4)")
draw_1h = input.bool(false, title = "draw 1h slow HTS")
metoda = input.string(title = "type average", defval = "RMA", options=["RMA", "EMA", "SMA", "WMA", "VWMA"])
// Calculate chart TF in minutes
float chartTFInMinutes = timeframe.in_seconds() / 60
// Get the auto-calculated timeframe string
string autoTFString = getAutoTFString(chartTFInMinutes)
srednia(src, length, type) =>
switch type
"RMA" => ta.rma(src, length)
"EMA" => ta.ema(src, length)
"SMA" => ta.sma(src, length)
"WMA" => ta.wma(src, length)
"VWMA" => ta.vwma(src, length)
// === Non-Auto (Current Timeframe) Calculations ===
string currentTFString = timeframe.period
shortl = request.security(syminfo.tickerid, currentTFString, srednia(low, short, metoda))
shorth = request.security(syminfo.tickerid, currentTFString, srednia(high, short, metoda))
longl = request.security(syminfo.tickerid, currentTFString, srednia(low, long, metoda))
longh = request.security(syminfo.tickerid, currentTFString, srednia(high, long, metoda))
// === Auto Timeframe Calculations ===
shortl_auto = request.security(syminfo.tickerid, autoTFString, srednia(low, short, metoda))
shorth_auto = request.security(syminfo.tickerid, autoTFString, srednia(high, short, metoda))
longl_auto = request.security(syminfo.tickerid, autoTFString, srednia(low, long, metoda))
longh_auto = request.security(syminfo.tickerid, autoTFString, srednia(high, long, metoda))
// === 1H Timeframe Calculations ===
// Use a fixed '60' for 1 hour
longl_1h = request.security(syminfo.tickerid, "60", srednia(low, long, metoda))
longh_1h = request.security(syminfo.tickerid, "60", srednia(high, long, metoda))
// === Plotting ===
// Auto HTS
plot(auto ? shortl_auto: na, color=color.new(color.aqua, 0), linewidth=1, title="fast low auto")
plot(auto ? shorth_auto: na, color=color.new(color.aqua, 0), linewidth=1, title="fast high auto")
plot(auto ? longl_auto: na, color=color.new(color.red, 0), linewidth=1, title="slow low auto")
plot(auto ? longh_auto: na, color=color.new(color.red, 0), linewidth=1, title="slow high auto")
// Current TF (only when Auto is enabled, for reference)
ll = plot( auto ? longl: na, color=color.new(color.red, 80), linewidth=1, title="current slow low")
oo = plot( auto ? longh: na, color=color.new(color.red, 80), linewidth=1, title="current slow high")
fill(ll,oo, color=color.new(color.red, 90))
// 1H Zone
zone_1hl = plot( draw_1h ? longl_1h: na, color=color.new(color.red, 80), linewidth=1, title="1h slow low")
zone_1hh = plot( draw_1h ? longh_1h: na, color=color.new(color.red, 80), linewidth=1, title="1h slow high")
fill(zone_1hl,zone_1hh, color=color.new(color.red, 90))
// Non-Auto HTS
plot(not auto ? shortl: na, color=color.new(color.aqua, 0), linewidth=1, title="fast low")
plot(not auto ? shorth: na, color=color.new(color.aqua, 0), linewidth=1, title="fast high")
plot(not auto ? longl: na, color=color.new(color.red, 0), linewidth=1, title="slow low")
plot(not auto ? longh: na, color=color.new(color.red, 0), linewidth=1, title="slow high")