//@version=6
indicator("Simplified RSI", overlay=false)

// Input Parameters
rsiLength = input.int(17, "RSI Length", minval=1)
hullLength = input.int(20, "Hull MA Length", minval=1)
obLevel = input.float(65, "Overbought Level", minval=50, maxval=100)
osLevel = input.float(35, "Oversold Level", minval=0, maxval=50)

// Core Calculations
rsi = ta.rsi(close, rsiLength)
hullMA = ta.hma(rsi, hullLength)

// Plotting
hullColor = hullMA > obLevel ? color.red : hullMA < osLevel ? color.green : color.gray
plot(rsi, "RSI", color.blue)
plot(hullMA, "Hull MA", hullColor, 2)
hline(obLevel, "Overbought", color.red)
hline(osLevel, "Oversold", color.green)
hline(50, "Centerline", color.gray, linestyle=hline.style_dotted)

// Basic Signals
bullSignal = rsi < osLevel and hullMA < osLevel
bearSignal = rsi > obLevel and hullMA > obLevel

// Signal Visualization
plotshape(bullSignal, "Buy Signal", shape.triangleup, location.bottom, color.green, size=size.small)
plotshape(bearSignal, "Sell Signal", shape.triangledown, location.top, color.red, size=size.small)

// Alerts
alertcondition(bullSignal, title="Bullish Signal", message="Bullish signal detected!")
alertcondition(bearSignal, title="Bearish Signal", message="Bearish signal detected!")

//@version=6
indicator("Stochastic Momentum Index", "SMI", timeframe = "", timeframe_gaps = true)

lengthK   = input.int(10, "%K Length",  minval = 1, maxval = 15000)
lengthD   = input.int(3,  "%D Length",  minval = 1, maxval = 4999)
lengthEMA = input.int(3,  "EMA Length", minval = 1, maxval = 4999)

emaEma(source, length) => ta.ema(ta.ema(source, length), length)

highestHigh = ta.highest(lengthK)
lowestLow =   ta.lowest(lengthK)
highestLowestRange = highestHigh - lowestLow
relativeRange = close - (highestHigh + lowestLow) / 2
smi = 200 * (emaEma(relativeRange, lengthD) / emaEma(highestLowestRange, lengthD))

smiPlot = plot(smi, "SMI", color = color.blue)
plot(ta.ema(smi, lengthEMA), "SMI-based EMA", color = color.orange)

overbought = hline(40, "Overbought Line")
oversold   = hline(-40, "Oversold Line")
fill(overbought, oversold, color = color.new(color.blue, 90))
hline(0, "Middle Line", color = color.new(color.gray, 50))


