You are a professional PineScript version=5 developer.
You know how to code indicators and strategies and you also know their differences in code.
I need your help to turn a TradingView indicator into a strategy please.

Respect these instructions:
- Convert all Indicator specific code to Strategy specific code. Don't use any code that a TradingView Strategy won't support. Especially timeframes and gaps. Define those in code so they are semantically the same as before.

- Preserve the timeframe logic if there is one. Fill gaps.

- If the indicator is plotting something, the strategy code shall plot the same thing as well so the visuals are preserved.

- Don't trigger a short. Simply go Long and Flat.

- Starting Balance is $25,000
- 
- Always use 1.5% of capital.

- Set commission to 0.1%.

- Set slippage to 3.

- strategy.commission.percent and strategy.slippage don't exist in PineScript. Please avoid this mistake. Set those variables in the strategy() function when initiating the strategy.

- When initiating the strategy() function, don't use line breaks as this will cause a compiler error.

- Leave all other strategy settings to default values (aka. don't set them at all).

- Add Start Date and End Date inputs/filters so the user can choose from when to when to execute trades. Start with 1st January 2020 and go to 31st December 2050.

- When setting the title of the strategy, add "Demo GPT - " at the start of the name and then continue with the name of the strategy.


This is the code of the Indicator you shall migrate to a TradingView Strategy:




//@version=5
indicator('Magic MA with Daily Fibs Levels', overlay=true, max_bars_back=2000)

// Custom weighted moving average function
wma(src, len) =>
    float sum = 0.0
    float norm = 0.0
    for i = 0 to len - 1
        weight = len - i
        sum := sum + src[i] * weight
        norm := norm + weight
    sum / norm

// SuperSmoother filter
superSmoother(src, len) =>
    a1 = math.exp(-1.414 * math.pi / len)
    b1 = 2 * a1 * math.cos(1.414 * math.pi / len)
    c2 = b1
    c3 = -a1 * a1
    c1 = 1 - c2 - c3
    var float data = na
    data := c1 * (src + nz(src[1])) / 2 + c2 * nz(data[1]) + c3 * nz(data[2])

// Function to select Moving Average type
ma(type, src, len) =>
    switch type
        "SMA" => ta.sma(src, len)
        "EMA" => ta.ema(src, len)
        "WMA" => wma(src, len)
        "VWMA" => ta.vwma(src, len)
        "SMMA" => ta.rma(src, len)

        "HullMA" => wma(2 * wma(src, len / 2) - wma(src, len), math.round(math.sqrt(len)))
        "ZEMA" => ta.ema(ta.sma(src, len) + (ta.sma(src, len) - ta.ema(src, len)), len)
        "TMA" => ta.sma(ta.sma(src, len), len)
        "SSMA" => superSmoother(src, len)
        => src  // Default to source if type is unknown

// Inputs
type3 = input.string(defval="HullMA", title="Slow MA Type", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "DEMA", "TEMA", "HullMA", "ZEMA", "TMA", "SSMA"])
len3 = input.int(defval=37, title="Slow Length", minval=1)
RSIsrc = close
RSILen = input.int(6, title="RSI Length")
SF = input.int(3, title="RSI Smoothing Factor")
QQE = input.float(2.618, title="Fast QQE Factor")
threshhold = input.int(10, title="RSI Threshold")
filter = input.bool(false, title="Use Moving Average Filter")

// QQE Variables
Wilders_Period = RSILen * 2 - 1
Rsi = ta.rsi(RSIsrc, RSILen)
RSIndex = ta.ema(Rsi, SF)  // Ensure length is passed as SF
AtrRsi = math.abs(RSIndex[1] - RSIndex)
MaAtrRsi = ta.ema(AtrRsi, Wilders_Period)  // Ensure length is passed as Wilders_Period
DeltaFastAtrRsi = MaAtrRsi * QQE

newshortband = RSIndex + DeltaFastAtrRsi
newlongband = RSIndex - DeltaFastAtrRsi
float longband = 0.0
float shortband = 0.0
var int trend = 0
longband := RSIndex[1] > longband[1] and RSIndex > longband[1] ? math.max(longband[1], newlongband) : newlongband
shortband := RSIndex[1] < shortband[1] and RSIndex < shortband[1] ? math.min(shortband[1], newshortband) : newshortband
isCrossUp = ta.cross(RSIndex, shortband[1])
isCrossDown = ta.cross(longband[1], RSIndex)
trend := isCrossUp ? 1 : isCrossDown ? -1 : nz(trend[1], 1)
FastAtrRsiTL = trend == 1 ? longband : shortband

// Series variables
ma_slow = ma(type3, RSIsrc, len3)

// Plot Slow MA
plot(ma_slow, title="MA Slow", color=color.blue, linewidth=2)

// Daily Fibs Levels Section
firstLength = input.int(50, title='ADR Calculation Period (Days)')
fibScale = input.float(1, step=0.1, title='Fibonacci Scale')

dayOpen = request.security(syminfo.tickerid, "D", open)
dayHigh = request.security(syminfo.tickerid, "D", high)
dayLow = request.security(syminfo.tickerid, "D", low)

dayRange = dayHigh - dayLow
avgRange = request.security(syminfo.tickerid, "D", ta.sma(dayRange, firstLength))

fibLevels = array.new_float(6)
array.set(fibLevels, 0, avgRange * 0.25 * fibScale)
array.set(fibLevels, 1, avgRange * 0.77 * fibScale)  // Changed from 0.382 to 0.77
array.set(fibLevels, 2, avgRange * 1.0 * fibScale)  // Changed from 0.5 to 1.0
array.set(fibLevels, 3, avgRange * 0.618 * fibScale)
array.set(fibLevels, 4, avgRange * 0.786 * fibScale)
array.set(fibLevels, 5, avgRange * 1.0 * fibScale)

// Plot Fib Levels
plot(dayOpen + array.get(fibLevels, 0), color=color.red, linewidth=1, title="Fib Level 0.25")
plot(dayOpen - array.get(fibLevels, 0), color=color.green, linewidth=1, title="Fib Level -0.25")
plot(dayOpen + array.get(fibLevels, 1), color=color.red, linewidth=1, title="Fib Level 0.77")
plot(dayOpen - array.get(fibLevels, 1), color=color.green, linewidth=1, title="Fib Level -0.77")
plot(dayOpen + array.get(fibLevels, 2), color=color.red, linewidth=1, title="Fib Level 1.0")
plot(dayOpen - array.get(fibLevels, 2), color=color.green, linewidth=1, title="Fib Level -1.0")

// Alerts for crossing fib levels
alertcondition(ta.cross(close, dayOpen + array.get(fibLevels, 5)), title='Cross Above Fib 1', message='Price crossed above Fib 1')
alertcondition(ta.cross(close, dayOpen - array.get(fibLevels, 5)), title='Cross Below Fib -1', message='Price crossed below Fib -1').  add buy and sells criteria:
Buy - if price close above the slowma and above the -0.77 fib level. they must have same direction of trend.

Sell - if price close below the slowma and abelow the 0.77 fib level., they must have same direction if trend.

take profit is at 1:3
stoploss is at 1:05 fib level
dont take trade if the theyre not on thesame direction