add buy and sells criteria: Buy - if price close above the slowma and above the -0.77…
- User
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 below 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 //@version=5 strategy("Demo GPT - Magic MA with Daily Fibs Levels", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=1.5, commission_type=strategy.commission.percent, commission_value=0.1, slippage=3)
// 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)
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.