-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnum3.pine
42 lines (32 loc) · 2.39 KB
/
num3.pine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//@version=2
study(title="be_mill", shorttitle="be_mill", overlay=true)
myLineToggle = input(defval=true, type=bool, title="Line1")
myLineToggle2 = input(defval=false, type=bool, title="Line2")
myPeriod = input(defval=7, type=integer, title="Period")
myRSI=rsi(close, myPeriod)
myThresholdDn = input(defval=25, type=float, title="Lower Threshold1")
myThresholdDn2 = input(defval=10, type=float, title="Lower Threshold2")
myThresholdUp = input(defval=75, type=float, title="Higher Threshold")
s100sma = sma(close, 7)
s200sma = sma(close, 25)
plot(myLineToggle2 ? s100sma : na, color = green, linewidth = 1)
plot(myLineToggle2 ? s200sma : na, color = blue, linewidth = 1)
//plot(s200sma-s100sma, color=green, style=area, transp=80)
//plot(cross(s100sma, s200sma) ? btc : na, color = black , style = circles, linewidth = 10)
//plot(cross(s100sma, s200sma) ? btc : na, color = (s200sma - s100sma > 0 ? white : lime) , style = circles, linewidth = 10)
buy1 = (falling(s100sma,300) and cross(myRSI, myThresholdDn) and (myRSI < myThresholdDn) )
buy2 = (falling(s100sma,900) and (myRSI < myThresholdDn2) and falling(myRSI,340) )
buy3 = (falling(myRSI,170) and (myRSI < 20) and myPosition[1]==0 and 0 )
buy = ( buy1 or buy2 or buy3 )
sell = (rising(s100sma,100) and (myRSI > myThresholdUp))
plotshape( buy1 ? close : na , style=shape.labelup, location=location.absolute, text= "1buy" , transp=0, textcolor = white, color=green, editable=false)
plotshape( buy2 ? close : na , style=shape.labelup, location=location.absolute, text= "2buy" , transp=0, textcolor = white, color=green, editable=false)
plotshape( buy3 ? close : na , style=shape.labelup, location=location.absolute, text= "3buy" , transp=0, textcolor = white, color=green, editable=false)
plotshape( sell and myPosition[1]==0 ? high : na , style=shape.labeldown, location=location.absolute , text= "Sell" , transp=0, textcolor = white, color=red, editable=false)
//strategy.entry("long", strategy.long, when = buy)
//strategy.exit("XS", from_entry = "short", when = sell and myPosition[1]==0)
alertcondition(buy, "Buy!!", "bbbb")
alertcondition(sell and myPosition[1]==0, "Sell!!", "ssss")
myPosition = buy==1 ? 0 : sell==1 or myPosition[1]==1 ? 1 : 0
trendColor = buy ? color(red,100) : sell ? green : na
plot(myLineToggle ? buy and myPosition[1]==1 ? close - 0.004: sell and myPosition[1]==0 ? close + 0.004 : na : na, color=trendColor, style=line, linewidth=4, editable=false)