PINE LIBRARY
tp_sl_styling_lib

TP/SL Styling Library
A professional-grade library for creating highly customizable trade management visualizations with extensive styling options and multiple display versions. Perfect for indicators and strategies that require consistent, professional-looking trade level drawings.
Key Features - Extensive Styling Options
Multiple Visual Styles
Comprehensive Customization
Professional Features
What Makes This Library Unique
Unlike basic drawing functions, this library provides:
Usage Example
Pine Script®
Main Functions
Core Drawing Functions
Data Types
Perfect For
Pro Tips
Version Comparison
Label Positions:
Directional Indicators:
Tooltips:
Bar-Level Markers:
Memory Efficiency:
Note: This library is designed for professional use and provides extensive customization options. Choose the version that best fits your visual style and requirements.
Main Functions:
shrink_lines(version, start_idx, min_bars_label_length, drawings)
Parameters:
version (int)
start_idx (int)
min_bars_label_length (int)
drawings (tradeDrawingsUnion)
draw_bad_rrr(version, ep, rrr, min_bars_label_length, ep_thickness, ep_color)
Parameters:
version (int)
ep (float)
rrr (float)
min_bars_label_length (int)
ep_thickness (int)
ep_color (color)
remove_trade_drawings(version, drawings)
Parameters:
version (int)
drawings (tradeDrawingsUnion)
remove_trade_drawings_labels(version, drawings)
Parameters:
version (int)
drawings (tradeDrawingsUnion)
draw_trade_tp_sl(version, direction, ep, tp1, tp2, tp3, sl, rrr, tp1_perc, tp2_perc, tp3_perc, sizeInfo, patternStartBarIdx, tp_sl_line_length, show_tp1, show_tp2, show_tp3, show_sl, show_ep, show_size_info, tp_sl_label_pos, tp_sl_price_pos, tp_sl_rrr_pos, tp_sl_perc_pos, tp_sl_qty_pos, tp1_style, tp2_style, tp3_style, sl_style, ep_style, tp1_thickness, tp2_thickness, tp3_thickness, sl_thickness, ep_thickness, tp1_color, tp2_color, tp3_color, sl_color, ep_color, buy_color, sell_color)
Parameters:
version (int)
direction (int)
ep (float)
tp1 (float)
tp2 (float)
tp3 (float)
sl (float)
rrr (float)
tp1_perc (float)
tp2_perc (float)
tp3_perc (float)
sizeInfo (string)
patternStartBarIdx (int)
tp_sl_line_length (int)
show_tp1 (bool)
show_tp2 (bool)
show_tp3 (bool)
show_sl (bool)
show_ep (bool)
show_size_info (bool)
tp_sl_label_pos (string)
tp_sl_price_pos (string)
tp_sl_rrr_pos (string)
tp_sl_perc_pos (string)
tp_sl_qty_pos (string)
tp1_style (string)
tp2_style (string)
tp3_style (string)
sl_style (string)
ep_style (string)
tp1_thickness (int)
tp2_thickness (int)
tp3_thickness (int)
sl_thickness (int)
ep_thickness (int)
tp1_color (color)
tp2_color (color)
tp3_color (color)
sl_color (color)
ep_color (color)
buy_color (color)
sell_color (color)
A professional-grade library for creating highly customizable trade management visualizations with extensive styling options and multiple display versions. Perfect for indicators and strategies that require consistent, professional-looking trade level drawings.
Key Features - Extensive Styling Options
Multiple Visual Styles
- Version 1: Traditional multi-label style with left/center/right positioning
- Version 2: Modern streamlined style with single-side labels and tooltips
- Version 3: Advanced style with directional arrows (▲/▼) and bar-level indicators
Comprehensive Customization
- Line Styles: Solid, Dashed, Dotted for all levels
- Line Thickness: Individual thickness control for each level
- Color Schemes: Separate colors for TP1, TP2, TP3, SL, Entry, Buy/Sell signals
- Label Positioning: Flexible left/center/right positioning for all information
- Information Display: Configurable display of prices, R:R ratios, percentages, and position sizes
Professional Features
- Memory Management: Proper cleanup functions prevent memory leaks
- Dynamic Line Adjustment: Automatic line length adjustment based on chart view
- Tooltip Integration: Hover information for all trade levels
- Bad R/R Detection: Special visualization for poor risk/reward scenarios
What Makes This Library Unique
Unlike basic drawing functions, this library provides:
- 3 Different Visual Styles to match any trading strategy aesthetic
- Granular Control over every visual element (colors, styles, thickness, positioning)
- Professional Consistency across all your indicators and strategies
- Memory-Efficient design with proper cleanup methods
- Future-Proof architecture with version-based feature progression
Usage Example
//@version=5
indicator("My Strategy")
import bilsebub/tp_sl_drawing_lib/1 as tpsl
// Choose your preferred visual style
var VERSION = input.int(3, "Drawing Style", minval=1, maxval=3, options=["Traditional", "Modern", "Advanced"])
// Extensive styling options
var TP1_STYLE = input.string("Solid", "TP1 Line Style", options=["Solid", "Dashed", "Dotted"])
var TP1_THICKNESS = input.int(2, "TP1 Thickness", minval=1, maxval=5)
var TP1_COLOR = input.color(color.green, "TP1 Color")
var LABEL_POS = input.string("Right", "Label Position", options=["Left", "Center", "Right"])
var SHOW_PRICES = input.bool(true, "Show Prices")
var SHOW_RR = input.bool(true, "Show Risk/Reward")
// Create professional trade drawings
var drawings = tpsl.tradeDrawingsUnion.new()
if entrySignal
tpsl.remove_trade_drawings(VERSION, drawings)
drawings := tpsl.draw_trade_tp_sl(
version=VERSION,
direction=1, // 1 for buy, -1 for sell
ep=entry_price,
tp1=take_profit1,
tp2=take_profit2,
tp3=take_profit3,
sl=stop_loss,
rrr=risk_reward_ratio,
show_tp1=true,
show_tp2=true,
show_tp3=false,
show_sl=true,
show_ep=true,
tp_sl_label_pos=LABEL_POS,
tp_sl_price_pos=SHOW_PRICES ? LABEL_POS : "None",
tp_sl_rrr_pos=SHOW_RR ? LABEL_POS : "None",
tp1_style=TP1_STYLE,
tp1_thickness=TP1_THICKNESS,
tp1_color=TP1_COLOR
// ... additional styling parameters
)
Main Functions
Core Drawing Functions
- draw_trade_tp_sl() - Create complete trade visualization with all styling options
- draw_bad_rrr() - Special visualization for poor risk/reward scenarios
- remove_trade_drawings() - Clean up all drawings to prevent memory issues
- remove_trade_drawings_labels() - Remove only labels while keeping lines
- shrink_lines() - Dynamically adjust line lengths based on chart view
Data Types
- tradeDrawingsV1 - Traditional multi-label style
- tradeDrawingsV2 - Modern streamlined style
- tradeDrawingsV3 - Advanced style with directional indicators
- tradeDrawingsUnion - Unified interface for all versions
Perfect For
- Professional Indicators requiring consistent trade visualization
- Trading Strategies with multiple take profit levels
- Educational Content with clear trade management displays
- Algorithmic Trading systems needing reliable drawing functions
- Custom Indicators requiring extensive styling flexibility
Pro Tips
- Choose the Right Version: V1 for detailed info, V2 for clean look, V3 for modern style
- Memory Management: Always call remove_trade_drawings() before creating new ones
- Styling Consistency: Use the same color scheme across all your indicators
- Performance: Use shrink_lines() for dynamic line adjustment on large charts
Version Comparison
Label Positions:
- V1 (Traditional): Left/Center/Right positioning available
- V2 (Modern): Right-side positioning only
- V3 (Advanced): Right-side + Bar-level positioning
Directional Indicators:
- V1 (Traditional): ❌ Not available
- V2 (Modern): ❌ Not available
- V3 (Advanced): ✅ Available (▲/▼ arrows)
Tooltips:
- V1 (Traditional): ❌ Not available
- V2 (Modern): ✅ Available
- V3 (Advanced): ✅ Available
Bar-Level Markers:
- V1 (Traditional): ❌ Not available
- V2 (Modern): ❌ Not available
- V3 (Advanced): ✅ Available
Memory Efficiency:
- V1 (Traditional): Good
- V2 (Modern): Better
- V3 (Advanced): Best
Note: This library is designed for professional use and provides extensive customization options. Choose the version that best fits your visual style and requirements.
Main Functions:
shrink_lines(version, start_idx, min_bars_label_length, drawings)
Parameters:
version (int)
start_idx (int)
min_bars_label_length (int)
drawings (tradeDrawingsUnion)
draw_bad_rrr(version, ep, rrr, min_bars_label_length, ep_thickness, ep_color)
Parameters:
version (int)
ep (float)
rrr (float)
min_bars_label_length (int)
ep_thickness (int)
ep_color (color)
remove_trade_drawings(version, drawings)
Parameters:
version (int)
drawings (tradeDrawingsUnion)
remove_trade_drawings_labels(version, drawings)
Parameters:
version (int)
drawings (tradeDrawingsUnion)
draw_trade_tp_sl(version, direction, ep, tp1, tp2, tp3, sl, rrr, tp1_perc, tp2_perc, tp3_perc, sizeInfo, patternStartBarIdx, tp_sl_line_length, show_tp1, show_tp2, show_tp3, show_sl, show_ep, show_size_info, tp_sl_label_pos, tp_sl_price_pos, tp_sl_rrr_pos, tp_sl_perc_pos, tp_sl_qty_pos, tp1_style, tp2_style, tp3_style, sl_style, ep_style, tp1_thickness, tp2_thickness, tp3_thickness, sl_thickness, ep_thickness, tp1_color, tp2_color, tp3_color, sl_color, ep_color, buy_color, sell_color)
Parameters:
version (int)
direction (int)
ep (float)
tp1 (float)
tp2 (float)
tp3 (float)
sl (float)
rrr (float)
tp1_perc (float)
tp2_perc (float)
tp3_perc (float)
sizeInfo (string)
patternStartBarIdx (int)
tp_sl_line_length (int)
show_tp1 (bool)
show_tp2 (bool)
show_tp3 (bool)
show_sl (bool)
show_ep (bool)
show_size_info (bool)
tp_sl_label_pos (string)
tp_sl_price_pos (string)
tp_sl_rrr_pos (string)
tp_sl_perc_pos (string)
tp_sl_qty_pos (string)
tp1_style (string)
tp2_style (string)
tp3_style (string)
sl_style (string)
ep_style (string)
tp1_thickness (int)
tp2_thickness (int)
tp3_thickness (int)
sl_thickness (int)
ep_thickness (int)
tp1_color (color)
tp2_color (color)
tp3_color (color)
sl_color (color)
ep_color (color)
buy_color (color)
sell_color (color)
Pine kitaplığı
Gerçek TradingView ruhuyla, yazar bu Pine kodunu açık kaynaklı bir kütüphane olarak yayınladı, böylece topluluğumuzdaki diğer Pine programcıları onu yeniden kullanabilir. Yazara saygı! Bu kütüphaneyi özel olarak veya diğer açık kaynaklı yayınlarda kullanabilirsiniz, ancak bu kodun bir yayında yeniden kullanımı Site Kuralları tarafından yönetilmektedir.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Pine kitaplığı
Gerçek TradingView ruhuyla, yazar bu Pine kodunu açık kaynaklı bir kütüphane olarak yayınladı, böylece topluluğumuzdaki diğer Pine programcıları onu yeniden kullanabilir. Yazara saygı! Bu kütüphaneyi özel olarak veya diğer açık kaynaklı yayınlarda kullanabilirsiniz, ancak bu kodun bir yayında yeniden kullanımı Site Kuralları tarafından yönetilmektedir.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.