-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathTidal Wave 1.5.txt
121 lines (94 loc) · 4.31 KB
/
Tidal Wave 1.5.txt
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//@version=5
indicator(title="Tidal Wave", shorttitle="Tidal Wave v1", overlay=true, max_bars_back=1000, max_labels_count=500, max_lines_count=500)
bShowII = input.bool(false, "Show ii pattern")
bShowIOI = input.bool(false, "Show iOi pattern")
trendMarker = input.bool(false, "Show UpTrend markers")
UseSession = input.bool(false, "Only show during NY session")
tradeTimes = input.session("0830-1500", title="Trading Times")
InSession(sessionTimes) =>
not na(time(timeframe.period, sessionTimes))
bool iss = InSession(tradeTimes)
if (not UseSession)
iss := true
isInside() =>
bodyStatus = (close >= open) ? 1 : -1
isInsidePattern = high < high[1] and low > low[1]
isInsidePattern ? bodyStatus : 0
isOutside() =>
bodyStatus = (close >= open) ? 1 : -1
isOutsidePattern = low < low[1] and high > high[1]
isOutsidePattern ? bodyStatus : 0
const int upTrend = 1
const int downTrend = 2
colorRed = color.rgb(255, 0, 0)
colorGreen = color.rgb(0, 255, 132)
var int waveState = na
var float prevRedLow = 9999999
var float prevGreenHigh = 0
bool bFirstGreenCandleFound = false
bool bFirstRedCandleFound = false
redCandle = close < open
greenCandle = close > open
noOverlapRed = false
noOverlapGreen = false
brightGreen = false
brightRed = false
if (iss and greenCandle and open > close[1] and greenCandle[1])
noOverlapGreen := true
waveState := upTrend
if (iss and redCandle and open > close[1] and redCandle[1])
noOverlapRed := true
waveState := downTrend
if (iss and greenCandle)
for i = 1 to 200
if (brightRed[i]) // if bright red candle, stop
break
else if (waveState==upTrend and redCandle[i]) // if we're in a uptrend, and the candle is red, stop
break
else if (waveState==downTrend and open > close[i] and greenCandle[i])
noOverlapGreen := true
waveState := upTrend
bFirstGreenCandleFound := true
break
if (iss and redCandle)
for i = 1 to 200
if (brightGreen[i]) // if bright green candle, stop
break
else if (waveState==downTrend and greenCandle[i]) // if we're in a downtrend, and the candle is green, stop
break
else if (waveState==upTrend and open < close[i] and redCandle[i])
noOverlapRed := true
waveState := downTrend
bFirstRedCandleFound := true
break
barcolor(iss and noOverlapRed ? colorRed : iss and noOverlapGreen ? colorGreen : na)
if (iss and noOverlapGreen)
brightGreen := true
if (iss and noOverlapRed)
brightRed := true
//plotshape(bFirstGreenCandleFound and brightGreen ? 1 : na, style=shape.square, location = location.belowbar, color=color.yellow)
//plotshape(bFirstRedCandleFound and brightRed ? 1 : na, style=shape.square, location = location.abovebar, color=color.yellow)
plotchar(trendMarker and waveState==upTrend ? 1 : na, char="^", location = location.abovebar)
InsideBar = isInside()
OutsideBar = isOutside()
plotchar(bShowII and InsideBar and InsideBar[1] ? 1 : na, char="⛄", location = location.abovebar, color=color.white, size=size.small)
plotchar(bShowIOI and InsideBar and OutsideBar[1] and InsideBar[2] ? 1 : na, char="⌛", location = location.abovebar, color=color.white, size=size.tiny)
//swing_high = ta.highest(20)
//swing_low = ta.lowest(20)
//high_when_swing_high = ta.valuewhen(swing_high > swing_high[1], high, 0)
//low_when_swing_high = ta.valuewhen(swing_high > swing_high[1], low, 0)
//_bar_index_swing_high = ta.valuewhen(swing_high > swing_high[1], bar_index, 0)
//is_swing_high_found = close < low_when_swing_high ? 1 : 0
//swing_high_bar_diff = if(is_swing_high_found)
//-1 * (bar_index - _bar_index_swing_high)
//line.new(bar_index+swing_high_bar_diff-1, high_when_swing_high, bar_index+swing_high_bar_diff+1, high_when_swing_high, color=colorGreen, style=line.style_arrow_both)
// label.new(bar_index+swing_high_bar_diff, high_when_swing_high, text="Wave", color=color.blue, textcolor=color.yellow)
// Store current candle high/low
//if (redCandle and not bFirstRedCandleFound and waveState == upTrend)
// prevRedLow := close
// bFirstRedCandleFound := true
// if (redCandle and close > prevRedLow) // and waveState==downTrend)
//bFirstRedCandleFound := true
// prevRedLow := close
//if (greenCandle and close < prevGreenHigh)
// prevGreenHigh := close