-
Notifications
You must be signed in to change notification settings - Fork 0
/
Inside_Candle_Detector.pine
30 lines (20 loc) · 1.17 KB
/
Inside_Candle_Detector.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
//Run the following Script on PINE EDITOR or any platform supporting Pine Script
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © might-tree
//@version=5
strategy("Inside Candle Detector", overlay=true, margin_long=100, margin_short=100)
increasingbar = 1
decreasingbar = -1
check_inside_candle() =>
previousBar = 1
bodyStatus = (close >= open) ? 1 : -1
isInsidePattern = high < high[previousBar] and low > low[previousBar]
isInsidePattern ? bodyStatus : 0
barcolor(check_inside_candle() == increasingbar ? color.rgb(40, 253, 47) : na)
barcolor(check_inside_candle() == decreasingbar ? color.rgb(253, 117, 117) : na)
plotshape(check_inside_candle() == increasingbar, style=shape.triangleup,
location=location.abovebar, color=color.rgb(37, 255, 44))
plotshape(check_inside_candle() == decreasingbar, style=shape.triangledown,
location=location.belowbar, color=color.rgb(251, 121, 121))
is_inside_candle = check_inside_candle() == increasingbar or check_inside_candle() == decreasingbar
alertcondition(is_inside_candle, title='Inside Candle', message='Inside Candle detected')