Reversal Points

Enes_Yetkin_ · study · 68 行 · 点赞 2,950 · TradingView 原页

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

Pine Script

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © enesyetkin
 
//@version=5
indicator('Reversal Points', overlay=true)
 
newHighSensitivity = input.int(defval=50, title='New Low Sensitivity', minval=1)
 
Periods = input(title='ATR Period', defval=10)
src = input(hl2, title='Source')
Multiplier = input.float(title='ATR Multiplier', step=0.1, defval=2.0)
changeATR = input(title='Change ATR Calculation Method ?', defval=true)
 
 
Supertrend(src, Multiplier, Periods,changeATR) =>
 
    atr2 = ta.sma(ta.tr, Periods)
    atr = changeATR ? ta.atr(Periods) : atr2
    up = src - Multiplier * atr
    up1 = nz(up[1], up)
    up := close[1] > up1 ? math.max(up, up1) : up
    dn = src + Multiplier * atr
    dn1 = nz(dn[1], dn)
    dn := close[1] < dn1 ? math.min(dn, dn1) : dn
    trend = 1
    trend := nz(trend[1], trend)
    trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
 
 
    [trend, up,dn]
 
[trend, up,dn] = Supertrend(src, Multiplier, Periods,changeATR)
 
 
 
 
//upPlot = plot(trend == 1 ? up : na, title='Up Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.green, 0))
buySignal = trend == 1 and trend[1] == -1
//dnPlot = plot(trend == 1 ? na : dn, title='Down Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.red, 0))
sellSignal = trend == -1 and trend[1] == 1
 
 
 
var newHighCondition = 0
 
higher = ta.highest(newHighSensitivity)
 
 
if higher == higher[newHighSensitivity / 10]
    newHighCondition := 0
    newHighCondition
//    lowerLevel:=0.0
if higher != higher[newHighSensitivity / 10] and close > higher[newHighSensitivity / 10]
    newHighCondition := 1
    newHighCondition
 
 
HighColor = newHighCondition == 0 ? color.orange : na
 
topswitch = 0
topswitch :=  sellSignal ? 0 : (not newHighCondition == 0) and trend == 1  ? 1  : topswitch[1]
 
reversalsignal = topswitch[1] == 1 and topswitch == 0 ? true : false
 
plotshape(reversalsignal, title='Sell', text='Sell', location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 0))
 
 
//plot(higher, color=HighColor)

← 返回列表