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

Pine Script Support Resistance Tool

Pine Script Support Resistance Tool gpt prompt mini thumbnail
1Eye icon
Views
GPT-4O
TestedTick icon
TipsTick icon
4 examplesTick icon
Pine Script Multi-Timeframe Support & Resistance Tool Creator
...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.
1 day ago

Prompt Details

Model
Chat - GPT-4o (gpt-4o)
Token size
174 ($0.00870 / call)
Example input
[ describe the purpose and application of the tool ]: identify key support and resistance zones across multiple timeframes to aid swing traders
Example output
Below is a **Pine Script** implementation for a **multi-timeframe support and resistance tool** in TradingView. It includes key features like automatic detection, configurable parameters, multi-timeframe plotting, alerts, and filtering weaker zones. --- ### **Pine Script Code** ```pinescript //@version=5 indicator("Multi-Timeframe Support and Resistance", shorttitle="MTF S/R", overlay=true) // === Input Parameters === // // Timeframes to analyze tf1 = input.timeframe("60", title="Timeframe 1 (e.g., 1H)") tf2 = input.timeframe("240", title="Timeframe 2 (e.g., 4H)") tf3 = input.timeframe("D", title="Timeframe 3 (e.g., 1D)") // Sensitivity and Filtering sensitivity = input.int(2, minval=1, title="Sensitivity (Lower = More Levels)") levelTouches = input.int(3, minval=1, title="Min Touches for Valid Level") // Display Options numLevels = input.int(5, minval=1, title="Number of Levels to Display per Timeframe") lineStyleTF1 = input.string("solid", title="Line Style for TF1", options=["solid", "dashed", "dotted"]) lineStyleTF2 = input.string("dashed", title="Line Style for TF2", options=["solid", "dashed", "dotted"]) lineStyleTF3 = input.string("dotted", title="Line Style for TF3", options=["solid", "dashed", "dotted"]) colorTF1 = color.new(color.blue, 0) // 1H color colorTF2 = color.new(color.orange, 0) // 4H color colorTF3 = color.new(color.red, 0) // Daily color // Alert Options alertProximity = input.float(0.5, minval=0.1, title="Alert Proximity % (from level)") // === Utility Functions === // // Identify key levels for a specific timeframe f_getLevels(tf, sens, minTouches) => var float[] levels = array.new_float(0) var int[] touches = array.new_int(0) srcHigh = request.security(syminfo.tickerid, tf, high) srcLow = request.security(syminfo.tickerid, tf, low) srcClose = request.security(syminfo.tickerid, tf, close) // Detect significant swing highs and lows for i = 1 to 200 if (high[i] == ta.highest(high, sens)) level = high[i] index = array.indexof(levels, level) if (index != -1) array.set(touches, index, array.get(touches, index) + 1) else array.push(levels, level) array.push(touches, 1) if (low[i] == ta.lowest(low, sens)) level = low[i] index = array.indexof(levels, level) if (index != -1) array.set(touches, index, array.get(touches, index) + 1) else array.push(levels, level) array.push(touches, 1) // Filter levels with sufficient touches var float[] validLevels = array.new_float(0) for i = 0 to array.size(levels) - 1 if array.get(touches, i) >= minTouches array.push(validLevels, array.get(levels, i)) // Sort levels and return the strongest ones array.sort(validLevels, order.ascending) resultLevels = array.slice(validLevels, 0, math.min(array.size(validLevels), numLevels)) resultLevels // === Get Levels for Each Timeframe === // levelsTF1 = f_getLevels(tf1, sensitivity, levelTouches) levelsTF2 = f_getLevels(tf2, sensitivity, levelTouches) levelsTF3 = f_getLevels(tf3, sensitivity, levelTouches) // === Plot Levels === // f_plotLevels(levels, color, style) => for i = 0 to array.size(levels) - 1 level = array.get(levels, i) line.new(bar_index - 1, level, bar_index, level, color=color, style=style, width=1, extend=extend.right) // Plot levels for each timeframe f_plotLevels(levelsTF1, colorTF1, lineStyleTF1) f_plotLevels(levelsTF2, colorTF2, lineStyleTF2) f_plotLevels(levelsTF3, colorTF3, lineStyleTF3) // === Alerts === // f_checkAlerts(levels, tfName) => for i = 0 to array.size(levels) - 1 level = array.get(levels, i) proximity = level * (alertProximity / 100) if math.abs(close - level) <= proximity alert("Price is near a " + tfName + " level: " + str.tostring(level, "#.##"), alert.freq_once_per_bar) f_checkAlerts(levelsTF1, "1H") f_checkAlerts(levelsTF2, "4H") f_checkAlerts(levelsTF3, "Daily") // === Labels for Guidance === // label.new(bar_index, na, "Key Levels for Support and Resistance:\n1H: Blue, 4H: Orange, Daily: Red", style=label.style_label_lower_left, color=color.gray, textcolor=color.white, size=size.normal) ``` --- ### **Script Explanation** 1. **Configurable Timeframes**: - Users can define 1-hour (`60`), 4-hour (`240`), and daily (`D`) timeframes. 2. **Level Detection Logic**: - **Swing Highs**: A local high that is the highest over a given sensitivity period. - **Swing Lows**: A local low that is the lowest over the sensitivity period. - **Minimum Touch Filtering**: Levels must have a certain number of touches (`levelTouches`) to qualify as valid. 3. **Display**: - Each timeframe uses a different color and line style: - **1H**: Solid blue lines. - **4H**: Dashed orange lines. - **Daily**: Dotted red lines. - Levels are dynamically extended to the right of the chart. 4. **Alerts**: - Alerts trigger when the current price is within a user-defined percentage (`alertProximity`) of a support/resistance level. 5. **Customizable Sensitivity**: - Lower sensitivity creates more levels, while higher sensitivity simplifies level detection. 6. **Clear Comments**: - The code is well-documented, ensuring users can easily modify logic or add features. 7. **Performance Optimization**: - The script only analyzes the most recent 200 candles for level detection to improve efficiency. --- ### **How to Use**: 1. Copy the script and paste it into a **new Pine Script editor** in TradingView. 2. Save and add the indicator to your chart. 3. Customize the timeframes, sensitivity, and other parameters from the indicator settings. 4. Enable **alerts** to be notified when the price nears a support or resistance level. --- ### **Key Benefits for Traders**: - **Multi-Timeframe Clarity**: See significant support/resistance zones from multiple timeframes on a single chart. - **Customizability**: Adjust sensitivity, line styles, and number of levels to suit your strategy. - **Alerts**: Receive timely notifications to anticipate potential reversals or breakouts. - **Efficiency**: Filters out weaker levels, focusing on significant zones that are actionable. This tool empowers swing traders to analyze price action across multiple timeframes and make informed trading decisions.
Browse Marketplace