//@version=4 strategy(“Spread Z-Score Strategy”, overlay=true) // Step 1: Get Spread…
- User
//@version=4 strategy(“Spread Z-Score Strategy”, overlay=true)
// Step 1: Get Spread (Asset Price - VWAP) spread = close - vwap
// Step 2: Input value for “Rolling Window” window = input(250, “Rolling Window”)
// Step 3: Z-Score with MAD as mean mean = ta.zscore(spread, window, 1) deviation = stdev(spread, window) z_score = (spread - mean) / deviation
// Step 4: Buy/Sell Strategy Logic long_entry = input(-1, “Long Entry”) long_stop_loss = input(-1.5, “Long Stop Loss”) long_take_profit = input(0, “Long Take Profit”)
short_entry = input(1, “Short Entry”) short_stop_loss = input(1.5, “Short Stop Loss”) short_take_profit = input(0, “Short Take Profit”)
// Buy Signal buy_signal = z_score < long_entry
// Sell Signal sell_signal = z_score > short_entry
// Exit Signal exit_long = z_score < long_stop_loss or z_score > long_take_profit exit_short = z_score > short_stop_loss or z_score < short_take_profit
// Strategy Entry and Exit strategy.entry(“Buy”, strategy.long, when=buy_signal) strategy.entry(“Sell”, strategy.short, when=sell_signal)
strategy.close(“Buy”, when=exit_long) strategy.close(“Sell”, when=exit_short)
- Assistant
//@version=4 strategy("Spread Z-Score Strategy", overlay=true)
// Step 1: Get Spread (Asset Price - VWAP) spread = close - vwap
// Step 2: Input value for "Rolling Window" window = input(250, "Rolling Window")
// Step 3: Z-Score with MAD as mean mean = ta.zscore(spread, window, 1) deviation = stdev(spread, window) z_score = (spread - mean) / deviation
// Step 4: Buy/Sell Strategy Logic long_entry = input(-1, "Long Entry") long_stop_loss = input(-1.5, "Long Stop Loss") long_take_profit = input(0, "Long Take Profit")
short_entry = input(1, "Short Entry") short_stop_loss = input(1.5, "Short Stop Loss") short_take_profit = input(0, "Short Take Profit")
// Buy Signal buy_signal = z_score < long_entry
// Sell Signal sell_signal = z_score > short_entry
// Exit Signal exit_long = z_score < long_stop_loss or z_score > long_take_profit exit_short = z_score > short_stop_loss or z_score < short_take_profit
// Strategy Entry and Exit strategy.entry("Buy", strategy.long, when=buy_signal) strategy.entry("Sell", strategy.short, when=sell_signal)
strategy.close("Buy", when=exit_long) strategy.close("Sell", when=exit_short)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.