PromptBase
Close icon
General
Home
Marketplace
Hire
Create
Login
Sell
Explore
🤖 GPT

Pine Script Multitimeframe Strategy

Pine Script Multitimeframe Strategy gpt prompt mini thumbnail
1Eye icon
Views
GPT-4O
TestedTick icon
TipsTick icon
4 examplesTick icon
Expert Pine Script Multi-Timeframe Strategy Developer
...more
$4.99
Get prompt
After purchasing, you will gain access to the prompt file which you can use with GPT or the app builder. You'll receive 20 free generation credits with this purchase. By purchasing this prompt, you agree to our terms of service.
6 days ago

Prompt Details

Model
Chat - GPT-4o (gpt-4o)
Token size
142 ($0.00710 / call)
Example input
[ describe the trading strategy ]: combine a daily MACD for trend direction with hourly price breakouts for entries [ specify indicators or rules ]: MACD histogram being positive on the daily chart and hourly price breaking above resistance
Example output
Here’s the Pine Script for the described multi-timeframe strategy: ```pinescript //@version=5 strategy("Daily MACD + Hourly Breakout Strategy", overlay=true) // === INPUT PARAMETERS === // Timeframe and MACD settings dailyTF = input.timeframe("D", title="Higher Timeframe (MACD)") macdFast = input(12, title="MACD Fast Length") macdSlow = input(26, title="MACD Slow Length") macdSignal = input(9, title="MACD Signal Length") // Breakout settings breakoutThreshold = input(0.5, title="Breakout Threshold (%)") // Risk management riskPercent = input.float(1, title="Risk % of Equity", minval=0.1, step=0.1) // === FUNCTIONS === // Higher timeframe MACD calculation [dailyMacdLine, dailySignalLine, dailyHist] = request.security(syminfo.tickerid, dailyTF, ta.macd(close, macdFast, macdSlow, macdSignal)) // Hourly breakout levels hourlyHigh = ta.highest(high, 24) // Last 24 candles hourlyLow = ta.lowest(low, 24) // Last 24 candles breakoutLevel = hourlyHigh + (hourlyHigh * breakoutThreshold / 100) // Entry conditions longCondition = (dailyHist > 0) and (close > breakoutLevel) // Exit conditions exitCondition = close < hourlyLow // === STRATEGY LOGIC === if longCondition strategy.entry("Long", strategy.long) label.new(bar_index, close, "Entry", style=label.style_label_up, color=color.green) if exitCondition strategy.close("Long") label.new(bar_index, close, "Exit", style=label.style_label_down, color=color.red) // === ALERTS === if longCondition alert("Long Entry Signal: Price breaking above breakout level with daily MACD histogram positive.", alert.freq_once_per_bar) if exitCondition alert("Exit Signal: Price fell below hourly support level.", alert.freq_once_per_bar) // === PLOTTING === // Visualize breakout levels and MACD histogram plot(hourlyHigh, color=color.blue, linewidth=2, title="Hourly Resistance") plot(hourlyLow, color=color.red, linewidth=2, title="Hourly Support") hline(0, "MACD Zero Line", color=color.gray) plot(dailyHist, color=color.purple, style=plot.style_histogram, title="Daily MACD Histogram") // === COMMENTS === // 1. The strategy uses the daily MACD histogram to identify the trend. // 2. The hourly breakout above resistance determines the entry point. // 3. Exit occurs when the price breaks below the hourly support. // 4. Configurable inputs allow customization of timeframes, MACD settings, and breakout threshold. // 5. Alerts are generated for both entry and exit conditions. ``` ### Features and Functionality: 1. **Higher Timeframe MACD**: The daily MACD histogram is used to confirm an uptrend. 2. **Lower Timeframe Breakout**: Hourly breakouts above resistance signal entry points. 3. **Configurable Parameters**: Timeframes, MACD lengths, breakout thresholds, and risk settings are fully adjustable. 4. **Clear Trade Markers**: Labels for entry and exit points are placed on the chart. 5. **Alerts**: Alerts for entries and exits are aligned with conditions on both timeframes. 6. **Visualizations**: Hourly breakout levels and MACD histogram are displayed for better strategy tracking. Let me know if you need further refinements!
Browse Marketplace