FIRST 15 SWEEP + VOL 1.6 + CISD - FIXED V4 SANJEEV

ANS987 · study · 89 行 · 点赞 632 · TradingView 原页

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

Pine Script

// @version=6
indicator("FIRST 15 SWEEP + VOL 1.6 + CISD - FIXED V4", overlay=true, max_lines_count=500, max_labels_count=500, max_bars_back=500)
 
rr1=input.float(2.0,"T1 RR")
rr2=input.float(4.0,"T2 RR")
rr3=input.float(6.0,"T3 RR")
vMult=input.float(1.6,"Vol Mult",1.0,3.0,0.1)
useVol=input.bool(false,"Use Vol Filter?")
 
var float fH=na
var float fL=na
var bool fCap=false
 
// FIXED LINE - THIS WAS THE ERROR
isNewDay = ta.change(time("D"))!= 0
 
inFirst15=false
if hour==9 and minute>=15 and minute<30
    inFirst15:=true
 
if isNewDay
    fH:=na
    fL:=na
    fCap:=false
 
if inFirst15
    if na(fH)
        fH:=high
        fL:=low
    else
        fH:=math.max(fH,high)
        fL:=math.min(fL,low)
else if inFirst15[1]
    fCap:=true
 
plot(fCap?fH:na,"F15 HIGH",color=color.orange,linewidth=3,style=plot.style_linebr)
plot(fCap?fL:na,"F15 LOW",color=color.orange,linewidth=3,style=plot.style_linebr)
bgcolor(inFirst15?color.new(color.orange,80):na)
 
after=fCap and not inFirst15
vAvg=ta.sma(volume,20)
volOk=volume>vAvg*vMult
 
bullRaw=after and close[1]<fL and close>fL
bearRaw=after and close[1]>fH and close<fH
 
bullSig=bullRaw and (useVol?volOk:true)
bearSig=bearRaw and (useVol?volOk:true)
 
var line eLine=na
var line slLine=na
var line t1Line=na
var line t2Line=na
var line t3Line=na
 
if bullSig or bearSig
    line.delete(eLine)
    line.delete(slLine)
    line.delete(t1Line)
    line.delete(t2Line)
    line.delete(t3Line)
    float entry=close
    float sl=na
    float t1=na
    float t2=na
    float t3=na
    float risk=na
    if bullSig
        sl:=low
        risk:=entry-sl
        t1:=entry+risk*rr1
        t2:=entry+risk*rr2
        t3:=entry+risk*rr3
        eLine:=line.new(bar_index,entry,bar_index+1,entry,color=color.green,width=3,extend=extend.right)
        slLine:=line.new(bar_index,sl,bar_index+1,sl,color=color.red,width=2,style=line.style_dashed,extend=extend.right)
    else
        sl:=high
        risk:=sl-entry
        t1:=entry-risk*rr1
        t2:=entry-risk*rr2
        t3:=entry-risk*rr3
        eLine:=line.new(bar_index,entry,bar_index+1,entry,color=color.red,width=3,extend=extend.right)
        slLine:=line.new(bar_index,sl,bar_index+1,sl,color=color.red,width=2,style=line.style_dashed,extend=extend.right)
    t1Line:=line.new(bar_index,t1,bar_index+1,t1,color=color.green,width=2,extend=extend.right)
    t2Line:=line.new(bar_index,t2,bar_index+1,t2,color=color.green,width=2,extend=extend.right)
    t3Line:=line.new(bar_index,t3,bar_index+1,t3,color=color.green,width=3,extend=extend.right)
 
plotshape(bullSig,style=shape.triangleup,location=location.belowbar,color=color.green,size=size.large,text="LONG")
plotshape(bearSig,style=shape.triangledown,location=location.abovebar,color=color.red,size=size.large,text="SHORT")

← 返回列表