Pivot Points Level [TradingFinder] 4 Methods + Reversal lines

TradingFinder · study · 160 行 · 点赞 884 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TFlab
 
//@version=5
indicator("Pivot Points Level [TradingFinder] 4 Methods + Reversal lines", "Pivot Point TFlab" ,overlay = true, max_bars_back = 5000, max_lines_count = 500, max_labels_count = 500)
 
 
 
//Input
PPType = input.string('Floor', 'Pivot Point Type', ['Floor', 'Woodie', 'Camarilla', 'Fibonacci'], inline = 'PP', group = 'Pivot Point Types')
Color = input.color(#1848cc, '', inline = 'PP', group = 'Pivot Point Types')
 
 
 
 
//Variables
 
var line R4Line = na
var line R3Line = na
var line R2Line = na
var line R1Line = na
var line PPLine = na
var line S1Line = na
var line S2Line = na
var line S3Line = na
var line S4Line = na
 
 
var label R4Label = na
var label R3Label = na
var label R2Label = na
var label R1Label = na
var label PPLabel = na
var label S1Label = na
var label S2Label = na
var label S3Label = na
var label S4Label = na
//get data 
 
 
//Pivot Point Function
PivotPoint (PPType) =>
 
    var float O = 0.0
    var float H = 0.0
    var float L = 0.0
    var float C = 0.0
 
    var float R4 = 0.0
    var float R3 = 0.0
    var float R2 = 0.0
    var float R1 = 0.0
    var float PP = 0.0
    var float S1 = 0.0
    var float S2 = 0.0
    var float S3 = 0.0
    var float S4 = 0.0
 
 
    if minute(time_close('1D', syminfo.timezone))  == minute(time, syminfo.timezone)
        O := open[0]
        H := high[0]
        L := low[0]
        C := close[0]
 
    if PPType == 'Floor'
        PP := (H + L + C) / 3
        R1 := (2 * PP) - L
        R2 := PP + H - L
        R3 := H + (2 * (PP - L))
        S1 := (2 * PP) - H
        S2 := PP - H + L
        S3 := L - (2 * (H - PP))
 
    if PPType == 'Woodie'
        PP := (H + L + 2 * C) / 4
        R1 := (2 * PP) - L
        R2 := PP + H - L
        S1 := (2 * PP) - H
        S2 := PP - H + L
 
    if PPType == 'Camarilla'
        PP := (H + L + C) / 3
        R4 := (((H - L) * 1.1) / 2) + C
        R3 := (((H - L) * 1.1) / 4) + C
        R2 := (((H - L) * 1.1) / 6) + C
        R1 := (((H - L) * 1.1) / 12) + C
        S1 := C - (((H - L) * 1.1) / 12)
        S2 := C - (((H - L) * 1.1) / 6)
        S3 := C - (((H - L) * 1.1) / 4)
        S4 := C - (((H - L) * 1.1) / 2)
 
 
    if PPType == "Fibonacci" 
        PP := (H + L + C) / 3
        R3 := PP + ((H - L) * 1.000)
        R2 := PP + ((H - L) * 0.618)
        R1 := PP + ((H - L) * 0.382)
        S1 := PP - ((H - L) * 0.382)
        S2 := PP - ((H - L) * 0.618)
        S3 := PP - ((H - L) * 1.000)
    [PP,R1,R2,R3,R4,S1,S2,S3,S4,O,H,L,C]
 
 
 
//Call PP Function
[PP,R1,R2,R3,R4,S1,S2,S3,S4,O,H,L,C] = request.security(syminfo.tickerid, '1D', PivotPoint (PPType))
 
 
 
//Drawing Lines
if PP > 0 and ta.change(dayofweek)
    if R4 > 0 
        R4Line := line.new( bar_index, R4, bar_index, R4, style = line.style_dashed , color = Color)
        R4Label:= label.new(bar_index , R4   , 'R4', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal) 
    if R3 > 0 
        R3Line := line.new(bar_index, R3, bar_index, R3, style = line.style_dotted , color = Color) 
        R3Label:= label.new(bar_index , R3   , 'R3', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
    if R2 > 0
        R2Line := line.new(bar_index, R2, bar_index, R2, style = line.style_dashed , color = Color)
        R2Label:= label.new(bar_index , R2   , 'R2', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal) 
    if R1 > 0
        R1Line := line.new(bar_index, R1, bar_index, R1, style = line.style_dotted , color = Color) 
        R1Label:= label.new(bar_index , R1   , 'R1', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
    if PPType != "Camarilla"
        PPLine := line.new(bar_index, PP, bar_index, PP, style = line.style_solid , color = Color) 
        PPLabel:= label.new(bar_index , PP   , 'PP', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
    if S1 > 0
        S1Line := line.new(bar_index, S1, bar_index, S1, style = line.style_dotted , color = Color) 
        S1Label:= label.new(bar_index , S1   , 'S1', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
    if S2 > 0
        S2Line := line.new(bar_index, S2, bar_index, S2, style = line.style_dashed , color = Color) 
        S2Label:= label.new(bar_index , S2   , 'S2', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
    if S3 > 0
        S3Line := line.new(bar_index, S3, bar_index, S3, style = line.style_dotted , color = Color) 
        S3Label:= label.new(bar_index , S3   , 'S3', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
    if S4 > 0
        S4Line := line.new(bar_index, S4, bar_index, S4, style = line.style_dashed , color = Color) 
        S4Label:= label.new(bar_index , S4   , 'S4', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
 
if  not (minute(time_close('1D', syminfo.timezone))  == minute(time, syminfo.timezone))
    R4Line.set_x2(bar_index)
    R3Line.set_x2(bar_index)
    R2Line.set_x2(bar_index)
    R1Line.set_x2(bar_index)
    PPLine.set_x2(bar_index)
    S1Line.set_x2(bar_index)
    S2Line.set_x2(bar_index)
    S3Line.set_x2(bar_index)
    S4Line.set_x2(bar_index)
 
    R4Label.set_x(bar_index)
    R3Label.set_x(bar_index)
    R2Label.set_x(bar_index)
    R1Label.set_x(bar_index)
    PPLabel.set_x(bar_index)
    S1Label.set_x(bar_index)
    S2Label.set_x(bar_index)
    S3Label.set_x(bar_index)
    S4Label.set_x(bar_index)

← 返回列表