midLinePlot = plot(0, color = na, editable = false, display = display.none)
fill(smiPlot, midLinePlot, 120,  40,   top_color = color.new(#4caf4f, 50),    bottom_color = color.new(color.green, 100), title = "Overbought Gradient Fill")
fill(smiPlot, midLinePlot, -40, -120,  top_color = color.new(color.red, 100), bottom_color = color.new(color.red, 50),    title = "Oversold Gradient Fill")

//@version=3
study(title = "Hull Moving Averages", shorttitle="HMAs", overlay = true)
length1 = input(4, minval=1)
length2 = input(108, minval=1)
src = input(ohlc4, title="Source")
//Thanks ChrisMoody and TheLark...AKA...The Coding Genius's   (For the pivot thingy)
pf = input(false,title="Show Filtered Pivots")
sa = input(false,title="Show Pivot Average")
sh = input(false, title="Show 1 Hour Pivots?")
sf = input(false, title="Show 4 Hour Pivots?")
sd = input(false, title="Show Daily Pivots?")
sh3 = input(false, title="Show R3 & S3 Only On 1 Hour & 4 Hour?")
// Classic Pivot
pivot = (high + low + close ) / 3.0
// Filter Cr
bull= pivot > (pivot + pivot[1]) / 2 + .0025
bear= pivot < (pivot + pivot[1]) / 2 - .0025
// Classic Pivots
r1 = pf and bear ? pivot + (pivot - low) : pf and bull ? pivot + (high - low) : pivot + (pivot - low)
s1 = pf and bull ? pivot - (high - pivot) : pf and bear ? pivot - (high - low) : pivot - (high - pivot)
r2 = pf ? na : pivot + (high - low)
s2 = pf ? na : pivot - (high - low)
r3 = sh3 and r1 + (high - low) ? r1 + (high - low) : na
s3 = sh3 and s1 - (high - low) ? s1 - (high - low) : na
//Pivot Average Calculation
smaP = sma(pivot, 3)
//1 Hour Pivots
htime_pivot = security(tickerid, '60', pivot[1])
htime_pivotAvg = security(tickerid, '60', smaP[1])
htime_R1 = security(tickerid, '60', r1[1])
htime_S1 = security(tickerid, '60', s1[1])
htime_R2 = security(tickerid, '60', r2[1])
htime_S2 = security(tickerid, '60', s2[1])
htime_R3 = security(tickerid, '60', r3[1])
htime_S3 = security(tickerid, '60', s3[1])
plot(sa and sh and htime_pivotAvg ? htime_pivotAvg : na, title="Hourly Pivot Average",style=cross, color=orange,linewidth=1,trackprice=true)
plot(sh and htime_pivot ? htime_pivot : na, title="Hourly Pivot",style=cross, color=fuchsia,linewidth=1,trackprice=true) 
plot(sh and htime_R1 ? htime_R1 : na, title="Hourly R1",style=cross, color=#DC143C,linewidth=1,trackprice=true)
plot(sh and htime_S1 ? htime_S1 : na, title="Hourly S1",style=cross, color=lime,linewidth=1,trackprice=true)
plot(sh and htime_R2 ? htime_R2 : na, title="Hourly R2",style=cross, color=maroon,linewidth=1,trackprice=true)
plot(sh and htime_S2 ? htime_S2 : na, title="Hourly S2",style=cross, color=#228B22,linewidth=1,trackprice=true)
plot(sh and htime_R3 ? htime_R3 : na, title="Hourly R3",style=cross, color=#FA8072,linewidth=1,trackprice=true)
plot(sh and htime_S3 ? htime_S3 : na, title="Hourly S3",style=cross, color=#CD5C5C,linewidth=1,trackprice=true)

//4 Hour Pivots
ftime_pivot = security(tickerid, '240', pivot[1])
ftime_pivotAvg = security(tickerid, '240', smaP[1])
ftime_R1 = security(tickerid, '240', r1[1]) 
ftime_S1 = security(tickerid, '240', s1[1])
ftime_R2 = security(tickerid, '240', r2[1]) 
ftime_S2 = security(tickerid, '240', s2[1])
ftime_R3 = security(tickerid, '240', r3[1]) 
ftime_S3 = security(tickerid, '240', s3[1])
plot(sa and sf and ftime_pivotAvg ? ftime_pivotAvg : na, title="4 Hour Pivot Average",style=cross, color=orange,linewidth=1,trackprice=true)
plot(sf and ftime_pivot ? ftime_pivot : na, title="4 Hour Pivot",style=cross, color=fuchsia,linewidth=1,trackprice=true) 
plot(sf and ftime_R1 ? ftime_R1 : na, title="4 Hour R1",style=cross, color=#DC143C,linewidth=1,trackprice=true) 
plot(sf and ftime_S1 ? ftime_S1 : na, title="4 Hour S1",style=cross, color=lime,linewidth=1,trackprice=true) 
plot(sf and ftime_R2 ? ftime_R2 : na, title="4 Hour R2",style=cross, color=maroon,linewidth=1,trackprice=true) 
plot(sf and ftime_S2 ? ftime_S2 : na, title="4 Hour S2",style=cross, color=#228B22,linewidth=1,trackprice=true) 
plot(sf and ftime_R3 ? ftime_R3 : na, title="4 Hour R3",style=cross, color=#FA8072,linewidth=1,trackprice=true) 
//Daily Pivots 
dtime_pivot = security(tickerid, 'D', pivot[1])
dtime_pivotAvg = security(tickerid, 'D', smaP[1])
dtime_r1 = security(tickerid, 'D', r1[1]) 
dtime_s1 = security(tickerid, 'D', s1[1]) 
dtime_r2 = security(tickerid, 'D', r2[1]) 
dtime_s2 = security(tickerid, 'D', s2[1])
offs_daily = 0
plot(sa and sd and dtime_pivotAvg ? dtime_pivotAvg : na, title="Daily Pivot Average",style=cross, color=orange,linewidth=1,trackprice=true)
plot(sd and dtime_pivot ? dtime_pivot : na, title="Daily Pivot",style=cross, color=fuchsia,linewidth=1,trackprice=true) 
plot(sd and dtime_r1 ? dtime_r1 : na, title="Daily R1",style=cross, color=#DC143C,linewidth=1,trackprice=true) 
plot(sd and dtime_s1 ? dtime_s1 : na, title="Daily S1",style=cross, color=lime,linewidth=1,trackprice=true) 
plot(sd and dtime_r2 ? dtime_r2 : na, title="Daily R2",style=cross, color=maroon,linewidth=1,trackprice=true) 
plot(sd and dtime_s2 ? dtime_s2 : na, title="Daily S2",style=cross, color=#228B22,linewidth=1,trackprice=true) 
//-end of pivot code
h2ma=2*wma(src,round(length1/2))
hma=wma(src,length1)
diff=h2ma-hma
sqn=round(sqrt(length1))
h2mab=2*wma(src[1],round(length2/2))
hmab=wma(src[1],length2)
diff1=h2mab-hmab
sqn1=round(sqrt(length2))
hma1=wma(diff,sqn)
hma2=wma(diff1,sqn)
c=hma1>hma2?green:red
d=plot(hma1, style = line,color=c, linewidth = 1, title='HMA1')
e=plot(hma2, style = line,color=c, linewidth = 1, title='HMA2')
fill(d,e,color=c, transp=75, title='cloud')

I wrote the above 3 indicators in Pinescript, and I want you to convert them into python code and write a strategy that uses the above 3 indicators. 
The first indicator is a custom simplified RSI. If the RSI is above the overbought level and SMI for second indicator is above overbought line in both 1m and 5m timeframes, then generate a sell signal. Both conditions must be true. After the signal is generated then look for an entry point which should be based on the third indicator. If HMA1 crosses below HMA2, then that becomes the entry point for a sell trade. 
If the RSI is below the oversold level and SMI in second indicator is below oversold line in both 1m and 5m timeframes, then generate a buy signal. Both conditions must be true and both timeframes must show the same. After the signal is generated then look for an entry point which should be based on the third indicator. If HMA1 crosses above HMA2, then that becomes the entry point for a buy trade. 
You need to generate a signal even without the entry point and then continue to monitor the symbol price to identify the entry point. Use these custom indicators with the parameters I specified in my pinescript code. When writing SMI ensure timeframe is 5 minutes. Do not use chart. 

Also, I want you to use Binance public APIs to fetch historical price data and connect to websockets to fetch real time price data for all USDT pairs in futures. Fetch historical data in batches i.e use one API call to fetch as many symbols as possible. Like 10 symbols or even more in a single API call and fetch them concurrently. Also connect several symbols to each websocket connection and also use asyncio for concurrent WebSocket connections.  Please note I intend to use PostgreSQL and Django so make it compatible. Ensure that all historical data is saved so that I don't have to fetch data everytime. Also, when connected to websockets ensure all the data coming in is also saved to the existing historical data so that the data is updated automatically and is continous. Perform analysis on all symbols concurrently. Include robust error handling and data validation. Ensure the data is accurate and complete. And I repeat, all websocket data must be added and saved to historical data automatically.

Ensure that you write custom indicators in python, maintaining the exact same behavior as your PineScript code. Do not use common indiactors from Talib.
Ensure you use both 1 minute and 5 minute timeframes so that the signals will be confirmed. Both 1m and 5m timeframes must fulfill the conditions.
When saving signals include the RSI, The SMI, and Entry price, Symbol, Timestamp. The entry price is where HMA1 crossess HMA2. Initially it will be pending but the moment the crossing happens then record that price and let it be the entry price.
Write the indicators, data fetcher and signal generator in one script. Do not write models.py code. Use Binance public API do not ask for API keys and secret keys
Hull MA should have Length 1 of 4 Length 2 of 30 and source is close. Simplified RSI should have RSI Length of 20, Hull MA of 168, Overbought level of 65 and oversold level of 35. Custom SMI should have k_length of 10, d_length of 3, ema_length of 3 and Multi Timeframe (MTF) timeframe of 5 minutes. Make sure you include the MTF and modify it to 5 minutes. Do not use the common that uses chart 
The system should Fetch all USDT futures pairs, Download historical data for both 1-minute and 5-minute timeframes and update it with data from websockets as it is received, Start multiple WebSocket connections for real-time data and save it to historical data, Process incoming data and generate signals, Save all data and signals to PostgreSQL and Automatically reconnect if connections are lost.

Write complete code regardless of length