├── README.md ├── thms: EMAs combined └── NF: fakey + MB break /README.md: -------------------------------------------------------------------------------- 1 | # TradingView scripts 2 | 3 | ## NF: fakey + MB-break 4 | Indicator for fakey and mother bar (MB) break setups 5 | 6 | ## thms: EMAs combined 7 | Exponential Moving Average (EMA) indicators on multi-timeframe 8 | -------------------------------------------------------------------------------- /thms: EMAs combined: -------------------------------------------------------------------------------- 1 | // Created by @thmstm (https://www.tradingview.com/u/thms/) October 13, 2017 2 | // Inspired by a concept by Nial Fuller (http://www.learntotradethemarket.com/) 3 | // https://github.com/thmstm/TradinView-scripts 4 | 5 | 6 | // This script displays Exponential Moving Averages (EMAs) on multi-timeframe. 7 | 8 | 9 | //@version=3 10 | study(title="thms - EMAs combined", shorttitle="thms: EMAs", overlay=true) 11 | 12 | // Length of periods to average on different timeframes 13 | len1m = 1440 // EMA shows here the average value for the past 24 hours 14 | len5m = 288 // EMA shows here the average value for the past 24 hours 15 | len1h1 = 1200 // EMA shows here the average value for the past 50 days 16 | len1h2 = 4800 // EMA shows here the average value for the past 200 days 17 | len1hNF1 = 150 // EMA shows here the average value for the past 150 hours according to Niall Fuller's method 18 | len1hNF2 = 365 // EMA shows here the average value for the past 365 hours according to Niall Fuller's method 19 | len4h1 = 300 // EMA shows here the average value for the past 50 days 20 | len4h2 = 1200 // EMA shows here the average value for the past 200 days 21 | len1D1 = 50 // EMA shows here the average value for the past 50 days 22 | len1D2 = 200 // EMA shows here the average value for the past 200 days 23 | len1DNF1 = 8 // EMA shows here the average value for the past 8 days according to Niall Fuller's method 24 | len1DNF2 = 21 // EMA shows here the average value for the past 21 days according to Niall Fuller's method 25 | len1W = 52 // EMA shows here the average value for the past 1 year 26 | len1M = 84 // EMA shows here the average value for the past 7 years 27 | 28 | // Type of data to count average on 29 | ema_src = close 30 | 31 | // Defining the EMAs that will show up on different time frames 32 | // Where 'ema_length_X' == 1, that EMA will not show up on the given period 33 | ema_length_1 = period == '1' ? 1 : period == '5' ? 1 : period == '60' ? len1hNF1 : period == '240' ? 1 : period == 'D' ? len1DNF1 : period == 'W' ? 1 : period == 'M' ? 1 : 1 34 | ema_length_2 = period == '1' ? 1 : period == '5' ? 1 : period == '60' ? len1hNF2 : period == '240' ? 1 : period == 'D' ? len1DNF2 : period == 'W' ? 1 : period == 'M' ? 1 : 1 35 | 36 | // Invert comment signs below for showing 50D and 200D EMAs 37 | // ema_length_3 = period == '1' ? len1m : period == '5' ? len5m : period == '60' ? len1h1 : period == '240' ? len4h1 : period == 'D' ? len1D1 : period == 'W' ? len1W : period == 'M' ? len1M : 1 38 | ema_length_3 = period == '1' ? len1m : period == '5' ? len5m : period == '60' ? 1 : period == '240' ? len4h1 : period == 'D' ? len1D1 : period == 'W' ? len1W : period == 'M' ? len1M : 1 39 | // ema_length_4 = period == '1' ? 1 : period == '5' ? 1 : period == '60' ? len1h2 : period == '240' ? len4h2 : period == 'D' ? len1D2 : period == 'W' ? 1 : period == 'M' ? 1 : 1 40 | ema_length_4 = period == '1' ? 1 : period == '5' ? 1 : period == '60' ? 1 : period == '240' ? len4h2 : period == 'D' ? len1D2 : period == 'W' ? 1 : period == 'M' ? 1 : 1 41 | 42 | // Plotting the EMAs 43 | plot(ema_length_1 == 1 ? na : ema(ema_src, ema_length_1), title="8D / 150h", style=line, linewidth=1, color=#656565, transp=50) 44 | plot(ema_length_2 == 1 ? na : ema(ema_src, ema_length_2), title="21D / 365h", style=line, linewidth=2, color=#656565, transp=40) 45 | plot(ema_length_3 == 1 ? na : ema(ema_src, ema_length_3), title="1D / 50D / 52W / 7Y", style=circles, linewidth=1, color=#115394, transp=5) 46 | plot(ema_length_4 == 1 ? na : ema(ema_src, ema_length_4), title="200D", style=circles, linewidth=1, color=#3D85C6, transp=5) 47 | -------------------------------------------------------------------------------- /NF: fakey + MB break: -------------------------------------------------------------------------------- 1 | // Created by @thmstm (https://www.tradingview.com/u/thms/) September 4, 2017 2 | // Inspired by a concept by Nial Fuller (http://www.learntotradethemarket.com/) 3 | // https://github.com/thmstm/TradingView-scripts 4 | 5 | 6 | // This script includes the price action based indicator for the fakey signal and 7 | // the mother bar (MB) break signal combined together. Both of them may be switched 8 | // on or off separately. As a bonus, inside bars are also markable up. 9 | 10 | // The fakey signal is a pinbar formation coming after a structure of a mother bar 11 | // (MB) followed by one or more inside bars (IBs). The fakey pinbar has to break 12 | // the mother bar's (MB's) low or high, depending on the direction of the trend, 13 | // but in line with the trend. 14 | 15 | // The mother bar (MB) break signal is a breakout pattern where the mother bar's 16 | // (MB's) low or high is broken, subsequent one or more inside bars (IBs), depending 17 | // on the direction of the trend, but in line with the trend. 18 | 19 | 20 | //@version=3 21 | study(title="thms - NF: fakey + MB break", shorttitle="NF: fakey + MB break", overlay=true) 22 | 23 | //Input for the maximum number of the coiling inside bars that may be considered as a setup 24 | //maxNumCoilingIBs = input(title="Max number of coiling inside bars", type=integer, minval=1, maxval=20, defval=5) 25 | 26 | // Input for pinbar shape and size 27 | // Input for the number of days to take into consideration when comparing a pinbar's range to previous bars' average range 28 | pinbarRangeForNumDays = input(title="Number of days to compare pinbar range size", type=integer, minval=1, maxval=100, defval=21) 29 | // Input for the proportion, how big a pinbar's range should be as compared to previous bars' average range 30 | pinbarRangeForNumDaysMultiplier = input(title="Pinbar range size at least at [%] of above average", type=integer, minval=1, defval=100) 31 | // Input for the proportion, where the OPEN and CLOSE should be within the [HIGH,LOW] range of the candle to classify as a pinbar 32 | pinbarMultiplierOfOpen = input(title="Pinbar's open > [%] of bar", type=integer, minval=0, maxval=100, defval=55) 33 | pinbarMultiplierOfClose = input(title="Pinbar's close > [%] of bar", type=integer, minval=0, maxval=100, defval=55) 34 | 35 | // Input for the size of the marks for an Inside Bar (IB), a Mother Bar (MB) break and a Fakey 36 | IBHeight = input(title="Size of the arrows showing Inside Bars (IBs)", type=integer, minval=1, defval=10) 37 | MBHeight = input(title="Size of the arrows showing Mother Bar breaks (MBs)", type=integer, minval=1, defval=20) 38 | fakeyHeight = input(title="Size of the arrows showing Fakeys", type=integer, minval=1, defval=100) 39 | 40 | // Input for the number of how many of the last Inside Bars (IBs), Mother Bar (MB) breaks and Fakeys to display 41 | numLastIBs = input(title="Number of how many of the last Inside Bars (IBs) to show", type=integer, minval=1, defval=10) 42 | numLastMBs = input(title="Number of how many of the last Mother Bar (MB) breaks to show", type=integer, minval=1, defval=3) 43 | numLastFakeys = input(title="Number of how many of the last Fakeys to show", type=integer, minval=1, defval=3) 44 | 45 | // MB_low = ohlc4 46 | // MB_high = ohlc4 47 | 48 | // for i = maxNumCoilingIBs+1 to 1 49 | // if (lowest(i) == low[i-1]) and (highest(i) == high[i-1]) 50 | // MB_low := low[i-1] 51 | // MB_high := high[i-1] 52 | // break 53 | // else 54 | // continue 55 | 56 | // Determining what is the HIGH of the Mother Bar (MB) candle, if any 57 | MB_high = if lowest(5) == low[4] and highest(5) == high[4] 58 | high[4] 59 | else 60 | if lowest(4) == low[3] and highest(4) == high[3] 61 | high[3] 62 | else 63 | if lowest(3) == low[2] and highest(3) == high[2] 64 | high[2] 65 | else 66 | if lowest(2) == low[1] and highest(2) == high[1] 67 | high[1] 68 | else 69 | ohlc4 70 | 71 | // Determining what is the LOW of the Mother Bar (MB) candle, if any 72 | MB_low = if lowest(5) == low[4] and highest(5) == high[4] 73 | low[4] 74 | else 75 | if lowest(4) == low[3] and highest(4) == high[3] 76 | low[3] 77 | else 78 | if lowest(3) == low[2] and highest(3) == high[2] 79 | low[2] 80 | else 81 | if lowest(2) == low[1] and highest(2) == high[1] 82 | low[1] 83 | else 84 | ohlc4 85 | 86 | // Determining if there is no more Inside Bar (IB) candle 87 | IB_NoMore = (MB_high == MB_low) 88 | 89 | // Determining whether the bar is an Inside Bar (IB) 90 | isIB() => high < MB_high and low > MB_low 91 | // Determining the direction of the Inside Bar (IB) 92 | isDown() => close < open 93 | isDoji() => close == open 94 | isUp() => close > open 95 | IB_Down() => isIB() and isDown() 96 | IB_Doji() => isIB() and isDoji() 97 | IB_Up() => isIB() and isUp() 98 | 99 | // Preparing for drawing arrows upwards and downwards if the bar is an Inside Bar (IB) 100 | IB_DownArrow = isIB() ? -high : na 101 | IB_UpArrow = isIB() ? low : na 102 | 103 | // Determining the previous bars' average range 104 | avgRange = sma((high - low), pinbarRangeForNumDays) 105 | 106 | // Determining whether there is a bar that might be a pinbar eligible for the Fakey 107 | pinbarLongPossible = (open > MB_low[1] and open <= MB_high[1] and close > MB_low[1] and close <= MB_high[1] and low < MB_low[1]) and ((high - low) > pinbarRangeForNumDaysMultiplier / 100 * avgRange) 108 | pinbarShortPossible = (open > MB_low[1] and open <= MB_high[1] and close > MB_low[1] and close <= MB_high[1] and high > MB_high[1]) and ((high - low) > pinbarRangeForNumDaysMultiplier / 100 * avgRange) 109 | // Determining whether the bar possibly eligible for the Fakey meets the criteria of shape as given in the inputs, i.e. whether it is enough "pinbar-shaped" 110 | pinbarLong = pinbarLongPossible and (open > low + (high - low) * pinbarMultiplierOfOpen / 100) and (close > low + (high - low) * pinbarMultiplierOfClose / 100) 111 | pinbarShort = pinbarShortPossible and (open < high - (high - low) * pinbarMultiplierOfOpen / 100) and (close < high - (high - low) * pinbarMultiplierOfClose / 100) 112 | 113 | // Determining whether there is a Fakey actually 114 | Fakey = if pinbarLong 115 | low 116 | else 117 | if pinbarShort 118 | -high 119 | else 120 | na 121 | 122 | // Determining whether there is a Mother Bar (MB) break actually 123 | MB_break = if (MB_high[1] != ohlc4[1]) and (close > MB_high[1]) 124 | MB_high 125 | else 126 | if (MB_low[1] != ohlc4[1]) and (close < MB_low[1]) 127 | -MB_low 128 | else 129 | na 130 | 131 | // Annotating the Inside Bars (IB) 132 | // Drawing arrows upwards and downwards on Inside Bars (IB) 133 | // plotarrow(IB_DownArrow, title="Inside bar (arrow down)", colordown=white, transp=20, maxheight=IBHeight, show_last=5) 134 | // plotarrow(IB_UpArrow, title="Inside bar (arrow up)", colorup=white, transp=20, maxheight=IBHeight, show_last=5) 135 | // Coloring Inside Bars (IB) 136 | IB_color = IB_Down() ? #440000 : IB_Up() ? #004400 : IB_Doji() ? #AAAAAA : na 137 | barcolor(IB_color, show_last=5) 138 | bgcolor(IB_color, show_last=5, transp=75) 139 | 140 | // Annotating the Mother Bar (MB) break 141 | // Drawing a short arrow on Mother Bar (MB) break 142 | plotarrow(MB_break, title="Mother bar break", colorup=#00FFFF, colordown=#FFFF00, transp=15, maxheight=MBHeight, show_last=5) 143 | // Coloring Mother Bar (MB) break 144 | MB_color = MB_break > 0 ? #AAFFAA : MB_break < 0 ? #FFAAAA : na //#55FB6D : MB_break < 0 ? #FB556D : na 145 | barcolor(MB_color, show_last=5) 146 | bgcolor(MB_color, show_last=5, transp=85) 147 | 148 | // Annotating the Fakey setup 149 | // Drawing a long arrow on Fakey setup 150 | plotarrow(Fakey, title="Fakey setup", colorup=#00FFFF, colordown=#FFFF00, transp=0, maxheight=fakeyHeight, show_last=5) 151 | // Coloring Fakey setup 152 | Fakey_color = Fakey > 0 ? #66FFFF : Fakey < 0 ? #FFFF66 : na // #00CC00 : Fakey < 0 ? #FF0000 : na 153 | barcolor(Fakey_color, show_last=5) 154 | bgcolor(Fakey_color, show_last=5, transp=75) 155 | --------------------------------------------------------------------------------