-
Notifications
You must be signed in to change notification settings - Fork 14
/
CandlestickInsideBar.pine
30 lines (22 loc) · 1.77 KB
/
CandlestickInsideBar.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
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © FxCloudTrader
//@version=5
// This is a 3-bar formation setup
// The range of -1 bar is capped within the -2 bar's
// The direction of current bar dictates the direction of the signal
indicator(title="Candlestick - Inside Bar Pattern", shorttitle="Inside Bar", overlay=true, precision = 0)
getRange(x, y) => math.abs(x - y)
bool enableInsideBar = input.bool(true, '2. Enable Inside Bar signal')
int minimumCloseTriggerCandle = input.int(50, "Minimum Pencentage of Close of Price Candle Range", step = 5)// The default is 50%, meaning the closing price needs to be above 50% of its price range for a bullish candle
range_bar_2 = getRange(high[2], low[2])
range_bar_1 = getRange(high[1], low[1])
bool insbar_cond_up = low[2] < low[1] and high[2] > high[1] and close > open //and close >= hl2
bool insbar_cond_dn = low[2] < low[1] and high[2] > high[1] and close < open //and close <= hl2
bool weakUp = close < hl2
bool weakDn = close > hl2
// if insbar_cond_up and weakUp
// label.new(bar_index, na, "Weak", yloc = yloc.belowbar, style = label.style_none, textcolor = color.red, size = size.normal)
// if insbar_cond_dn and weakDn
// label.new(bar_index, na, "Weak", yloc = yloc.abovebar, style = label.style_none, textcolor = color.red, size = size.normal)
plotshape(insbar_cond_up, "Inside Bar Bullish", shape.cross, location.belowbar, color = color.new(weakUp?color.yellow:color.black, 50), size = size.auto, display = enableInsideBar?display.all:display.data_window)
plotshape(insbar_cond_dn, "Inside Bar Bearish", shape.cross, location.abovebar, color = color.new(weakDn?color.yellow:color.black, 50), size = size.auto, display = enableInsideBar?display.all:display.data_window)