gpt-4.1-mini-2025-04-14· OpenAI
WildChat-4.8M (AI2)
create me a simple day trading strategy and write a pine script. the rate should be 1:5
- User
create me a simple day trading strategy and write a pine script. the rate should be 1:5
- Assistant
create me a simple day trading strategy and write a pine script. the rate should be 1:5
Certainly! A simple day trading strategy with a 1:5 risk-to-reward ratio can be created using commonly used technical indicators. Here's an example:
Strategy Concept:
Use a Moving Average Crossover for entries:
Use the entry price to set Stop Loss (SL) and Take Profit (TP) to follow a 1:5 risk-to-reward ratio:
//@version=5
strategy("Simple MA Crossover 1:5 R:R Day Trading", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// Inputs
shortLen = input.int(9, minval=1, title="Short MA Length")
longLen = input.int(21, minval=1, title="Long MA Length")
atrLen = input.int(14, minval=1, title="ATR Length")
atrMultiplierSL = input.float(1.0, title="ATR Multiplier for Stop Loss")
// Moving Averages
shortMA = ta.sma(close, shortLen)
longMA = ta.sma(close, longLen)
// ATR for stop loss distance
atr = ta.atr(atrLen)
stopLossDistance = atr * atrMultiplierSL
// Entry Conditions
longCondition = ta.crossover(shortMA, longMA)
shortCondition = ta.crossunder(shortMA, longMA)
// Plot MAs
plot(shortMA, color=color.blue, title="Short MA")
plot(longMA, color=color.orange, title="Long MA")
// Manage Entries and Exits
if (longCondition)
// Enter long
strategy.entry("Long", strategy.long)
// Set stop loss and take profit
strategy.exit("Long Exit", from_entry="Long", stop=close - stopLossDistance, limit=close + 5 * stopLossDistance)
if (shortCondition)
// Enter short
strategy.entry("Short", strategy.short)
// Set stop loss and take profit
strategy.exit("Short Exit", from_entry="Short", stop=close + stopLossDistance, limit=close - 5 * stopLossDistance)
You can adjust inputs such as shortLen, longLen, atrLen, and atrMultiplierSL as needed. Also, ensure to test the strategy and adapt it to your trading asset/timeframe.
If you want it with fixed stop loss points (instead of ATR), just let me know and I can modify the script!
Not yet included in a published release.