name
stringlengths
1
64
url
stringlengths
44
135
author
stringlengths
3
30
author_url
stringlengths
34
61
likes_count
int64
0
33.2k
kind
stringclasses
3 values
pine_version
int64
1
5
license
stringclasses
3 values
source
stringlengths
177
279k
Baekdoo ANGN for cryptocurrency
https://www.tradingview.com/script/XTDOjvtG-Baekdoo-ANGN-for-cryptocurrency/
traderbaekdoosan
https://www.tradingview.com/u/traderbaekdoosan/
57
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © traderbaekdoosan //@version=4 //ANGN study(title="Baekdoo ANGN", overlay=true, scale=scale.left) OLratio=abs((open-low)/(high-low)) HCratio=abs((high-close)/(high-low)) LCratio=abs((close-low)/(high-low)) HOratio=abs((high-open)/(high-low)) PV_ANGN=if close>open volume*(-HCratio) + volume - volume*OLratio else volume*LCratio + volume - volume*HOratio NV_ANGN=if close<open volume*LCratio - volume + volume*HOratio else volume*(-HCratio) - volume + volume*OLratio ANGN_volume=if close>=close[1] PV_ANGN else NV_ANGN Cumulative_volume=sum(ANGN_volume/10, 500) plot(Cumulative_volume, color=color.white) //minimum volume var chunk=input(100000000) pAA=close>close[1] pBB=ohlc4*volume>chunk pv=0.0 if pAA and pBB pv:=volume else pv:=0 //negative volume nAA=close<close[1] nBB=ohlc4*volume>chunk nv=0.0 if nAA and nBB nv:=volume else nv:=0 plot(pv, color=color.red, style=plot.style_columns) plot(nv, color=color.blue, style=plot.style_columns)
M.Right Candlestick Patterns & Bulkowski Percentages 1.0
https://www.tradingview.com/script/O7uspdg4-M-Right-Candlestick-Patterns-Bulkowski-Percentages-1-0/
UPRIGHTTrading
https://www.tradingview.com/u/UPRIGHTTrading/
136
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © mikeright25 //@version=5 ////Source: Built in "All Candlestick Patterns" ////Bulkowski Candlestick Percentages from his site and book. ////Built in Variables and Candles adjusted slightly to conform to Bulkowski principles. ////In this current version, I've added about 8 candles and removed some that are statistically insignificant and others that Bulkowski doesn't use. Will add back if requested. Moved inputs back to ABC order. ////I decided to leave the theoretical performance as the signal being still on Top for theoretically bearish, and the opposite for theoretically bullish; but I did adjust the signal color to match Bulkowski's tested performance. ////Removed Plot Close indicator('M.Right Candlestick Patterns & Bulkowski Percentages 1.0', shorttitle='M.Right Candle_Ptrns_Bulkowski_Perc', overlay=true) ttnote_perc = 'Please note: the percentages listed are based on Bulkowski\'s tested performance of the candles during a Bull Market (which we are currently in), this doesn\'t guarantee future success.' C_DownTrend = true C_UpTrend = true var trendRule1 = 'SMA50' var trendRule2 = 'SMA50, SMA200' var trendRule = input.string(trendRule1, 'Detect Trend Based On', options=[trendRule1, trendRule2, 'No detection']) if trendRule == trendRule1 priceAvg = ta.sma(close, 50) C_DownTrend := close < priceAvg C_UpTrend := close > priceAvg C_UpTrend if trendRule == trendRule2 sma200 = ta.sma(close, 200) sma50 = ta.sma(close, 50) C_DownTrend := close < sma50 and sma50 < sma200 C_UpTrend := close > sma50 and sma50 > sma200 C_UpTrend C_Len = 14 // ema depth for bodyAvg C_ShadowPercent = 5.0 // size of shadows C_ShadowEqualsPercent = 100.0 C_DojiBodyPercent = 5.0 C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick body //VARIABLES C_BodyHi = math.max(close, open) C_BodyLo = math.min(close, open) C_Body = C_BodyHi - C_BodyLo C_BodyAvg = ta.ema(C_Body, C_Len) C_SmallBody = C_Body < C_BodyAvg C_LongBody = C_Body > C_BodyAvg C_UpShadow = high - C_BodyHi C_DnShadow = C_BodyLo - low C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body C_WhiteBody = open < close C_BlackBody = open > close C_Range = high - low C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo C_BodyMiddle = C_Body / 2 + C_BodyLo C_ShadowEquals = C_UpShadow == C_DnShadow or math.abs(C_UpShadow - C_DnShadow) / C_DnShadow * 100 < C_ShadowEqualsPercent and math.abs(C_DnShadow - C_UpShadow) / C_UpShadow * 100 < C_ShadowEqualsPercent C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100 C_Doji = C_IsDojiBody and C_ShadowEquals patternLabelPosLow = low - ta.atr(30) * 0.6 patternLabelPosHigh = high + ta.atr(30) * 0.6 label_color_bullish = input(color.blue, 'Label Color Bullish') label_color_bearish = input(color.red, 'Label Color Bearish') label_color_neutral = input(color.gray, 'Label Color Neutral') label_color_bullcont = input(color.new(color.aqua, 60), 'Label Color Bullish Continuation') label_color_bearcont = input(color.new(color.orange, 60), 'Label Color Bearish Continuation') CandleType = input.string(title='Pattern Type', defval='Both', options=['Bullish', 'Bearish', 'Both'], tooltip=ttnote_perc) AbandonedBabyInput = input(title='Abandoned Baby (Bullish=70% rev./ Bearish=69% rev.)', defval=true) AboveTheStomachInput = input(title='Above The Stomach (Bullish reversal 66%)', defval=true) Bullish_BeltHoldInput = input(title='Bullish Bult Hold (Bullish reversal 71%)', defval=true) DarkCloudCoverInput = input(title='Dark Cloud Cover (Bearish reversal 60%)', defval=true) DeliberationInput = input(title='Deliberation (Bullish contin. 77%)', defval=true) DojiInput = input(title='Doji (Bullish contin. 51%)', defval=true) DojiStarInput = input(title='Doji Star', defval=true) DownsideTasukiGapInput = input(title='Downside Tasuki Gap (Bullish reversal 54%) ', defval=true) DragonflyDojiInput = input(title='Dragonfly Doji (Bullish contin. 51%)', defval=true) EngulfingInput = input(title='Engulfing (Bullish=rev. 63%/ Bearish=rev. 79%)', defval=true) EveningDojiStarInput = input(title='Evening Doji Star (Bearish reversal 71%)', defval=true) EveningStarInput = input(title='Evening Star (Bearish reversal 72%)', defval=true) FallingThreeMethodsInput = input(title='Falling Three Methods (Bearish contin. 71%)', defval=true) FallingWindowInput = input(title='Falling Window', defval=true) GravestoneDojiInput = input(title='Gravestone Doji', defval=true) HammerInput = input(title='Hammer', defval=true) Inverted_HammerInput = input(title='Inverted Hammer (Bearish contin. 65%)', defval=true) HangingManInput = input(title='Hanging Man', defval=true) HaramiCrossInput = input(title='Harami Cross (Bullish contin. 57%)', defval=true) HaramiInput = input(title='Harami', defval=true) IdenticalThreeCrowsInput = input(title='Identical Three Crows (Bearish reversal 79%)', defval=true) KickingInput = input(title='Kicking (Bullish reversal 53%)', defval=true) //LongLowerShadowInput = input(title = "Long Lower Shadow" ,defval=false) //LongUpperShadowInput = input(title = "Long Upper Shadow" ,defval=false) //MarubozuBlackInput = input(title = "Marubozu Black" ,defval=false) //MarubozuWhiteInput = input(title = "Marubozu White" ,defval=false) MorningDojiStarInput = input(title='Morning Doji Star (Bullish reversal 76%)', defval=true) MorningStarInput = input(title='Morning Star (Bullish reversal 78%)', defval=true) OnNeckInput = input(title='On Neck (Bearish contin. 56%)', defval=true) PiercingInput = input(title='Piercing (Bullish reversal 64%)', defval=true) RisingThreeMethodsInput = input(title='Rising Three Methods (Bullish contin. 74%)', defval=true) RisingWindowInput = input(title='Rising Window (Bullish contin. 75%)', defval=true) ShootingStarInput = input(title='Shooting Star (Bearish reversal 59%)', defval=true) SpinningTopBlackInput = input(title='Spinning Top Black (Reversal 51%)', defval=true) SpinningTopWhiteInput = input(title='Spinning Top White (Reversal 50%)', defval=true) ThreeBlackCrowsInput = input(title='Three Black Crows (Bearish reversal 78%)', defval=true) Bearish_ThreeLineStrikeInput = input(title='Bearish Three Line Strike (Bullish reversal 84%)', defval=true) Bullish_ThreeLineStrikeInput = input(title='Bullish Three Line Strike (Bearish reversal 83%)', defval=true) ThreeOutsideUpInput = input(title='Three Outside Up (Bullish reversal 75%)', defval=true) ThreeWhiteSoldiersInput = input(title='Three White Soldiers (Bullish reversal 82%)', defval=true) TriStarInput = input(title='Tri-Star (Bullish reversal 60%)', defval=true) TweezerBottomInput = input(title='Tweezer Bottom (Bearish contin. 52%)', defval=true) TweezerTopInput = input(title='Tweezer Top (Bullish contin. 56%)', defval=true) UpsideTasukiGapInput = input(title='Upside Tasuki Gap (Bullish contin. 57%)', defval=true) C_AboveTheStomachNumberOfCandles = 2 C_AboveTheStomach = false if C_DownTrend and C_WhiteBody and C_BlackBody[1] C_AboveTheStomach := open[3] > close[3] and open[2] > close[2] and open[1] > close[1] and open < close and high[1] <= close and close[1] <= open and open[1] >= open C_AboveTheStomach alertcondition(C_AboveTheStomach, title='Above The Stomach', message='New Above The Stomach (Bullish reversal) pattern detected') if C_AboveTheStomach and AboveTheStomachInput and ('Bullish' == CandleType or CandleType == 'Both') var ttAboveTheStomach = 'Above The Stomach\nBullish reversal 66% of the time. Overall performance rank: 31. Look for two candles in a downward price trend. The first candle is black and the second white. The white candle should open and close at or above the mid point of the black candle\'s body.' label.new(bar_index, patternLabelPosLow, text='ATS', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttAboveTheStomach) C_Bullish_BeltHoldNumberOfCandles = 1 C_BBHShadowPercentWhite = 5.0 C_Bullish_BeltHold = false if C_DownTrend and C_WhiteBody C_Bullish_BeltHold := open[1] > close[1] and open < close and open[1] > close and low[1] > open and C_HasUpShadow and C_LongBody and C_DnShadow <= C_BBHShadowPercentWhite / 100 * C_Body and C_WhiteBody C_Bullish_BeltHold alertcondition(C_Bullish_BeltHold, title='Bullish Belt Hold', message='New Bullish Belt Hold (Bullish reversal) pattern detected') if C_Bullish_BeltHold and Bullish_BeltHoldInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullish_BeltHold = 'Bullish Belt Hold\nBullish reversal 71% of the time. Overall performance rank: 62 Look for a white candle with no lower shadow, but closing near the high. Belt hold candles taller than the median have post breakout performance significantly better than those shorter than the median. Belt holds with comparatively tall upper shadows outperform.' label.new(bar_index, patternLabelPosLow, text='BBH', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttBullish_BeltHold) C_ThreeOutsideUpNumberOfCandles = 3 C_ThreeOutsideUp = false if C_DownTrend and C_WhiteBody and C_WhiteBody[1] and C_BlackBody[2] C_ThreeOutsideUp := open[3] > close[3] and open[2] > close[2] and open[1] < close[1] and open < close and open[2] <= close[1] and close[2] >= open[1] and close[1] <= open C_ThreeOutsideUp alertcondition(C_ThreeOutsideUp, title='Three Outside Up', message='New Three Outside Up (Bullish reversal) pattern detected') if C_ThreeOutsideUp and ThreeOutsideUpInput and ('Bullish' == CandleType or CandleType == 'Both') var ttThreeOutsideUp = 'Three Outside Up\nBullish reversal 75% of the time. Overall performance rank: 34. Look for a black candle in a downward price trend. Following that, a white candle opens below the prior body and closes above it, too. The last day is a candle in which price closes higher, according to Morris who developed the candle. For the best performance, look for the pattern in a downward retracement of the upward price trend.' label.new(bar_index, patternLabelPosLow, text='3OU', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttThreeOutsideUp) C_Bullish_ThreeLineStrikeNumberOfCandles = 4 C_Bullish_ThreeLineStrike = false if C_UpTrend and C_BlackBody and C_WhiteBody[1] and C_WhiteBody[2] and C_WhiteBody[3] C_Bullish_ThreeLineStrike := open[3] < close[3] and open[2] < close[2] and open[1] < close[1] and open > close and close[3] <= open[2] and close[2] <= open[1] and close[1] <= open and open[3] >= close C_Bullish_ThreeLineStrike alertcondition(C_Bullish_ThreeLineStrike, title='Bullish Three-Line Strike (Bearish reversal)', message='New Bullish Three-Line Strike (bearish reversal) pattern detected') if C_Bullish_ThreeLineStrike and Bullish_ThreeLineStrikeInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullish_ThreeLineStrike = 'Bullish Three-Line Strike\nBearish reversal 65% of the time. Theoretical performance: Bullish continuation. Look for three white candles each with a higher close. A tall black candle should open higher, but close below the open of the first candle. Price forms three white candles, each with a higher close, in an upward price trend. A black candle opens higher but price plummets so that it closes below the opening price of the first candle. The next day, price gaps open lower and closes lower still, staging a downward breakout. This bullish three-line strike candlestick pattern acts as a bearish reversal of the upward price trend. That disobeys candle theory which says that this candlestick pattern acts as a continuation of the prevailing price trend.' label.new(bar_index, patternLabelPosHigh, text='3LS', style=label.style_label_down, color=label_color_bearish, textcolor=color.white, tooltip=ttBullish_ThreeLineStrike) C_DeliberationNumberOfCandles = 3 C_Deliberation = false if C_SmallBody and C_LongBody[1] and C_LongBody[2] if C_WhiteBody and C_WhiteBody[1] and C_WhiteBody[2] C_Deliberation := open[2] < close[2] and open[1] < close[1] and open < close and close[2] < open[1] and close[1] < open and high[2] - low[2] > high[1] - low[1] and high[1] - low[1] > high - low C_Deliberation alertcondition(C_Deliberation, title='Deliberation – Bullish Continuation', message='New Deliberation – Bullish Continuation pattern detected') if C_Deliberation and DeliberationInput and ('Bullish' == CandleType or CandleType == 'Both') var ttDeliberation = 'Deliberation\nBullish continuation 77% of the time. Theoretical performance: Bearish reversal. Overall performance rank: 93. Look for three white candlesticks in an upward price trend. The first two are tall bodied candles but the third has a small body that opens near the second day\'s close. Each candle opens and closes higher than the previous one. The first two candles have tall bodies but the third line has a small body. Each of the candles is supposed to open and close higher, but a higher close is tough to see on the third day. The last day should also open near the prior close. This deliberation acts as a reversal of the upward price trend because price closes below the bottom of the candle pattern first, not the top, plus, it appears in an upward price trend. Notice that the trend stops when it hits overhead resistance near the top of the candle pattern.' label.new(bar_index, patternLabelPosHigh, text='Del', style=label.style_label_down, color=label_color_bullcont, textcolor=color.white, tooltip=ttDeliberation) C_IdenticalThreeCrowsNumberOfCandles = 3 C_IdenticalThreeCrows = false if C_UpTrend and C_BlackBody and C_BlackBody[1] and C_BlackBody[2] if open[2] > close[2] and open[1] > close[1] and open > close and close[2] >= open[1] and close[2] >= open and low[2] <= open[1] and low[1] <= open and open[2] >= high[1] and open[1] >= high and low[2] >= close[1] and low[1] >= open C_IdenticalThreeCrows := true C_IdenticalThreeCrows alertcondition(C_IdenticalThreeCrows, title='Identical 3 Crows', message='New Bearish Identical 3 Crows pattern detected') if C_IdenticalThreeCrows and IdenticalThreeCrowsInput and ('Bearish' == CandleType or CandleType == 'Both') var ttIdenticalThreeCrows = 'Identical 3 Crows\nBearish Reversal Bearish reversal 79% of the time. Overall performance rank: 24. Look for three tall black candles, the last two opening near the prior candle\'s close. Some sources require each candle to be similar in size, but this one is rare enough without that restriction. ' label.new(bar_index, patternLabelPosHigh, text='I3C', style=label.style_label_down, color=label_color_bearish, textcolor=color.white, tooltip=ttIdenticalThreeCrows) C_Bearish_ThreeLineStrikeNumberOfCandles = 4 C_Bearish_ThreeLineStrike = false if C_DownTrend and C_WhiteBody and C_BlackBody[1] and C_BlackBody[2] and C_BlackBody[3] if close[3] < open[3] and close[2] < open[2] and close[2] < close[3] and close[1] < open[1] and close[1] < close[2] and open <= close[1] and close >= open[3] C_Bearish_ThreeLineStrike := true C_Bearish_ThreeLineStrike alertcondition(C_Bearish_ThreeLineStrike, title='Bearish Three-Line Strike (bullish rev)', message='New Bearish Three-Line Strike pattern detected') if C_Bearish_ThreeLineStrike and Bearish_ThreeLineStrikeInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearish_ThreeLineStrike = '3 Line Strike\nBullish reversal 84% of the time Theoretical performance: Bearish continuation. Price forms three black candles, each with lower closes, in a downward price trend. A tall white candle engulfs the price action of the prior three days. The candle acts as a bullish reversal when price breaks out upward, and closes above the top of the candle pattern. ' label.new(bar_index, patternLabelPosLow, text='3LS', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttBearish_ThreeLineStrike) C_OnNeckBearishNumberOfCandles = 2 C_OnNeckBearish = false if C_DownTrend and C_BlackBody[1] and C_LongBody[1] and C_WhiteBody and open < close[1] and C_SmallBody and C_Range != 0 and math.abs(close - low[1]) <= C_BodyAvg * 0.05 C_OnNeckBearish := true C_OnNeckBearish alertcondition(C_OnNeckBearish, title='On Neck – Bearish', message='New On Neck – Bearish pattern detected') if C_OnNeckBearish and OnNeckInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishOnNeck = 'On Neck\nBearish continuation 56%. On Neck is a two-line continuation pattern found in a downtrend. The first candle is long and red, the second candle is short and has a green body. The closing price of the second candle is close or equal to the first candle\'s low price. The pattern hints at a continuation of a downtrend, and penetrating the low of the green candlestick is sometimes considered a confirmation. ' label.new(bar_index, patternLabelPosHigh, text='ON', style=label.style_label_down, color=label_color_bearcont, textcolor=color.white, tooltip=ttBearishOnNeck) C_RisingWindowBullishNumberOfCandles = 2 C_RisingWindowBullish = false if C_UpTrend[1] and C_Range != 0 and C_Range[1] != 0 and low > high[1] C_RisingWindowBullish := true C_RisingWindowBullish alertcondition(C_RisingWindowBullish, title='Rising Window – Bullish', message='New Rising Window – Bullish pattern detected') if C_RisingWindowBullish and RisingWindowInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishRisingWindow = 'Rising Window\nBullish continuation 75%. Rising Window is a two-candle bullish continuation pattern that forms during an uptrend. Both candles in the pattern can be of any type with the exception of the Four-Price Doji. The most important characteristic of the pattern is a price gap between the first candle\'s high and the second candle\'s low. That gap (window) between two bars signifies support against the selling pressure.' label.new(bar_index, patternLabelPosLow, text='RW', style=label.style_label_up, color=label_color_bullcont, textcolor=color.white, tooltip=ttBullishRisingWindow) C_FallingWindowBearishNumberOfCandles = 2 C_FallingWindowBearish = false if C_DownTrend[1] and C_Range != 0 and C_Range[1] != 0 and high < low[1] C_FallingWindowBearish := true C_FallingWindowBearish alertcondition(C_FallingWindowBearish, title='Falling Window – Bearish', message='New Falling Window – Bearish pattern detected') if C_FallingWindowBearish and FallingWindowInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishFallingWindow = 'Falling Window\nBearish continuation 67%. Falling Window is a two-candle bearish continuation pattern that forms during a downtrend. Both candles in the pattern can be of any type, with the exception of the Four-Price Doji. The most important characteristic of the pattern is a price gap between the first candle\'s low and the second candle\'s high. The existence of this gap (window) means that the bearish trend is expected to continue.' label.new(bar_index, patternLabelPosHigh, text='FW', style=label.style_label_down, color=label_color_bearcont, textcolor=color.white, tooltip=ttBearishFallingWindow) C_FallingThreeMethodsBearishNumberOfCandles = 5 C_FallingThreeMethodsBearish = false if C_DownTrend[4] and C_LongBody[4] and C_BlackBody[4] and C_SmallBody[3] and C_WhiteBody[3] and open[3] > low[4] and close[3] < high[4] and C_SmallBody[2] and C_WhiteBody[2] and open[2] > low[4] and close[2] < high[4] and C_SmallBody[1] and C_WhiteBody[1] and open[1] > low[4] and close[1] < high[4] and C_LongBody and C_BlackBody and close < close[4] C_FallingThreeMethodsBearish := true C_FallingThreeMethodsBearish alertcondition(C_FallingThreeMethodsBearish, title='Falling Three Methods – Bearish', message='New Falling Three Methods – Bearish pattern detected') if C_FallingThreeMethodsBearish and FallingThreeMethodsInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishFallingThreeMethods = 'Falling Three Methods\nBearish continuation 71%. Falling Three Methods is a five-candle bearish pattern that signifies a continuation of an existing downtrend. The first candle is long and red, followed by three short green candles with bodies inside the range of the first candle. The last candle is also red and long and it closes below the close of the first candle. This decisive fifth strongly bearish candle hints that bulls could not reverse the prior downtrend and that bears have regained control of the market.' label.new(bar_index, patternLabelPosHigh, text='FTM', style=label.style_label_down, color=label_color_bearcont, textcolor=color.white, tooltip=ttBearishFallingThreeMethods) C_RisingThreeMethodsBullishNumberOfCandles = 5 C_RisingThreeMethodsBullish = false if C_UpTrend[4] and C_LongBody[4] and C_WhiteBody[4] and C_SmallBody[3] and C_BlackBody[3] and open[3] < high[4] and close[3] > low[4] and C_SmallBody[2] and C_BlackBody[2] and open[2] < high[4] and close[2] > low[4] and C_SmallBody[1] and C_BlackBody[1] and open[1] < high[4] and close[1] > low[4] and C_LongBody and C_WhiteBody and close > close[4] C_RisingThreeMethodsBullish := true C_RisingThreeMethodsBullish alertcondition(C_RisingThreeMethodsBullish, title='Rising Three Methods – Bullish', message='New Rising Three Methods – Bullish pattern detected') if C_RisingThreeMethodsBullish and RisingThreeMethodsInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishRisingThreeMethods = 'Rising Three Methods\nBullish continuation 74%. Rising Three Methods is a five-candle bullish pattern that signifies a continuation of an existing uptrend. The first candle is long and green, followed by three short red candles with bodies inside the range of the first candle. The last candle is also green and long and it closes above the close of the first candle. This decisive fifth strongly bullish candle hints that bears could not reverse the prior uptrend and that bulls have regained control of the market.' label.new(bar_index, patternLabelPosLow, text='RTM', style=label.style_label_up, color=label_color_bullcont, textcolor=color.white, tooltip=ttBullishRisingThreeMethods) C_TweezerTopBearishNumberOfCandles = 2 C_TweezerTopBearish = false if C_UpTrend[1] and (not C_IsDojiBody or C_HasUpShadow and C_HasDnShadow) and math.abs(high - high[1]) <= C_BodyAvg * 0.05 and C_WhiteBody[1] and C_BlackBody and C_LongBody[1] C_TweezerTopBearish := true C_TweezerTopBearish alertcondition(C_TweezerTopBearish, title='Tweezer Top – Bearish', message='New Tweezer Top – Bearish pattern detected') if C_TweezerTopBearish and TweezerTopInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishTweezerTop = 'Tweezer Top\nTested performance: Bullish continuation 56%. Theoretical performance: Bearish reversal. Tweezer Top is a two-candle pattern that signifies a potential bearish reversal. The pattern is found during an uptrend. The first candle is long and green, the second candle is red, and its high is nearly identical to the high of the previous candle. The virtually identical highs, together with the inverted directions, hint that bears might be taking over the market.' label.new(bar_index, patternLabelPosHigh, text='TT', style=label.style_label_down, color=label_color_bullcont, textcolor=color.white, tooltip=ttBearishTweezerTop) C_TweezerBottomBullishNumberOfCandles = 2 C_TweezerBottomBullish = false if C_UpTrend[1] and (not C_IsDojiBody or C_HasUpShadow and C_HasDnShadow) and math.abs(low - low[1]) <= C_BodyAvg * 0.05 and C_BlackBody[1] and C_WhiteBody and C_LongBody[1] C_TweezerBottomBullish := true C_TweezerBottomBullish alertcondition(C_TweezerBottomBullish, title='Tweezer Bottom – Bullish', message='New Tweezer Bottom – Bullish pattern detected') if C_TweezerBottomBullish and TweezerBottomInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishTweezerBottom = 'Tweezer Bottom\nTested performance: Bearish continuation 52% of the time. Theoretical performance: Bullish reversal. Tweezer Bottom is a two-candle pattern that signifies a potential bullish reversal. The pattern is found during a downtrend. The first candle is long and red, the second candle is green, its lows nearly identical to the low of the previous candle. The virtually identical lows together with the inverted directions hint that bulls might be taking over the market.' label.new(bar_index, patternLabelPosHigh, text='TB', style=label.style_label_up, color=label_color_bearcont, textcolor=color.white, tooltip=ttBullishTweezerBottom) C_DarkCloudCoverBearishNumberOfCandles = 2 C_DarkCloudCoverBearish = false if C_UpTrend[1] and C_WhiteBody[1] and C_LongBody[1] and C_BlackBody and open >= high[1] and close < C_BodyMiddle[1] and close > open[1] C_DarkCloudCoverBearish := true C_DarkCloudCoverBearish alertcondition(C_DarkCloudCoverBearish, title='Dark Cloud Cover – Bearish', message='New Dark Cloud Cover – Bearish pattern detected') if C_DarkCloudCoverBearish and DarkCloudCoverInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishDarkCloudCover = 'Dark Cloud Cover\nBearish reversal 60% of the time. Dark Cloud Cover is a two-candle bearish reversal candlestick pattern found in an uptrend. The first candle is green and has a larger than average body. The second candle is red and opens above the high of the prior candle, creating a gap, and then closes below the midpoint of the first candle. The pattern shows a possible shift in the momentum from the upside to the downside, indicating that a reversal might happen soon.' label.new(bar_index, patternLabelPosHigh, text='DCC', style=label.style_label_down, color=label_color_bearish, textcolor=color.white, tooltip=ttBearishDarkCloudCover) C_DownsideTasukiGapBearishNumberOfCandles = 3 C_DownsideTasukiGapBearish = false if C_LongBody[2] and C_SmallBody[1] and C_DownTrend and C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2] and C_BlackBody[1] and C_WhiteBody and C_BodyHi <= C_BodyLo[2] and C_BodyHi >= C_BodyHi[1] C_DownsideTasukiGapBearish := true C_DownsideTasukiGapBearish alertcondition(C_DownsideTasukiGapBearish, title='Downside Tasuki Gap – Bearish', message='New Downside Tasuki Gap – Bearish pattern detected') if C_DownsideTasukiGapBearish and DownsideTasukiGapInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishDownsideTasukiGap = 'Downside Tasuki Gap\nTested performance: Bullish reversal 54% of the time. Theoretical performance: Bearish continuation. Downside Tasuki Gap is a three-candle pattern found in a downtrend that usually hints at the continuation of the downtrend. The first candle is long and red, followed by a smaller red candle with its opening price that gaps below the body of the previous candle. The third candle is green and it closes inside the gap created by the first two candles, unable to close it fully. The bull’s inability to close that gap hints that the downtrend might continue.' label.new(bar_index, patternLabelPosHigh, text='DTG', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttBearishDownsideTasukiGap) C_UpsideTasukiGapBullishNumberOfCandles = 3 C_UpsideTasukiGapBullish = false if C_LongBody[2] and C_SmallBody[1] and C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2] and C_WhiteBody[1] and C_BlackBody and C_BodyLo >= C_BodyHi[2] and C_BodyLo <= C_BodyLo[1] C_UpsideTasukiGapBullish := true C_UpsideTasukiGapBullish alertcondition(C_UpsideTasukiGapBullish, title='Upside Tasuki Gap – Bullish', message='New Upside Tasuki Gap – Bullish pattern detected') if C_UpsideTasukiGapBullish and UpsideTasukiGapInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishUpsideTasukiGap = 'Upside Tasuki Gap\nBullish continuation 57% of the time. Upside Tasuki Gap is a three-candle pattern found in an uptrend that usually hints at the continuation of the uptrend. The first candle is long and green, followed by a smaller green candle with its opening price that gaps above the body of the previous candle. The third candle is red and it closes inside the gap created by the first two candles, unable to close it fully. The bear’s inability to close the gap hints that the uptrend might continue.' label.new(bar_index, patternLabelPosLow, text='UTG', style=label.style_label_up, color=label_color_bullcont, textcolor=color.white, tooltip=ttBullishUpsideTasukiGap) C_EveningDojiStarBearishNumberOfCandles = 3 C_EveningDojiStarBearish = false if C_LongBody[2] and C_IsDojiBody[1] and C_LongBody and C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2] and C_BlackBody and C_BodyLo <= C_BodyMiddle[2] and C_BodyLo > C_BodyLo[2] and C_BodyLo[1] > C_BodyHi C_EveningDojiStarBearish := true C_EveningDojiStarBearish alertcondition(C_EveningDojiStarBearish, title='Evening Doji Star – Bearish', message='New Evening Doji Star – Bearish pattern detected') if C_EveningDojiStarBearish and EveningDojiStarInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishEveningDojiStar = 'Evening Doji Star\nBearish reversal 71% of the time. This candlestick pattern is a variation of the Evening Star pattern. It is bearish and continues an uptrend with a long-bodied, green candle day. It is then followed by a gap and a Doji candle and concludes with a downward close. The close would be below the first day’s midpoint. It is more bearish than the regular evening star pattern because of the existence of the Doji.' label.new(bar_index, patternLabelPosHigh, text='EDS', style=label.style_label_down, color=label_color_bearish, textcolor=color.white, tooltip=ttBearishEveningDojiStar) C_DojiStarBearishNumberOfCandles = 2 C_DojiStarBearish = false if C_UpTrend and C_WhiteBody[1] and C_LongBody[1] and C_IsDojiBody and C_BodyLo > C_BodyHi[1] C_DojiStarBearish := true C_DojiStarBearish alertcondition(C_DojiStarBearish, title='Doji Star – Bearish', message='New Doji Star – Bearish pattern detected') if C_DojiStarBearish and DojiStarInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishDojiStar = 'Doji Star\nTested performance: Bullish continuation 69% of the time. Theoretical performance: Bearish reversal. This is a bearish reversal candlestick pattern that is found in an uptrend and consists of two candles. First comes a long green candle, followed by a Doji candle (except 4-Price Doji) that opens above the body of the first one, creating a gap. It is considered a reversal signal with confirmation during the next trading day.' label.new(bar_index, patternLabelPosHigh, text='DS', style=label.style_label_down, color=label_color_bullcont, textcolor=color.white, tooltip=ttBearishDojiStar) C_DojiStarBullishNumberOfCandles = 2 C_DojiStarBullish = false if C_DownTrend and C_BlackBody[1] and C_LongBody[1] and C_IsDojiBody and C_BodyHi < C_BodyLo[1] C_DojiStarBullish := true C_DojiStarBullish alertcondition(C_DojiStarBullish, title='Doji Star – Bullish', message='New Doji Star – Bullish pattern detected') if C_DojiStarBullish and DojiStarInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishDojiStar = 'Doji Star\nTested performance: Bearish continuation 64% of the time. Theoretical performance: Bullish reversal. This is a bullish reversal candlestick pattern that is found in a downtrend and consists of two candles. First comes a long red candle, followed by a Doji candle (except 4-Price Doji) that opens below the body of the first one, creating a gap. It is considered a reversal signal with confirmation during the next trading day.' label.new(bar_index, patternLabelPosLow, text='DS', style=label.style_label_up, color=label_color_bearcont, textcolor=color.white, tooltip=ttBullishDojiStar) C_MorningDojiStarBullishNumberOfCandles = 3 C_MorningDojiStarBullish = false if C_LongBody[2] and C_IsDojiBody[1] and C_LongBody and C_DownTrend and C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2] and C_WhiteBody and C_BodyHi >= C_BodyMiddle[2] and C_BodyHi < C_BodyHi[2] and C_BodyHi[1] < C_BodyLo C_MorningDojiStarBullish := true C_MorningDojiStarBullish alertcondition(C_MorningDojiStarBullish, title='Morning Doji Star – Bullish', message='New Morning Doji Star – Bullish pattern detected') if C_MorningDojiStarBullish and MorningDojiStarInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishMorningDojiStar = 'Morning Doji Star\nBullish reversal 76% of the time. This candlestick pattern is a variation of the Morning Star pattern. A three-day bullish reversal pattern, which consists of three candlesticks will look something like this: The first being a long-bodied red candle that extends the current downtrend. Next comes a Doji that gaps down on the open. After that comes a long-bodied green candle, which gaps up on the open and closes above the midpoint of the body of the first day. It is more bullish than the regular morning star pattern because of the existence of the Doji.' label.new(bar_index, patternLabelPosLow, text='MDS', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttBullishMorningDojiStar) C_PiercingBullishNumberOfCandles = 2 C_PiercingBullish = false if C_DownTrend[1] and C_BlackBody[1] and C_LongBody[1] and C_WhiteBody and open <= low[1] and close > C_BodyMiddle[1] and close < open[1] C_PiercingBullish := true C_PiercingBullish alertcondition(C_PiercingBullish, title='Piercing – Bullish', message='New Piercing – Bullish pattern detected') if C_PiercingBullish and PiercingInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishPiercing = 'Piercing\nBullish reversal 64% of the time. Piercing is a two-candle bullish reversal candlestick pattern found in a downtrend. The first candle is red and has a larger than average body. The second candle is green and opens below the low of the prior candle, creating a gap, and then closes above the midpoint of the first candle. The pattern shows a possible shift in the momentum from the downside to the upside, indicating that a reversal might happen soon.' label.new(bar_index, patternLabelPosLow, text='P', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttBullishPiercing) C_HammerBullishNumberOfCandles = 1 C_HammerBullish = false if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor * C_Body and not C_HasUpShadow if C_DownTrend C_HammerBullish := true C_HammerBullish alertcondition(C_HammerBullish, title='Hammer – Bullish', message='New Hammer – Bullish pattern detected') if C_HammerBullish and HammerInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishHammer = 'Hammer\nBullish reversal 60% of the time. Hammer candlesticks form when a security moves lower after the open, but continues to rally into close above the intraday low. The candlestick that you are left with will look like a square attached to a long stick-like figure. This candlestick is called a Hammer if it happens to form during a decline.' label.new(bar_index, patternLabelPosLow, text='H', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttBullishHammer) C_HangingManBearishNumberOfCandles = 1 C_HangingManBearish = false if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor * C_Body and not C_HasUpShadow if C_UpTrend C_HangingManBearish := true C_HangingManBearish alertcondition(C_HangingManBearish, title='Hanging Man – Bearish', message='New Hanging Man – Bearish pattern detected') if C_HangingManBearish and HangingManInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishHangingMan = 'Hanging Man\nTested performance: Bullish continuation 59% of the time. Theoretical performance: Bearish reversal. When a specified security notably moves lower after the open, but continues to rally to close above the intraday low, a Hanging Man candlestick will form. The candlestick will resemble a square, attached to a long stick-like figure. It is referred to as a Hanging Man if the candlestick forms during an advance.' label.new(bar_index, patternLabelPosHigh, text='HM', style=label.style_label_down, color=label_color_bullcont, textcolor=color.white, tooltip=ttBearishHangingMan) C_ShootingStarBearishNumberOfCandles = 1 C_ShootingStarBearish = false if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor * C_Body and not C_HasDnShadow if C_UpTrend C_ShootingStarBearish := true C_ShootingStarBearish alertcondition(C_ShootingStarBearish, title='Shooting Star – Bearish', message='New Shooting Star – Bearish pattern detected') if C_ShootingStarBearish and ShootingStarInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishShootingStar = 'Shooting Star\nBearish reversal 59% of the time. This single day pattern can appear during an uptrend and opens high, while it closes near its open. It trades much higher as well. It is bearish in nature, but looks like an Inverted Hammer.' label.new(bar_index, patternLabelPosHigh, text='SS', style=label.style_label_down, color=label_color_bearish, textcolor=color.white, tooltip=ttBearishShootingStar) C_Inverted_HammerBullishNumberOfCandles = 1 C_Inverted_HammerBullish = false if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor * C_Body and not C_HasDnShadow if C_DownTrend C_Inverted_HammerBullish := true C_Inverted_HammerBullish alertcondition(C_Inverted_HammerBullish, title='Inverted Hammer – Bullish', message='New Inverted Hammer – Bullish pattern detected') if C_Inverted_HammerBullish and Inverted_HammerInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishInverted_Hammer = 'Inverted Hammer\nTested performance: Bearish continuation 65% of the time. Theoretical performance: Bullish reversal. If in a downtrend, then the open is lower. When it eventually trades higher, but closes near its open, it will look like an inverted version of the Hammer Candlestick. This is a one-day bullish reversal pattern.' label.new(bar_index, patternLabelPosLow, text='IH', style=label.style_label_down, color=label_color_bearcont, textcolor=color.white, tooltip=ttBullishInverted_Hammer) C_MorningStarBullishNumberOfCandles = 3 C_MorningStarBullish = false if C_LongBody[2] and C_SmallBody[1] and C_LongBody if C_DownTrend and C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2] and C_WhiteBody and C_BodyHi >= C_BodyMiddle[2] and C_BodyHi < C_BodyHi[2] and C_BodyHi[1] < C_BodyLo C_MorningStarBullish := true C_MorningStarBullish alertcondition(C_MorningStarBullish, title='Morning Star – Bullish', message='New Morning Star – Bullish pattern detected') if C_MorningStarBullish and MorningStarInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishMorningStar = 'Morning Star\nBullish reversal 78% of the time. A three-day bullish reversal pattern, which consists of three candlesticks will look something like this: The first being a long-bodied red candle that extends the current downtrend. Next comes a short, middle candle that gaps down on the open. After comes a long-bodied green candle, which gaps up on the open and closes above the midpoint of the body of the first day.' label.new(bar_index, patternLabelPosLow, text='MS', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttBullishMorningStar) C_EveningStarBearishNumberOfCandles = 3 C_EveningStarBearish = false if C_LongBody[2] and C_SmallBody[1] and C_LongBody if C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2] and C_BlackBody and C_BodyLo <= C_BodyMiddle[2] and C_BodyLo > C_BodyLo[2] and C_BodyLo[1] > C_BodyHi C_EveningStarBearish := true C_EveningStarBearish alertcondition(C_EveningStarBearish, title='Evening Star – Bearish', message='New Evening Star – Bearish pattern detected') if C_EveningStarBearish and EveningStarInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishEveningStar = 'Evening Star\nBearish reversal 72% of the time. This candlestick pattern is bearish and continues an uptrend with a long-bodied, green candle day. It is then followed by a gapped and small-bodied candle day, and concludes with a downward close. The close would be below the first day’s midpoint.' label.new(bar_index, patternLabelPosHigh, text='ES', style=label.style_label_down, color=label_color_bearish, textcolor=color.white, tooltip=ttBearishEveningStar) //C_MarubozuWhiteBullishNumberOfCandles = 1 //C_MarubozuShadowPercentWhite = 5.0 //C_MarubozuWhiteBullish = C_WhiteBody and C_LongBody and C_UpShadow <= C_MarubozuShadowPercentWhite/100*C_Body and C_DnShadow <= C_MarubozuShadowPercentWhite/100*C_Body and C_WhiteBody //alertcondition(C_MarubozuWhiteBullish, title = "Marubozu White – Bullish", message = "New Marubozu White – Bullish pattern detected") //if C_MarubozuWhiteBullish and MarubozuWhiteInput and (("Bullish" == CandleType) or CandleType == "Both") // var ttBullishMarubozuWhite = "Marubozu White\nContinuation 54-56% of the time. A Marubozu White Candle is a candlestick that does not have a shadow that extends from its candle body at either the open or the close. Marubozu is Japanese for “close-cropped” or “close-cut.” Other sources may call it a Bald or Shaven Head Candle." // label.new(bar_index, patternLabelPosLow, text="MW", style=label.style_label_up, color = label_color_bullcont, textcolor=color.white, tooltip = ttBullishMarubozuWhite) //C_MarubozuBlackBearishNumberOfCandles = 1 //C_MarubozuShadowPercentBearish = 5.0 //C_MarubozuBlackBearish = C_BlackBody and C_LongBody and C_UpShadow <= C_MarubozuShadowPercentBearish/100*C_Body and C_DnShadow <= C_MarubozuShadowPercentBearish/100*C_Body and C_BlackBody //alertcondition(C_MarubozuBlackBearish, title = "Marubozu Black – Bearish", message = "New Marubozu Black – Bearish pattern detected") //if C_MarubozuBlackBearish and MarubozuBlackInput and (("Bearish" == CandleType) or CandleType == "Both") // var ttBearishMarubozuBlack = "Marubozu Black\nContinuation 53% of the time. This is a candlestick that has no shadow, which extends from the red-bodied candle at the open, the close, or even at both. In Japanese, the name means “close-cropped” or “close-cut.” The candlestick can also be referred to as Bald or Shaven Head." // label.new(bar_index, patternLabelPosHigh, text="MB", style=label.style_label_down, color = label_color_neutral, textcolor=color.white, tooltip = ttBearishMarubozuBlack) C_DojiNumberOfCandles = 1 C_DragonflyDoji = C_IsDojiBody and C_UpShadow <= C_Body C_GravestoneDojiOne = C_IsDojiBody and C_DnShadow <= C_Body alertcondition(C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne, title='Doji', message='New Doji pattern detected') if C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne and DojiInput var ttDoji = 'Doji\nIndecision. Bullish continuation 51% of the time. When the open and close of a security are essentially equal to each other, a doji candle forms. The length of both upper and lower shadows may vary, causing the candlestick you are left with to either resemble a cross, an inverted cross, or a plus sign. Doji candles show the playout of buyer-seller indecision in a tug-of-war of sorts. As price moves either above or below the opening level during the session, the close is either at or near the opening level.' label.new(bar_index, patternLabelPosLow, text='D', style=label.style_label_up, color=label_color_bullcont, textcolor=color.white, tooltip=ttDoji) C_GravestoneDojiBearishNumberOfCandles = 1 C_GravestoneDojiBearish = C_IsDojiBody and C_DnShadow <= C_Body alertcondition(C_GravestoneDojiBearish, title='Gravestone Doji – Bearish', message='New Gravestone Doji – Bearish pattern detected') if C_GravestoneDojiBearish and GravestoneDojiInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishGravestoneDoji = 'Gravestone Doji\nIndecision to Bearish reversal 51% of the time. When a doji is at or is close to the day’s low point, a doji line will develop.' label.new(bar_index, patternLabelPosHigh, text='GD', style=label.style_label_down, color=label_color_bearish, textcolor=color.white, tooltip=ttBearishGravestoneDoji) C_DragonflyDojiBullishNumberOfCandles = 1 C_DragonflyDojiBullish = C_IsDojiBody and C_UpShadow <= C_Body alertcondition(C_DragonflyDojiBullish, title='Dragonfly Doji – Bullish', message='New Dragonfly Doji – Bullish pattern detected') if C_DragonflyDojiBullish and DragonflyDojiInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishDragonflyDoji = 'Dragonfly Doji\nBullish reversal 50% during a decline, otherwise indecision. Similar to other Doji days, this particular Doji also regularly appears at pivotal market moments. This is a specific Doji where both the open and close price are at the high of a given day.' label.new(bar_index, patternLabelPosLow, text='DD', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttBullishDragonflyDoji) C_HaramiCrossBullishNumberOfCandles = 2 C_HaramiCrossBullish = C_LongBody[1] and C_BlackBody[1] and C_DownTrend[1] and C_IsDojiBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] alertcondition(C_HaramiCrossBullish, title='Harami Cross – Bullish', message='New Harami Cross – Bullish pattern detected') if C_HaramiCrossBullish and HaramiCrossInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishHaramiCross = 'Harami Cross\nBearish continuation 55% of the time. Theoretical performance: Bullish reversal. This candlestick pattern is a variation of the Harami Bullish pattern. It is found during a downtrend. The two-day candlestick pattern consists of a Doji candle that is entirely encompassed within the body of what was once a red-bodied candle.' label.new(bar_index, patternLabelPosLow, text='HC', style=label.style_label_up, color=label_color_bearcont, textcolor=color.white, tooltip=ttBullishHaramiCross) C_HaramiCrossBearishNumberOfCandles = 2 C_HaramiCrossBearish = C_LongBody[1] and C_WhiteBody[1] and C_UpTrend[1] and C_IsDojiBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] alertcondition(C_HaramiCrossBearish, title='Harami Cross – Bearish', message='New Harami Cross – Bearish pattern detected') if C_HaramiCrossBearish and HaramiCrossInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishHaramiCross = 'Harami Cross\nBullish continuation 57% of the time. Theoretical performance: Bearish reversal. This candlestick pattern is a variation of the Harami Bearish pattern. It is found during an uptrend. This is a two-day candlestick pattern with a Doji candle that is entirely encompassed within the body that was once a green-bodied candle. The Doji shows that some indecision has entered the minds of sellers, and the pattern hints that the trend might reverse.' label.new(bar_index, patternLabelPosHigh, text='HC', style=label.style_label_down, color=label_color_bullcont, textcolor=color.white, tooltip=ttBearishHaramiCross) C_HaramiBullishNumberOfCandles = 2 C_HaramiBullish = C_LongBody[1] and C_BlackBody[1] and C_DownTrend[1] and C_WhiteBody and C_SmallBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] alertcondition(C_HaramiBullish, title='Harami – Bullish', message='New Harami – Bullish pattern detected') if C_HaramiBullish and HaramiInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishHarami = 'Harami\nBullish reversal 53% of the time. This two-day candlestick pattern consists of a small-bodied green candle that is entirely encompassed within the body of what was once a red-bodied candle.' label.new(bar_index, patternLabelPosLow, text='BH', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttBullishHarami) C_HaramiBearishNumberOfCandles = 2 C_HaramiBearish = C_LongBody[1] and C_WhiteBody[1] and C_UpTrend[1] and C_BlackBody and C_SmallBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] alertcondition(C_HaramiBearish, title='Harami – Bearish', message='New Harami – Bearish pattern detected') if C_HaramiBearish and HaramiInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishHarami = 'Harami\nBullish continuation 53% of the time. Theoretical performance: Bearish reversal. This is a two-day candlestick pattern with a small, red-bodied candle that is entirely encompassed within the body that was once a green-bodied candle.' label.new(bar_index, patternLabelPosHigh, text='BH', style=label.style_label_down, color=label_color_bullcont, textcolor=color.white, tooltip=ttBearishHarami) //C_LongLowerShadowBullishNumberOfCandles = 1 //C_LongLowerShadowPercent = 75.0 //C_LongLowerShadowBullish = C_DnShadow > C_Range/100*C_LongLowerShadowPercent //alertcondition(C_LongLowerShadowBullish, title = "Long Lower Shadow – Bullish", message = "New Long Lower Shadow – Bullish pattern detected") //if C_LongLowerShadowBullish and LongLowerShadowInput and (("Bullish" == CandleType) or CandleType == "Both") //var ttBullishLongLowerShadow = "Long Lower Shadow\nConsidered to be a weak bullish signal. In addition, when the market is oversold or at support, the Long Lower Shadow candlestick tends to be more significant.To indicate seller domination of the first part of a session, candlesticks will present with long lower shadows and short upper shadows, consequently lowering prices." //label.new(bar_index, patternLabelPosLow, text="LLS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishLongLowerShadow) //C_LongUpperShadowBearishNumberOfCandles = 1 //C_LongShadowPercent = 75.0 //C_LongUpperShadowBearish = C_UpShadow > C_Range/100*C_LongShadowPercent //alertcondition(C_LongUpperShadowBearish, title = "Long Upper Shadow – Bearish", message = "New Long Upper Shadow – Bearish pattern detected") //if C_LongUpperShadowBearish and LongUpperShadowInput and (("Bearish" == CandleType) or CandleType == "Both") //var ttBearishLongUpperShadow = "Long Upper Shadow\nIt is considered a weak bearish pattern and takes on greater significance when the market is over bought or at resistance. To indicate buyer domination of the first part of a session, candlesticks will present with long upper shadows, as well as short lower shadows, consequently raising bidding prices." //label.new(bar_index, patternLabelPosHigh, text="LUS", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishLongUpperShadow) C_SpinningTopWhiteNumberOfCandles = 1 C_SpinningTopWhitePercent = 34.0 C_IsSpinningTopWhite = C_DnShadow >= C_Range / 100 * C_SpinningTopWhitePercent and C_UpShadow >= C_Range / 100 * C_SpinningTopWhitePercent and not C_IsDojiBody C_SpinningTopWhite = C_IsSpinningTopWhite and C_WhiteBody alertcondition(C_SpinningTopWhite, title='Spinning Top White', message='New Spinning Top White pattern detected') if C_SpinningTopWhite and SpinningTopWhiteInput var ttSpinningTopWhite = 'Spinning Top White\nTested performance: Reversal 50% of the time. Theoretical performance: Indecision. White spinning tops are candlestick lines that are small, green-bodied, and possess shadows (upper and lower) that end up exceeding the length of candle bodies. They often signal indecision between buyer and seller.' label.new(bar_index, patternLabelPosLow, text='STW', style=label.style_label_up, color=label_color_neutral, textcolor=color.white, tooltip=ttSpinningTopWhite) C_SpinningTopBlackNumberOfCandles = 1 C_SpinningTopBlackPercent = 34.0 C_IsSpinningTop = C_DnShadow >= C_Range / 100 * C_SpinningTopBlackPercent and C_UpShadow >= C_Range / 100 * C_SpinningTopBlackPercent and not C_IsDojiBody C_SpinningTopBlack = C_IsSpinningTop and C_BlackBody alertcondition(C_SpinningTopBlack, title='Spinning Top Black', message='New Spinning Top Black pattern detected') if C_SpinningTopBlack and SpinningTopBlackInput var ttSpinningTopBlack = 'Spinning Top Black\nTested performance: Reversal 51% of the time. Theoretical performance: Indecision. Black spinning tops are candlestick lines that are small, red-bodied, and possess shadows (upper and lower) that end up exceeding the length of candle bodies. They often signal indecision.' label.new(bar_index, patternLabelPosLow, text='STB', style=label.style_label_up, color=label_color_neutral, textcolor=color.white, tooltip=ttSpinningTopBlack) C_ThreeWhiteSoldiersBullishNumberOfCandles = 3 C_3WSld_ShadowPercent = 5.0 C_3WSld_HaveNotUpShadow = C_Range * C_3WSld_ShadowPercent / 100 > C_UpShadow C_ThreeWhiteSoldiersBullish = false if C_LongBody and C_LongBody[1] and C_LongBody[2] if C_WhiteBody and C_WhiteBody[1] and C_WhiteBody[2] C_ThreeWhiteSoldiersBullish := close > close[1] and close[1] > close[2] and open < close[1] and open > open[1] and open[1] < close[2] and open[1] > open[2] and C_3WSld_HaveNotUpShadow and C_3WSld_HaveNotUpShadow[1] and C_3WSld_HaveNotUpShadow[2] C_ThreeWhiteSoldiersBullish alertcondition(C_ThreeWhiteSoldiersBullish, title='Three White Soldiers – Bullish', message='New Three White Soldiers – Bullish pattern detected') if C_ThreeWhiteSoldiersBullish and ThreeWhiteSoldiersInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishThreeWhiteSoldiers = 'Three White Soldiers\n**Bullish reversal 82% of the time. This bullish reversal pattern is made up of three long-bodied, green candles in immediate succession. Each one opens within the body before it and the close is near to the daily high.' label.new(bar_index, patternLabelPosLow, text='3WS', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttBullishThreeWhiteSoldiers) C_ThreeBlackCrowsBearishNumberOfCandles = 3 C_3BCrw_ShadowPercent = 5.0 C_3BCrw_HaveNotDnShadow = C_Range * C_3BCrw_ShadowPercent / 100 > C_DnShadow C_ThreeBlackCrowsBearish = false if C_LongBody and C_LongBody[1] and C_LongBody[2] if C_BlackBody and C_BlackBody[1] and C_BlackBody[2] C_ThreeBlackCrowsBearish := close < close[1] and close[1] < close[2] and open > close[1] and open < open[1] and open[1] > close[2] and open[1] < open[2] and C_3BCrw_HaveNotDnShadow and C_3BCrw_HaveNotDnShadow[1] and C_3BCrw_HaveNotDnShadow[2] C_ThreeBlackCrowsBearish alertcondition(C_ThreeBlackCrowsBearish, title='Three Black Crows – Bearish', message='New Three Black Crows – Bearish pattern detected') if C_ThreeBlackCrowsBearish and ThreeBlackCrowsInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishThreeBlackCrows = 'Three Black Crows\n**Bearish reversal 78% of the time. Overall performance rank: 3. This is a bearish reversal pattern that consists of three long, red-bodied candles in immediate succession. For each of these candles, each day opens within the body of the day before and closes either at or near its low.' label.new(bar_index, patternLabelPosHigh, text='3BC', style=label.style_label_down, color=label_color_bearish, textcolor=color.white, tooltip=ttBearishThreeBlackCrows) C_EngulfingBullishNumberOfCandles = 2 C_EngulfingBullish = C_DownTrend and C_WhiteBody and C_LongBody and C_BlackBody[1] and C_SmallBody[1] and close >= open[1] and open <= close[1] and (close > open[1] or open < close[1]) alertcondition(C_EngulfingBullish, title='Engulfing – Bullish', message='New Engulfing – Bullish pattern detected') if C_EngulfingBullish and EngulfingInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishEngulfing = 'Engulfing\n**Bullish reversal 63% of the time. At the end of a given downward trend, there will most likely be a reversal pattern. To distinguish the first day, this candlestick pattern uses a small body, followed by a day where the candle body fully overtakes the body from the day before, and closes in the trend’s opposite direction. Although similar to the outside reversal chart pattern, it is not essential for this pattern to completely overtake the range (high to low), rather only the open and the close.' label.new(bar_index, patternLabelPosLow, text='BE', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttBullishEngulfing) C_EngulfingBearishNumberOfCandles = 2 C_EngulfingBearish = C_UpTrend and C_BlackBody and C_LongBody and C_WhiteBody[1] and C_SmallBody[1] and close <= open[1] and open >= close[1] and (close < open[1] or open > close[1]) alertcondition(C_EngulfingBearish, title='Engulfing – Bearish', message='New Engulfing – Bearish pattern detected') if C_EngulfingBearish and EngulfingInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishEngulfing = 'Engulfing\n**Bearish reversal 79% of the time. At the end of a given uptrend, a reversal pattern will most likely appear. During the first day, this candlestick pattern uses a small body. It is then followed by a day where the candle body fully overtakes the body from the day before it and closes in the trend’s opposite direction. Although similar to the outside reversal chart pattern, it is not essential for this pattern to fully overtake the range (high to low), rather only the open and the close.' label.new(bar_index, patternLabelPosHigh, text='BE', style=label.style_label_down, color=label_color_bearish, textcolor=color.white, tooltip=ttBearishEngulfing) C_AbandonedBabyBullishNumberOfCandles = 3 C_AbandonedBabyBullish = C_DownTrend[2] and C_BlackBody[2] and C_IsDojiBody[1] and low[2] > high[1] and C_WhiteBody and high[1] < low alertcondition(C_AbandonedBabyBullish, title='Abandoned Baby – Bullish', message='New Abandoned Baby – Bullish pattern detected') if C_AbandonedBabyBullish and AbandonedBabyInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishAbandonedBaby = 'Abandoned Baby\n**Bullish reversal 70% of the time. Overall performance rank: 9. This candlestick pattern is quite rare as far as reversal patterns go. The first of the pattern is a large down candle. Next comes a doji candle that gaps below the candle before it. The doji candle is then followed by another candle that opens even higher and swiftly moves to the upside.' label.new(bar_index, patternLabelPosLow, text='AB', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttBullishAbandonedBaby) C_AbandonedBabyBearishNumberOfCandles = 3 C_AbandonedBabyBearish = C_UpTrend[2] and C_WhiteBody[2] and C_IsDojiBody[1] and high[2] < low[1] and C_BlackBody and low[1] > high alertcondition(C_AbandonedBabyBearish, title='Abandoned Baby – Bearish', message='New Abandoned Baby – Bearish pattern detected') if C_AbandonedBabyBearish and AbandonedBabyInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishAbandonedBaby = 'Abandoned Baby\n*Bearish reversal 69% of the time. A bearish abandoned baby is a specific candlestick pattern that often signals a downward reversal trend in terms of security price. It is formed when a gap appears between the lowest price of a doji-like candle and the candlestick of the day before. The earlier candlestick is green, tall, and has small shadows. The doji candle is also tailed by a gap between its lowest price point and the highest price point of the candle that comes next, which is red, tall and also has small shadows. The doji candle shadows must completely gap either below or above the shadows of the first and third day in order to have the abandoned baby pattern effect.' label.new(bar_index, patternLabelPosHigh, text='AB', style=label.style_label_down, color=label_color_bearish, textcolor=color.white, tooltip=ttBearishAbandonedBaby) C_TriStarBullishNumberOfCandles = 3 C_3DojisBullish = C_Doji[2] and C_Doji[1] and C_Doji C_BodyGapUpBullish = C_BodyHi[1] < C_BodyLo C_BodyGapDnBullish = C_BodyLo[1] > C_BodyHi C_TriStarBullish = C_3DojisBullish and C_DownTrend[2] and C_BodyGapDnBullish[1] and C_BodyGapUpBullish alertcondition(C_TriStarBullish, title='Tri-Star – Bullish', message='New Tri-Star – Bullish pattern detected') if C_TriStarBullish and TriStarInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishTriStar = 'Tri-Star\nBullish reversal 60% of the time. A bullish TriStar candlestick pattern can form when three doji candlesticks materialize in immediate succession at the tail-end of an extended downtrend. The first doji candle marks indecision between bull and bear. The second doji gaps in the direction of the leading trend. The third changes the attitude of the market once the candlestick opens in the direction opposite to the trend. Each doji candle has a shadow, all comparatively shallow, which signify an interim cutback in volatility.' label.new(bar_index, patternLabelPosLow, text='3S', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttBullishTriStar) C_TriStarBearishNumberOfCandles = 3 C_3Dojis = C_Doji[2] and C_Doji[1] and C_Doji C_BodyGapUp = C_BodyHi[1] < C_BodyLo C_BodyGapDn = C_BodyLo[1] > C_BodyHi C_TriStarBearish = C_3Dojis and C_UpTrend[2] and C_BodyGapUp[1] and C_BodyGapDn alertcondition(C_TriStarBearish, title='Tri-Star – Bearish', message='New Tri-Star – Bearish pattern detected') if C_TriStarBearish and TriStarInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishTriStar = 'Tri-Star\nBearish reversal 52%. This particular pattern can form when three doji candlesticks appear in immediate succession at the end of an extended uptrend. The first doji candle marks indecision between bull and bear. The second doji gaps in the direction of the leading trend. The third changes the attitude of the market once the candlestick opens in the direction opposite to the trend. Each doji candle has a shadow, all comparatively shallow, which signify an interim cutback in volatility.' label.new(bar_index, patternLabelPosHigh, text='3S', style=label.style_label_down, color=label_color_bearish, textcolor=color.white, tooltip=ttBearishTriStar) C_KickingBullishNumberOfCandles = 2 C_MarubozuShadowPercent = 5.0 C_Marubozu = C_LongBody and C_UpShadow <= C_MarubozuShadowPercent / 100 * C_Body and C_DnShadow <= C_MarubozuShadowPercent / 100 * C_Body C_MarubozuWhiteBullishKicking = C_Marubozu and C_WhiteBody C_MarubozuBlackBullish = C_Marubozu and C_BlackBody C_KickingBullish = C_MarubozuBlackBullish[1] and C_MarubozuWhiteBullishKicking and high[1] < low alertcondition(C_KickingBullish, title='Kicking – Bullish', message='New Kicking – Bullish pattern detected') if C_KickingBullish and KickingInput and ('Bullish' == CandleType or CandleType == 'Both') var ttBullishKicking = 'Kicking\nBullish reversal 53% of the time. The first day candlestick is a bearish marubozu candlestick with next to no upper or lower shadow and where the price opens at the day’s high and closes at the day’s low. The second day is a bullish marubozu pattern, with next to no upper or lower shadow and where the price opens at the day’s low and closes at the day’s high. Additionally, the second day gaps up extensively and opens above the opening price of the day before. This gap or window, as the Japanese call it, lies between day one and day two’s bullish candlesticks.' label.new(bar_index, patternLabelPosLow, text='K', style=label.style_label_up, color=label_color_bullish, textcolor=color.white, tooltip=ttBullishKicking) C_KickingBearishNumberOfCandles = 2 C_MarubozuBullishShadowPercent = 5.0 C_MarubozuBearishKicking = C_LongBody and C_UpShadow <= C_MarubozuBullishShadowPercent / 100 * C_Body and C_DnShadow <= C_MarubozuBullishShadowPercent / 100 * C_Body C_MarubozuWhiteBearish = C_MarubozuBearishKicking and C_WhiteBody C_MarubozuBlackBearishKicking = C_MarubozuBearishKicking and C_BlackBody C_KickingBearish = C_MarubozuWhiteBearish[1] and C_MarubozuBlackBearishKicking and low[1] > high alertcondition(C_KickingBearish, title='Kicking – Bearish', message='New Kicking – Bearish pattern detected') if C_KickingBearish and KickingInput and ('Bearish' == CandleType or CandleType == 'Both') var ttBearishKicking = 'Kicking\nBearish reversal 54% of the time. A bearish kicking pattern will occur, subsequently signaling a reversal for a new downtrend. The first day candlestick is a bullish marubozu. The second day gaps down extensively and opens below the opening price of the day before. There is a gap between day one and two’s bearish candlesticks.' label.new(bar_index, patternLabelPosHigh, text='K', style=label.style_label_down, color=label_color_bearish, textcolor=color.white, tooltip=ttBearishKicking) var ttAllCandlestickPatterns = 'All Candlestick Patterns\n' label.new(bar_index, patternLabelPosLow, text='Collection', style=label.style_label_up, color=label_color_neutral, textcolor=color.white, tooltip=ttAllCandlestickPatterns)
Nadaraya-Watson Envelope [LuxAlgo]
https://www.tradingview.com/script/Iko0E2kL-Nadaraya-Watson-Envelope-LuxAlgo/
LuxAlgo
https://www.tradingview.com/u/LuxAlgo/
14,966
study
5
CC-BY-NC-SA-4.0
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/ // © LuxAlgo //@version=5 indicator("Nadaraya-Watson Envelope [LuxAlgo]", "LuxAlgo - Nadaraya-Watson Envelope", overlay = true, max_lines_count = 500, max_labels_count = 500, max_bars_back=500) //------------------------------------------------------------------------------ //Settings //-----------------------------------------------------------------------------{ h = input.float(8.,'Bandwidth', minval = 0) mult = input.float(3., minval = 0) src = input(close, 'Source') repaint = input(true, 'Repainting Smoothing', tooltip = 'Repainting is an effect where the indicators historical output is subject to change over time. Disabling repainting will cause the indicator to output the endpoints of the calculations') //Style upCss = input.color(color.teal, 'Colors', inline = 'inline1', group = 'Style') dnCss = input.color(color.red, '', inline = 'inline1', group = 'Style') //-----------------------------------------------------------------------------} //Functions //-----------------------------------------------------------------------------{ //Gaussian window gauss(x, h) => math.exp(-(math.pow(x, 2)/(h * h * 2))) //-----------------------------------------------------------------------------} //Append lines //-----------------------------------------------------------------------------{ n = bar_index var ln = array.new_line(0) if barstate.isfirst and repaint for i = 0 to 499 array.push(ln,line.new(na,na,na,na)) //-----------------------------------------------------------------------------} //End point method //-----------------------------------------------------------------------------{ var coefs = array.new_float(0) var den = 0. if barstate.isfirst and not repaint for i = 0 to 499 w = gauss(i, h) coefs.push(w) den := coefs.sum() out = 0. if not repaint for i = 0 to 499 out += src[i] * coefs.get(i) out /= den mae = ta.sma(math.abs(src - out), 499) * mult upper = out + mae lower = out - mae //-----------------------------------------------------------------------------} //Compute and display NWE //-----------------------------------------------------------------------------{ float y2 = na float y1 = na nwe = array.new<float>(0) if barstate.islast and repaint sae = 0. //Compute and set NWE point for i = 0 to math.min(499,n - 1) sum = 0. sumw = 0. //Compute weighted mean for j = 0 to math.min(499,n - 1) w = gauss(i - j, h) sum += src[j] * w sumw += w y2 := sum / sumw sae += math.abs(src[i] - y2) nwe.push(y2) sae := sae / math.min(499,n - 1) * mult for i = 0 to math.min(499,n - 1) if i%2 line.new(n-i+1, y1 + sae, n-i, nwe.get(i) + sae, color = upCss) line.new(n-i+1, y1 - sae, n-i, nwe.get(i) - sae, color = dnCss) if src[i] > nwe.get(i) + sae and src[i+1] < nwe.get(i) + sae label.new(n-i, src[i], '▼', color = color(na), style = label.style_label_down, textcolor = dnCss, textalign = text.align_center) if src[i] < nwe.get(i) - sae and src[i+1] > nwe.get(i) - sae label.new(n-i, src[i], '▲', color = color(na), style = label.style_label_up, textcolor = upCss, textalign = text.align_center) y1 := nwe.get(i) //-----------------------------------------------------------------------------} //Dashboard //-----------------------------------------------------------------------------{ var tb = table.new(position.top_right, 1, 1 , bgcolor = #1e222d , border_color = #373a46 , border_width = 1 , frame_color = #373a46 , frame_width = 1) if repaint tb.cell(0, 0, 'Repainting Mode Enabled', text_color = color.white, text_size = size.small) //-----------------------------------------------------------------------------} //Plot //-----------------------------------------------------------------------------} plot(repaint ? na : out + mae, 'Upper', upCss) plot(repaint ? na : out - mae, 'Lower', dnCss) //Crossing Arrows plotshape(ta.crossunder(close, out - mae) ? low : na, "Crossunder", shape.labelup, location.absolute, color(na), 0 , text = '▲', textcolor = upCss, size = size.tiny) plotshape(ta.crossover(close, out + mae) ? high : na, "Crossover", shape.labeldown, location.absolute, color(na), 0 , text = '▼', textcolor = dnCss, size = size.tiny) //-----------------------------------------------------------------------------}
STDev Bands
https://www.tradingview.com/script/LURVAugG-STDev-Bands/
Eliza123123
https://www.tradingview.com/u/Eliza123123/
178
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Eliza123123 //@version=4 study("STDev Bands", overlay = true) mean_last_bars = (sma(ohlc4, 1440)) stdev_last_bars = stdev(ohlc4, 1440) plot(mean_last_bars, color =color.white) plot(mean_last_bars + stdev_last_bars, color =color.red) plot(mean_last_bars - stdev_last_bars, color =color.red) plot(mean_last_bars + 2* stdev_last_bars, color =color.orange) plot(mean_last_bars - 2* stdev_last_bars, color =color.orange) plot(mean_last_bars + 3* stdev_last_bars, color =color.yellow) plot(mean_last_bars - 3* stdev_last_bars, color =color.yellow) plot(mean_last_bars + 4* stdev_last_bars, color =color.green) plot(mean_last_bars - 4* stdev_last_bars, color =color.green) plot(mean_last_bars + 5* stdev_last_bars, color =color.aqua) plot(mean_last_bars - 5* stdev_last_bars, color =color.aqua) plot(mean_last_bars + 6* stdev_last_bars, color =color.purple) plot(mean_last_bars - 6* stdev_last_bars, color =color.purple) plot(mean_last_bars + 7* stdev_last_bars, color =color.fuchsia) plot(mean_last_bars - 7* stdev_last_bars, color =color.fuchsia)
MACD With Crossings and Above Below Zero
https://www.tradingview.com/script/yGOHM7mz-MACD-With-Crossings-and-Above-Below-Zero/
Kgroomes
https://www.tradingview.com/u/Kgroomes/
98
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Kgroomes //@version=4 study(title="MACD With Crossings and Above Below Zero", shorttitle="MACD Xs & 0", resolution="") // Getting inputs fast_length = input(title="Fast Length", type=input.integer, defval=12) slow_length = input(title="Slow Length", type=input.integer, defval=26) src = input(title="Source", type=input.source, defval=close) signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9) sma_source = input(title="Simple MA(Oscillator)", type=input.bool, defval=false) sma_signal = input(title="Simple MA(Signal Line)", type=input.bool, defval=false) // Plot colors col_grow_above = #26A69A col_grow_below = #FFCDD2 col_fall_above = #B2DFDB col_fall_below = #EF5350 col_macd = #0094ff col_signal = #ff6a00 // Calculating fast_ma = sma_source ? sma(src, fast_length) : ema(src, fast_length) slow_ma = sma_source ? sma(src, slow_length) : ema(src, slow_length) macd = fast_ma - slow_ma signal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length) hist = macd - signal //ADX orginal adxlen = input(14, title="ADX Smoothing") dilen = input(14, title="DI Length") dirmov(len) => ADXup = change(high) ADXdown = -change(low) plusDM = na(ADXup) ? na : (ADXup > ADXdown and ADXup > 0 ? ADXup : 0) minusDM = na(ADXdown) ? na : (ADXdown > ADXup and ADXdown > 0 ? ADXdown : 0) truerange = rma(tr, adxlen) plus = fixnan(100 * rma(plusDM, adxlen) / truerange) minus = fixnan(100 * rma(minusDM, adxlen) / truerange) [plus, minus] adx(dilen, adxlen) => [plus, minus] = dirmov(dilen) sum = plus + minus adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen) sig = adx(dilen, adxlen) plot(sig, title="ADX", display=display.none) plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below) ), transp=50 ) //background color based on ADX bcol = sig>= 25 ? color.red : sig <= 25 ? color.blue : na bgcolor(bcol, transp=85) //Re-Coloring the MACD When Greater than Zero plot(macd, title="MACD", color = macd <= 0 ? #00477d : #00f0ff, transp=0) plot(signal, title="Signal", color = signal <= 0 ? #ff2600 : #ff6a00, transp=0) //Adding Change in MACD to Show Turning Points plot(change(macd), title="MACD Derivative", color = #ffff00, transp=50) //Adding MACD Crossings Up and Down with Plotted Triangles...Bigger Double Triangles for Crossing Above/Below Zero xUp = iff (macd > 0,crossover(signal, macd),na) xDn = iff (macd < 0,crossunder(signal, macd),na) xDnHigh = iff (macd >= 0,crossunder(signal, macd),na) xUpLow = iff (macd <= 0,crossover(signal, macd),na) plotshape(xUp, title="MACD X Up", style=shape.triangledown, size=size.tiny, location=location.top, color=color.red) plotshape(xDn, title="MACD X Dn", style=shape.triangleup, size=size.tiny, location=location.bottom, color=color.green) plotshape(xDnHigh, title="Big MACD X Up", style=shape.triangleup, size=size.small, location=location.bottom, color=color.green) plotshape(xUpLow, title="Big MACD X Dn", style=shape.triangledown, size=size.small, location=location.top, color=color.red) //RSI rsi_len = input(14, minval=1, title="Length") rsi_src = input(close, "Source", type = input.source) rsi_up = rma(max(change(rsi_src), 0), rsi_len) rsi_down = rma(-min(change(rsi_src), 0), rsi_len) rsi = (rsi_down == 0 ? 100 : rsi_up == 0 ? 0 : 100 - (100 / (1 + rsi_up / rsi_down)))/100 plot(rsi, "RSI", color=color.yellow) rsi_band1 = hline(.70, "Upper Band", color=#C0C0C0) rsi_band0 = hline(.30, "Lower Band", color=#C0C0C0) fill(rsi_band1, rsi_band0, color=#9915FF, transp=90, title="Background")
Auto Fib Golden Pocket Band - Autofib Moving Average
https://www.tradingview.com/script/3DcdyBpW-Auto-Fib-Golden-Pocket-Band-Autofib-Moving-Average/
imal_max
https://www.tradingview.com/u/imal_max/
80
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © imal_max reeee //@version=5 //strategy(title="Auto Fib Golden Pocket Band - Strategy", shorttitle="Auto Fib Golden Pocket Band", overlay=true, pyramiding=15, process_orders_on_close=true, calc_on_every_tick=true, initial_capital=10000, currency = currency.USD, default_qty_value=100, default_qty_type=strategy.percent_of_equity, commission_type=strategy.commission.percent, commission_value=0.05, slippage=2) indicator("Auto Fib Golden Pocket Band - Autofib Moving Average", overlay=true, shorttitle="Auto Fib Golden Pocket Band", timeframe="") // Fibs // auto fib ranges // fib band Strong Trend enable_StrongBand_Bull = input.bool(title='enable Upper Bullish Band . . . Fib Level', defval=true, group='══════ Strong Trend Levels ══════', inline="0") select_StrongBand_Fib_Bull = input.float(0.236, title=" ", options=[-0.272, 0, 0.236, 0.382, 0.5, 0.618, 0.702, 0.71, 0.786, 0.83, 0.886, 1, 1.272], group='══════ Strong Trend Levels ══════', inline="0") enable_StrongBand_Bear = input.bool(title='enable Lower Bearish Band . . . Fib Level', defval=false, group='══════ Strong Trend Levels ══════', inline="1") select_StrongBand_Fib_Bear = input.float(0.382, '', options=[-0.272, 0, 0.236, 0.382, 0.5, 0.618, 0.702, 0.71, 0.786, 0.83, 0.886, 1, 1.272], group='══════ Strong Trend Levels ══════', inline="1") StrongBand_Lookback = input.int(title='Pivot Look Back', minval=1, defval=400, group='══════ Strong Trend Levels ══════', inline="2") StrongBand_EmaLen = input.int(title='Fib EMA Length', minval=1, defval=120, group='══════ Strong Trend Levels ══════', inline="2") // fib middle Band regular Trend enable_MiddleBand_Bull = input.bool(title='enable Middle Bullish Band . . . Fib Level', defval=true, group='══════ Regular Trend Levels ══════', inline="0") select_MiddleBand_Fib_Bull = input.float(0.618, '', options=[-0.272, 0, 0.236, 0.382, 0.5, 0.6, 0.618, 0.702, 0.71, 0.786, 0.83, 0.886, 1, 1.272], group='══════ Regular Trend Levels ══════', inline="0") enable_MiddleBand_Bear = input.bool(title='enable Middle Bearish Band . . . Fib Level', defval=true, group='══════ Regular Trend Levels ══════', inline="1") select_MiddleBand_Fib_Bear = input.float(0.382, '', options=[-0.272, 0, 0.236, 0.382, 0.5, 0.618, 0.702, 0.71, 0.786, 0.83, 0.886, 1, 1.272], group='══════ Regular Trend Levels ══════', inline="1") MiddleBand_Lookback = input.int(title='Pivot Look Back', minval=1, defval=900, group='══════ Regular Trend Levels ══════', inline="2") MiddleBand_EmaLen = input.int(title='Fib EMA Length', minval=1, defval=400, group='══════ Regular Trend Levels ══════', inline="2") // fib Sideways Band enable_SidewaysBand_Bull = input.bool(title='enable Lower Bullish Band . . . Fib Level', defval=true, group='══════ Sideways Trend Levels ══════', inline="0") select_SidewaysBand_Fib_Bull = input.float(0.6, '', options=[-0.272, 0, 0.236, 0.382, 0.5, 0.6, 0.618, 0.702, 0.71, 0.786, 0.83, 0.886, 1, 1.272], group='══════ Sideways Trend Levels ══════', inline="0") enable_SidewaysBand_Bear = input.bool(title='enable Upper Bearish Band . . . Fib Level', defval=true, group='══════ Sideways Trend Levels ══════', inline="1") select_SidewaysBand_Fib_Bear = input.float(0.5, '', options=[-0.272, 0, 0.236, 0.382, 0.5, 0.618, 0.702, 0.71, 0.786, 0.83, 0.886, 1, 1.272], group='══════ Sideways Trend Levels ══════', inline="1") SidewaysBand_Lookback = input.int(title='Pivot Look Back', minval=1, defval=4000, group='══════ Sideways Trend Levels ══════', inline="2") SidewaysBand_EmaLen = input.int(title='Fib EMA Length', minval=1, defval=150, group='══════ Sideways Trend Levels ══════', inline="2") // Strong Band isBelow_StrongBand_Bull = true isBelow_StrongBand_Bear = true StrongBand_Price_of_Low = float(na) StrongBand_Price_of_High = float(na) StrongBand_Bear_Fib_Price = float(na) StrongBand_Bull_Fib_Price = float(na) /// Middle Band isBelow_MiddleBand_Bull = true isBelow_MiddleBand_Bear = true MiddleBand_Price_of_Low = float(na) MiddleBand_Price_of_High = float(na) MiddleBand_Bear_Fib_Price = float(na) MiddleBand_Bull_Fib_Price = float(na) // Sideways Band isBelow_SidewaysBand_Bull = true isBelow_SidewaysBand_Bear = true SidewaysBand_Price_of_Low = float(na) SidewaysBand_Price_of_High = float(na) SidewaysBand_Bear_Fib_Price = float(na) SidewaysBand_Bull_Fib_Price = float(na) // get Fib Levels if enable_StrongBand_Bull StrongBand_Price_of_High := ta.highest(high, StrongBand_Lookback) StrongBand_Price_of_Low := ta.lowest(low, StrongBand_Lookback) StrongBand_Bull_Fib_Price := (StrongBand_Price_of_High - StrongBand_Price_of_Low) * (1 - select_StrongBand_Fib_Bull) + StrongBand_Price_of_Low //+ fibbullHighDivi isBelow_StrongBand_Bull := StrongBand_Bull_Fib_Price > ta.lowest(low, 2) or not enable_StrongBand_Bull if enable_StrongBand_Bear StrongBand_Price_of_High := ta.highest(high, StrongBand_Lookback) StrongBand_Price_of_Low := ta.lowest(low, StrongBand_Lookback) StrongBand_Bear_Fib_Price := (StrongBand_Price_of_High - StrongBand_Price_of_Low) * (1 - select_StrongBand_Fib_Bear) + StrongBand_Price_of_Low// + fibbullLowhDivi isBelow_StrongBand_Bear := StrongBand_Bear_Fib_Price < ta.highest(low, 2) or not enable_StrongBand_Bear if enable_MiddleBand_Bull MiddleBand_Price_of_High := ta.highest(high, MiddleBand_Lookback) MiddleBand_Price_of_Low := ta.lowest(low, MiddleBand_Lookback) MiddleBand_Bull_Fib_Price := (MiddleBand_Price_of_High - MiddleBand_Price_of_Low) * (1 - select_MiddleBand_Fib_Bull) + MiddleBand_Price_of_Low //+ fibbullHighDivi isBelow_MiddleBand_Bull := MiddleBand_Bull_Fib_Price > ta.lowest(low, 2) or not enable_MiddleBand_Bull if enable_MiddleBand_Bear MiddleBand_Price_of_High := ta.highest(high, MiddleBand_Lookback) MiddleBand_Price_of_Low := ta.lowest(low, MiddleBand_Lookback) MiddleBand_Bear_Fib_Price := (MiddleBand_Price_of_High - MiddleBand_Price_of_Low) * (1 - select_MiddleBand_Fib_Bear) + MiddleBand_Price_of_Low// + fibbullLowhDivi isBelow_MiddleBand_Bear := MiddleBand_Bear_Fib_Price < ta.highest(low, 2) or not enable_MiddleBand_Bear if enable_SidewaysBand_Bull SidewaysBand_Price_of_High := ta.highest(high, SidewaysBand_Lookback) SidewaysBand_Price_of_Low := ta.lowest(low, SidewaysBand_Lookback) SidewaysBand_Bull_Fib_Price := (SidewaysBand_Price_of_High - SidewaysBand_Price_of_Low) * (1 - select_SidewaysBand_Fib_Bull) + SidewaysBand_Price_of_Low //+ fibbullHighDivi isBelow_SidewaysBand_Bull := SidewaysBand_Bull_Fib_Price > ta.lowest(low, 2) or not enable_SidewaysBand_Bull if enable_SidewaysBand_Bear SidewaysBand_Price_of_High := ta.highest(high, SidewaysBand_Lookback) SidewaysBand_Price_of_Low := ta.lowest(low, SidewaysBand_Lookback) SidewaysBand_Bear_Fib_Price := (SidewaysBand_Price_of_High - SidewaysBand_Price_of_Low) * (1 - select_SidewaysBand_Fib_Bear) + SidewaysBand_Price_of_Low// + fibbullLowhDivi isBelow_SidewaysBand_Bear := SidewaysBand_Bear_Fib_Price < ta.highest(low, 2) or not enable_SidewaysBand_Bear // Fib EMAs // fib ema Strong Trend StrongBand_current_Trend_EMA = float(na) StrongBand_Bull_EMA = ta.ema(StrongBand_Bull_Fib_Price, StrongBand_EmaLen) StrongBand_Bear_EMA = ta.ema(StrongBand_Bear_Fib_Price, StrongBand_EmaLen) StrongBand_Ema_in_Uptrend = ta.change(StrongBand_Bull_EMA) > 0 or ta.change(StrongBand_Bear_EMA) > 0 StrongBand_Ema_Sideways = ta.change(StrongBand_Bull_EMA) == 0 or ta.change(StrongBand_Bear_EMA) == 0 StrongBand_Ema_in_Downtrend = ta.change(StrongBand_Bull_EMA) < 0 or ta.change(StrongBand_Bear_EMA) < 0 if StrongBand_Ema_in_Uptrend or StrongBand_Ema_Sideways StrongBand_current_Trend_EMA := StrongBand_Bull_EMA if StrongBand_Ema_in_Downtrend StrongBand_current_Trend_EMA := StrongBand_Bear_EMA // fib ema Normal Trend MiddleBand_current_Trend_EMA = float(na) MiddleBand_Bull_EMA = ta.ema(MiddleBand_Bull_Fib_Price, MiddleBand_EmaLen) MiddleBand_Bear_EMA = ta.ema(MiddleBand_Bear_Fib_Price, MiddleBand_EmaLen) MiddleBand_Ema_in_Uptrend = ta.change(MiddleBand_Bull_EMA) > 0 or ta.change(MiddleBand_Bear_EMA) > 0 MiddleBand_Ema_Sideways = ta.change(MiddleBand_Bull_EMA) == 0 or ta.change(MiddleBand_Bear_EMA) == 0 MiddleBand_Ema_in_Downtrend = ta.change(MiddleBand_Bull_EMA) < 0 or ta.change(MiddleBand_Bear_EMA) < 0 if MiddleBand_Ema_in_Uptrend or MiddleBand_Ema_Sideways MiddleBand_current_Trend_EMA := MiddleBand_Bull_EMA if MiddleBand_Ema_in_Downtrend MiddleBand_current_Trend_EMA := MiddleBand_Bear_EMA // fib ema Sideways Trend SidewaysBand_current_Trend_EMA = float(na) SidewaysBand_Bull_EMA = ta.ema(SidewaysBand_Bull_Fib_Price, SidewaysBand_EmaLen) SidewaysBand_Bear_EMA = ta.ema(SidewaysBand_Bear_Fib_Price, SidewaysBand_EmaLen) SidewaysBand_Ema_in_Uptrend = ta.change(SidewaysBand_Bull_EMA) > 0 or ta.change(SidewaysBand_Bear_EMA) > 0 SidewaysBand_Ema_Sideways = ta.change(SidewaysBand_Bull_EMA) == 0 or ta.change(SidewaysBand_Bear_EMA) == 0 SidewaysBand_Ema_in_Downtrend = ta.change(SidewaysBand_Bull_EMA) < 0 or ta.change(SidewaysBand_Bear_EMA) < 0 if SidewaysBand_Ema_in_Uptrend or SidewaysBand_Ema_Sideways SidewaysBand_current_Trend_EMA := SidewaysBand_Bull_EMA if SidewaysBand_Ema_in_Downtrend SidewaysBand_current_Trend_EMA := SidewaysBand_Bear_EMA // trend states and colors all_Fib_Emas_Trending = StrongBand_Ema_in_Uptrend and MiddleBand_Ema_in_Uptrend and SidewaysBand_Ema_in_Uptrend all_Fib_Emas_Downtrend = MiddleBand_Ema_in_Downtrend and StrongBand_Ema_in_Downtrend and SidewaysBand_Ema_in_Downtrend all_Fib_Emas_Sideways = MiddleBand_Ema_Sideways and StrongBand_Ema_Sideways and SidewaysBand_Ema_Sideways all_Fib_Emas_Trend_or_Sideways = (MiddleBand_Ema_Sideways or StrongBand_Ema_Sideways or SidewaysBand_Ema_Sideways) or (StrongBand_Ema_in_Uptrend or MiddleBand_Ema_in_Uptrend or SidewaysBand_Ema_in_Uptrend) and not (MiddleBand_Ema_in_Downtrend or StrongBand_Ema_in_Downtrend or SidewaysBand_Ema_in_Downtrend) allFibsUpAndDownTrend = (MiddleBand_Ema_in_Downtrend or StrongBand_Ema_in_Downtrend or SidewaysBand_Ema_in_Downtrend) and (MiddleBand_Ema_Sideways or SidewaysBand_Ema_Sideways or StrongBand_Ema_Sideways or StrongBand_Ema_in_Uptrend or MiddleBand_Ema_in_Uptrend or SidewaysBand_Ema_in_Uptrend) Middle_and_Sideways_Emas_Trending = MiddleBand_Ema_in_Uptrend and SidewaysBand_Ema_in_Uptrend Middle_and_Sideways_Fib_Emas_Downtrend = MiddleBand_Ema_in_Downtrend and SidewaysBand_Ema_in_Downtrend Middle_and_Sideways_Fib_Emas_Sideways = MiddleBand_Ema_Sideways and SidewaysBand_Ema_Sideways Middle_and_Sideways_Fib_Emas_Trend_or_Sideways = (MiddleBand_Ema_Sideways or SidewaysBand_Ema_Sideways) or (MiddleBand_Ema_in_Uptrend or SidewaysBand_Ema_in_Uptrend) and not (MiddleBand_Ema_in_Downtrend or SidewaysBand_Ema_in_Downtrend) Middle_and_Sideways_UpAndDownTrend = (MiddleBand_Ema_in_Downtrend or SidewaysBand_Ema_in_Downtrend) and (MiddleBand_Ema_Sideways or SidewaysBand_Ema_Sideways or MiddleBand_Ema_in_Uptrend or SidewaysBand_Ema_in_Uptrend) UpperBand_Ema_Color = all_Fib_Emas_Trend_or_Sideways ? color.lime : all_Fib_Emas_Downtrend ? color.red : allFibsUpAndDownTrend ? color.white : na MiddleBand_Ema_Color = Middle_and_Sideways_Fib_Emas_Trend_or_Sideways ? color.lime : Middle_and_Sideways_Fib_Emas_Downtrend ? color.red : Middle_and_Sideways_UpAndDownTrend ? color.white : na SidewaysBand_Ema_Color = SidewaysBand_Ema_in_Uptrend ? color.lime : SidewaysBand_Ema_in_Downtrend ? color.red : (SidewaysBand_Ema_in_Downtrend and (SidewaysBand_Ema_Sideways or SidewaysBand_Ema_in_Uptrend)) ? color.white : na plotStrong_Ema = plot(StrongBand_current_Trend_EMA, color=UpperBand_Ema_Color, title="Strong Trend") plotMiddle_Ema = plot(MiddleBand_current_Trend_EMA, color=MiddleBand_Ema_Color, title="Normal Trend") plotSideways_Ema = plot(SidewaysBand_current_Trend_EMA, color=SidewaysBand_Ema_Color, title="Sidewaysd") Strong_Middle_fillcolor = color.new(color.green, 90) if all_Fib_Emas_Trend_or_Sideways Strong_Middle_fillcolor := color.new(color.green, 90) if all_Fib_Emas_Downtrend Strong_Middle_fillcolor := color.new(color.red, 90) if allFibsUpAndDownTrend Strong_Middle_fillcolor := color.new(color.white, 90) Middle_Sideways_fillcolor = color.new(color.green, 90) if Middle_and_Sideways_Fib_Emas_Trend_or_Sideways Middle_Sideways_fillcolor := color.new(color.green, 90) if Middle_and_Sideways_Fib_Emas_Downtrend Middle_Sideways_fillcolor := color.new(color.red, 90) if Middle_and_Sideways_UpAndDownTrend Middle_Sideways_fillcolor := color.new(color.white, 90) fill(plotStrong_Ema, plotMiddle_Ema, color=Strong_Middle_fillcolor, title="fib band background") fill(plotMiddle_Ema, plotSideways_Ema, color=Middle_Sideways_fillcolor, title="fib band background") // buy condition StrongBand_Price_was_below_Bull_level = ta.lowest(low, 1) < StrongBand_current_Trend_EMA StrongBand_Price_is_above_Bull_level = close > StrongBand_current_Trend_EMA StronBand_Price_Average_above_Bull_Level = ta.ema(low, 10) > StrongBand_current_Trend_EMA StrongBand_Low_isnt_toLow = (ta.lowest(StrongBand_current_Trend_EMA, 15) - ta.lowest(low, 15)) < close * 0.005 StronBand_Trend_isnt_fresh = ta.barssince(StrongBand_Ema_in_Downtrend) > 50 or na(ta.barssince(StrongBand_Ema_in_Downtrend)) MiddleBand_Price_was_below_Bull_level = ta.lowest(low, 1) < MiddleBand_current_Trend_EMA MiddleBand_Price_is_above_Bull_level = close > MiddleBand_current_Trend_EMA MiddleBand_Price_Average_above_Bull_Level = ta.ema(close, 20) > MiddleBand_current_Trend_EMA MiddleBand_Low_isnt_toLow = (ta.lowest(MiddleBand_current_Trend_EMA, 10) - ta.lowest(low, 10)) < close * 0.0065 MiddleBand_Trend_isnt_fresh = ta.barssince(MiddleBand_Ema_in_Downtrend) > 50 or na(ta.barssince(MiddleBand_Ema_in_Downtrend)) SidewaysBand_Price_was_below_Bull_level = ta.lowest(low, 1) < SidewaysBand_current_Trend_EMA SidewaysBand_Price_is_above_Bull_level = close > SidewaysBand_current_Trend_EMA SidewaysBand_Price_Average_above_Bull_Level = ta.ema(low, 80) > SidewaysBand_current_Trend_EMA SidewaysBand_Low_isnt_toLow = (ta.lowest(SidewaysBand_current_Trend_EMA, 150) - ta.lowest(low, 150)) < close * 0.0065 SidewaysBand_Trend_isnt_fresh = ta.barssince(SidewaysBand_Ema_in_Downtrend) > 50 or na(ta.barssince(SidewaysBand_Ema_in_Downtrend)) StrongBand_Buy_Alert = StronBand_Trend_isnt_fresh and StrongBand_Low_isnt_toLow and StronBand_Price_Average_above_Bull_Level and StrongBand_Price_was_below_Bull_level and StrongBand_Price_is_above_Bull_level and all_Fib_Emas_Trend_or_Sideways MiddleBand_Buy_Alert = MiddleBand_Trend_isnt_fresh and MiddleBand_Low_isnt_toLow and MiddleBand_Price_Average_above_Bull_Level and MiddleBand_Price_was_below_Bull_level and MiddleBand_Price_is_above_Bull_level and Middle_and_Sideways_Fib_Emas_Trend_or_Sideways SidewaysBand_Buy_Alert = SidewaysBand_Trend_isnt_fresh and SidewaysBand_Low_isnt_toLow and SidewaysBand_Price_Average_above_Bull_Level and SidewaysBand_Price_was_below_Bull_level and SidewaysBand_Price_is_above_Bull_level and (SidewaysBand_Ema_Sideways or SidewaysBand_Ema_in_Uptrend and ( not SidewaysBand_Ema_in_Downtrend)) // Sell condition StrongBand_Price_was_above_Bear_level = ta.highest(high, 1) > StrongBand_current_Trend_EMA StrongBand_Price_is_below_Bear_level = close < StrongBand_current_Trend_EMA StronBand_Price_Average_below_Bear_Level = ta.sma(high, 10) < StrongBand_current_Trend_EMA StrongBand_High_isnt_to_High = (ta.highest(high, 15) - ta.highest(StrongBand_current_Trend_EMA, 15)) < close * 0.005 StrongBand_Bear_Trend_isnt_fresh = ta.barssince(StrongBand_Ema_in_Uptrend) > 50 MiddleBand_Price_was_above_Bear_level = ta.highest(high, 1) > MiddleBand_current_Trend_EMA MiddleBand_Price_is_below_Bear_level = close < MiddleBand_current_Trend_EMA MiddleBand_Price_Average_below_Bear_Level = ta.sma(high, 9) < MiddleBand_current_Trend_EMA MiddleBand_High_isnt_to_High = (ta.highest(high, 10) - ta.highest(MiddleBand_current_Trend_EMA, 10)) < close * 0.0065 MiddleBand_Bear_Trend_isnt_fresh = ta.barssince(MiddleBand_Ema_in_Uptrend) > 50 SidewaysBand_Price_was_above_Bear_level = ta.highest(high, 1) > SidewaysBand_current_Trend_EMA SidewaysBand_Price_is_below_Bear_level = close < SidewaysBand_current_Trend_EMA SidewaysBand_Price_Average_below_Bear_Level = ta.sma(high, 20) < SidewaysBand_current_Trend_EMA SidewaysBand_High_isnt_to_High = (ta.highest(high, 20) - ta.highest(SidewaysBand_current_Trend_EMA, 15)) < close * 0.0065 SidewaysBand_Bear_Trend_isnt_fresh = ta.barssince(SidewaysBand_Ema_in_Uptrend) > 50 StrongBand_Sell_Alert = StronBand_Price_Average_below_Bear_Level and StrongBand_High_isnt_to_High and StrongBand_Bear_Trend_isnt_fresh and StrongBand_Price_was_above_Bear_level and StrongBand_Price_is_below_Bear_level and all_Fib_Emas_Downtrend and not all_Fib_Emas_Trend_or_Sideways MiddleBand_Sell_Alert = MiddleBand_Price_Average_below_Bear_Level and MiddleBand_High_isnt_to_High and MiddleBand_Bear_Trend_isnt_fresh and MiddleBand_Price_was_above_Bear_level and MiddleBand_Price_is_below_Bear_level and Middle_and_Sideways_Fib_Emas_Downtrend and not Middle_and_Sideways_Fib_Emas_Trend_or_Sideways SidewaysBand_Sell_Alert = SidewaysBand_Price_Average_below_Bear_Level and SidewaysBand_High_isnt_to_High and SidewaysBand_Bear_Trend_isnt_fresh and SidewaysBand_Price_was_above_Bear_level and SidewaysBand_Price_is_below_Bear_level and SidewaysBand_Ema_in_Downtrend and not (SidewaysBand_Ema_Sideways or SidewaysBand_Ema_in_Uptrend and ( not SidewaysBand_Ema_in_Downtrend))
Momentum and Acceleration
https://www.tradingview.com/script/kGuSqfpe-Momentum-and-Acceleration/
animecummer
https://www.tradingview.com/u/animecummer/
242
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //Credit: This script utilizes the "Color Gradient Framework" tutorial by LucF (PineCoders) to create gradient visuals, which are also customizable for the user. //@version=5 //INPUT indicator(title='Momentum and Acceleration', shorttitle='Momentum & Acceleration', overlay=false, timeframe="", timeframe_gaps=true) source = input.source(close, 'Source', inline='Source') len = input.int(10, minval=1, title='Length', inline='Source') choice = input.string(title='Modifier', defval='Source Only', options=['Source * Volume', 'Volume Only', 'Source Only'], inline='0') scaleosc = input.bool(true, 'Divide calculation by length? (Only affects scaling, 1st deriv is equivalent to built-in momentum indicator when unchecked, unchecked may help seeing acceleration easier)', inline='10') //CALCS dp = choice == 'Source * Volume' ? source * volume - source[len] * volume[len] : choice == 'Volume Only' ? volume - volume[len] : choice == 'Source Only' ? source - source[len] : na dt = scaleosc == true ? len : 1 mom = dp / dt dmom = mom - mom[len] acc = dmom / dt //PLOT INPUTS show_1d = input.bool(true, 'Show?', inline='1', group='1st Derivative - Momentum') grow1 = input.color(color.green, 'Grow', group='1st Derivative - Momentum', inline='2') fall1 = input.color(color.red, 'Fall', group='1st Derivative - Momentum', inline='2') bullfill = input.color(color.lime, 'Bull Fill', group='1st Derivative - Momentum', inline='2') bearfill = input.color(color.fuchsia, 'Bear Fill', group='1st Derivative - Momentum', inline='2') show_2d = input.bool(true, 'Show?', inline='3', group='2nd Derivative - Acceleration') grow2 = input.color(color.blue, 'Grow', group='2nd Derivative - Acceleration', inline='4') fall2 = input.color(color.orange, 'Fall', group='2nd Derivative - Acceleration', inline='4') bullfill2 = input.color(color.aqua, 'Bull Fill', group='2nd Derivative - Acceleration', inline='4') bearfill2 = input.color(color.yellow, 'Bear Fill', group='2nd Derivative - Acceleration', inline='4') //GRADIENT gradmult = input.float(1, title='Gradient \'Intensity\' (Higher = more intense)', step=0.01, group='Plot Color and Label Settings', inline='6') gradconst = input.int(1, title='Gradient Constant (Higher = less intense)', minval=-100, maxval=100, group='Plot Color and Label Settings', inline='7') gradlimit = input.int(99, title='Transparency Limit', minval=0, maxval=100, group='Plot Color and Label Settings', inline='8') colorgrad = input.bool(defval=true, title='Fill Gradient?', group='Plot Color and Label Settings', inline='8') // ————————————————————————————————————————— // ————— Advance/Decline Gradient (Credit: LucF from PineCoders) // ————————————————————————————————————————— // ————— Function returning one of the bull/bear colors in a transparency proportional to the current qty of advances/declines // relative to the historical max qty of adv/dec for this `_source`. f_c_gradientAdvDec(_source, _center, _c_bear, _c_bull) => // float _source: input signal. // float _center: centerline used to determine if signal is bull/bear. // color _c_bear: most bearish color. // color _c_bull: most bullish color. // Dependency: `f_colorNew()` var float _maxAdvDec = 0. var float _qtyAdvDec = 0. bool _xUp = ta.crossover(_source, _center) bool _xDn = ta.crossunder(_source, _center) float _chg = ta.change(_source) bool _up = _chg > 0 bool _dn = _chg < 0 bool _srcBull = _source > _center bool _srcBear = _source < _center _qtyAdvDec := _srcBull ? _xUp ? 1 : _up ? _qtyAdvDec + 1 : _dn ? math.max(1, _qtyAdvDec - 1) : _qtyAdvDec : _srcBear ? _xDn ? 1 : _dn ? _qtyAdvDec + 1 : _up ? math.max(1, _qtyAdvDec - 1) : _qtyAdvDec : _qtyAdvDec // Keep track of max qty of advances/declines. _maxAdvDec := math.max(_maxAdvDec, _qtyAdvDec) // Calculate transparency from the current qty of advances/declines relative to the historical max qty of adv/dec for this `_source`. float _transp = 100 - _qtyAdvDec * 100 / _maxAdvDec * gradmult + gradconst _transp2 = _transp > gradlimit ? gradlimit : _transp var color _return = na _return := _srcBull ? color.new(_c_bull, _transp2) : _srcBear ? color.new(_c_bear, _transp2) : _return _return //PLOTS p0 = hline(0, title='Zero', color=color.gray, linestyle=hline.style_dashed) p1 = plot(show_1d ? mom : na, title='1st Deriv', linewidth=2, color=mom > mom[1] ? grow1 : fall1, style=plot.style_line) p2 = plot(show_2d ? acc : na, title='2nd Deriv', linewidth=2, color=acc > acc[1] ? grow2 : fall2, style=plot.style_line) color c_1 = f_c_gradientAdvDec(mom, 0, bearfill, bullfill) color c_2 = f_c_gradientAdvDec(acc, 0, bearfill2, bullfill2) fill(p1, plot(0), colorgrad == true ? c_1 : color.new(color.white, 100), title='Momentum Fill') fill(plot(0), p2, colorgrad == true ? c_2 : color.new(color.white, 100), title='Acceleration Fill')
Divergence-Support/Resistence
https://www.tradingview.com/script/UkaoD896-Divergence-Support-Resistence/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
3,067
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © HeWhoMustNotBeNamed // __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __ // / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / | // $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ | // $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ | // $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ | // $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ | // $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ | // $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ | // $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/ // // // //@version=5 indicator("Divergence-Support/Resistence", shorttitle="DSR", overlay=true, max_lines_count=500, max_labels_count=500, max_bars_back=500) import HeWhoMustNotBeNamed/zigzag/3 as zg import HeWhoMustNotBeNamed/enhanced_ta/8 as eta import HeWhoMustNotBeNamed/supertrend/4 as st maxItems = input.int(10, step=5, title="Max Depth") showZigzag1 = input.bool(true, "", group="Zigzag", inline="z1") zigzag1Length = input.int(8, "", group="Zigzag", inline="z1") showZigzag2 = input.bool(true, "", group="Zigzag", inline="z2") zigzag2Length = input.int(13, "", group="Zigzag", inline="z2") var useAlternativeSource = true source = close oscillatorType = input.string('rsi', title='Oscillator Source       ', options=["cci", "cmo", "cog", "mfi", "roc", "rsi", "stoch", "tsi", "wpr"], group='Oscillator', inline='osc') useExternalSource = input.bool(false, title='External Source', group='Oscillator', inline="osce") externalSource = input.source(close, title='', group='Oscillator', inline="osce") var history = 1 var waitForClose = true var atrMaType = "rma" var atrMultiplier = 1 add_to_array(arr, val, maxItems)=> array.unshift(arr, val) if(array.size(arr) > maxItems) array.pop(arr) add_to_line_array(arr, val, maxItems)=> array.unshift(arr, val) if(array.size(arr) > maxItems) line.delete(array.pop(arr)) add_to_label_array(arr, val, maxItems)=> array.unshift(arr, val) if(array.size(arr) > maxItems) label.delete(array.pop(arr)) getSentimentDetails(sentiment) => [sentimentSymbol, sentimentColor] = switch sentiment 4 => ['⬆', color.green] -4 => ['⬇', color.red] 3 => ['↗', color.lime] -3 => ['↘', color.orange] 2 => ['⤴',color.rgb(202, 224, 13, 0)] -2 => ['⤵',color.rgb(250, 128, 114, 0)] => ['▣', color.silver] [sentimentSymbol, sentimentColor] plot_support_resistence(showZigzag, zigzagLength, srArray, lnArray, lblArray, maxItems, largest)=> if(showZigzag) length = zigzagLength * 3 longLength = zigzagLength*5 atrLength = zigzagLength*5 [oscillator, overbought, oversold] = eta.oscillator(oscillatorType, length, length, longLength) [dir_zigzag, supertrend] = st.supertrend_zigzag(length=zigzagLength, history = history, useAlternativeSource = useAlternativeSource, alternativeSource=source, waitForClose=waitForClose, atrlength=atrLength, multiplier=atrMultiplier, atrMaType=atrMaType) [zigzagpivots, zigzagpivotbars, zigzagpivotdirs, zigzagpivotratios, zigzagoscillators, zigzagoscillatordirs, zigzagtrendbias, zigzagdivergence, newPivot, doublePivot] = zg.zigzag(zigzagLength, oscillatorSource=useExternalSource ? externalSource : oscillator, directionBias = dir_zigzag) if(array.size(zigzagpivots)>1) price = array.get(zigzagpivots, 1) divergence = array.get(zigzagdivergence, 1) if(math.abs(divergence) == 2 or math.abs(divergence) == 3) if(array.indexof(srArray, price) == -1) add_to_array(srArray, price, maxItems) [sentimentSymbol, sentimentColor] = getSentimentDetails(divergence) lblSize = largest? size.normal : size.small lnStyle = largest? line.style_solid : line.style_dashed ln = line.new(time, price, time+1, price, extend=extend.right, xloc=xloc.bar_time, color=sentimentColor, style=lnStyle, width=largest? 1 : 0) lbl = label.new(time, price, sentimentSymbol, color=sentimentColor, xloc=xloc.bar_time, textcolor=sentimentColor, style=label.style_none, yloc=yloc.price, size=lblSize) add_to_line_array(lnArray, ln, maxItems) add_to_label_array(lblArray, lbl, maxItems) var srArray1 = array.new_float() var srArray2 = array.new_float() var lnArray1 = array.new_line() var lblArray1 = array.new_label() var lnArray2 = array.new_line() var lblArray2 = array.new_label() plot_support_resistence(showZigzag1, zigzag1Length, srArray1, lnArray1, lblArray1, maxItems, zigzag1Length>zigzag2Length) plot_support_resistence(showZigzag2, zigzag2Length, srArray2, lnArray2, lblArray2, maxItems, zigzag2Length>zigzag1Length)
Trailing Stop
https://www.tradingview.com/script/OQRqi5he-Trailing-Stop/
OztheWoz
https://www.tradingview.com/u/OztheWoz/
59
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © OztheWoz //@version=4 study("Trailing Stop", overlay=true) tssmot = input(false, "Trailing Stop Smoothing?") tslen = input(4, "Trailing Stop Smooth") prc = input(3, "Trailing Stop Percentage") trailstop = close[1] - (close[1] * prc/100) tssma = sma(trailstop, tslen) plot((tssmot ? tssma : trailstop), color=color.fuchsia)
No-lose trading targets (Based on EoRfA) By Mustafa ÖZVER
https://www.tradingview.com/script/YUx9eTVm/
Mustafaozver
https://www.tradingview.com/u/Mustafaozver/
244
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Mustafaozver //@version=5 indicator('No-lose trading targets (Based on EoRfA) By Mustafa ÖZVER', 'NLTT_EoRfA', overlay=true) ref = input(hlc3) var line U_AREA_LINE = na var line D_AREA_LINE = na BUY__AREA = 0 SELL_AREA = 0 // EoRfA FPrice = ta.wma(ref, 3) FVolume = volume >= 0 ? volume : 1 len = input(13, 'Length') limit0 = 1 // natural action limit1 = 1.66 // wave edge limit2 = 2.58 // way to infinitive limit3 = 2.72 // hard breakout limit = input(1.68) volweight = ta.change(FVolume, 1) / ta.ema(FVolume, len) + 1.0 FPriveWVol = volweight * ta.change(FPrice) + FPrice stdev = ta.stdev(FPrice, len) ema = ta.ema(FPriveWVol, len) rsi = ta.rsi(FPriveWVol, len) vEorfa = (FPriveWVol - ema) / stdev higherpoint = ta.highest(high, 31) lowerpoint = ta.lowest(low, 31) Rational = (FPrice - lowerpoint) / (higherpoint - lowerpoint) BUY__SIGNAL = vEorfa < -limit and ta.change(vEorfa) > 0 and Rational < 0.4 ? 1 : 0 SELL_SIGNAL = vEorfa > +limit and ta.change(vEorfa) < 0 and Rational > 0.6 ? 1 : 0 U_AREA_ = math.min(ohlc4, hlc3, hl2, open, close) D_AREA_ = math.max(ohlc4, hlc3, hl2, open, close) U_AREA = U_AREA_ D_AREA = D_AREA_ maxLine = high minLine = low BUY__AREA := nz(BUY__SIGNAL[1], 0) == 1 ? 1 : nz(BUY__AREA[1], 0) == 1 ? 1 : 0 SELL_AREA := nz(SELL_SIGNAL[1], 0) == 1 ? 1 : nz(SELL_AREA[1], 0) == 1 ? 1 : 0 U_AREA := SELL_AREA == 1 ? nz(U_AREA[1], U_AREA_) : U_AREA_ D_AREA := BUY__AREA == 1 ? nz(D_AREA[1], D_AREA_) : D_AREA_ maxLine := SELL_AREA == 1 ? math.max(nz(maxLine[1], 0), high) : high minLine := BUY__AREA == 1 ? math.min(nz(minLine[1], 0), low) : low refLine = plot(ref, color=#00000000, display=display.none, offset=1) D_Line = plot(D_AREA, color=BUY__AREA == 1 ? #00FF00A0 : #00000000, linewidth=2, offset=2) U_Line = plot(U_AREA, color=SELL_AREA == 1 ? #FF0000A0 : #00000000, linewidth=2, offset=2) fibo_0236 = input(0.23606797749979) fibo_0381 = input(0.38196601125011) fibo_0500 = input(0.5) fibo_0618 = input(0.61803398874990) fibo_0763 = input(0.76393202250021) fibo_1618 = input(1.61803398874990) SelllineforBuying = fibo_0763 * (D_AREA - minLine) + minLine BuylineforSelling = fibo_0236 * (maxLine - U_AREA) + U_AREA //if (U_AREA < close) // line.set_x2(U_AREA_LINE,bar_index) //if (D_AREA > close) // line.set_x2(D_AREA_LINE,bar_index) if U_AREA >= math.min(close, open) or BUY__SIGNAL == 1 or nz(BuylineforSelling[1], low) > close or ta.barssince(SELL_AREA == 1) > 20 SELL_AREA := 0 SELL_AREA if D_AREA <= math.max(close, open) or SELL_SIGNAL == 1 or nz(SelllineforBuying[1], high) < close or ta.barssince(BUY__AREA == 1) > 20 BUY__AREA := 0 BUY__AREA if SELL_AREA == 0 and SELL_SIGNAL == 1 U_AREA_LINE := line.new(bar_index - 1, U_AREA, bar_index + 5, U_AREA, xloc.bar_index, extend.none, #FF0000A0, line.style_solid, 3) U_AREA_LINE if BUY__AREA == 0 and BUY__SIGNAL == 1 D_AREA_LINE := line.new(bar_index - 1, D_AREA, bar_index + 5, D_AREA, xloc.bar_index, extend.none, #00FF00A0, line.style_solid, 3) D_AREA_LINE //fill(D_Line, refLine, color=BUY__AREA==1?#00FF0020:#00000000) //fill(U_Line, refLine, color=SELL_AREA==1?#FF000020:#00000000) // draw fibonacci max_ = BUY__AREA == 1 ? D_AREA : SELL_AREA == 1 ? maxLine : ref min_ = SELL_AREA == 1 ? U_AREA : BUY__AREA == 1 ? minLine : ref tolerance = input(0.015) verify_Revision = ta.change(max_ + min_) == 0 and max_ / min_ > tolerance + 1 verify_Draw = (BUY__AREA == 1 or SELL_AREA == 1) and verify_Revision fibo_0000_line = plot(min_, color=BUY__AREA == 1 and verify_Revision ? #FFFFFF80 : #00000000, linewidth=2) fibo_1000_line = plot(max_, color=SELL_AREA == 1 and verify_Revision ? #FFFFFF80 : #00000000, linewidth=2) fibo_1618_line1 = plot((max_ - min_) * fibo_1618 + min_, color=verify_Draw ? #FF000050 : #00000000, linewidth=2) fibo_1618_line2 = plot(-(max_ - min_) * fibo_1618 + min_, color=verify_Draw ? #00FF0050 : #00000000, linewidth=2) fibo_0236_line = plot((max_ - min_) * fibo_0236 + min_, color=verify_Draw ? #FFFFFF50 : #00000000, linewidth=1) fibo_0381_line = plot((max_ - min_) * fibo_0381 + min_, color=verify_Draw ? #00FF0080 : #00000000, linewidth=1) fibo_0500_line = plot((max_ - min_) * fibo_0500 + min_, color=verify_Draw ? #FFFFFF50 : #00000000, linewidth=1) fibo_0618_line = plot((max_ - min_) * fibo_0618 + min_, color=verify_Draw ? #FF000080 : #00000000, linewidth=1) fibo_0763_line = plot((max_ - min_) * fibo_0763 + min_, color=verify_Draw ? #FFFFFF50 : #00000000, linewidth=1) fill(fibo_0236_line, fibo_0381_line, color=verify_Draw == 1 ? #00FF0020 : #00000000, transp=90) fill(fibo_0763_line, fibo_0618_line, color=verify_Draw == 1 ? #FF000020 : #00000000, transp=90) //min_Line = plot(SelllineforBuying,color=BUY__AREA==1?#FF000080:#00000000,linewidth=2) //max_Line = plot(BuylineforSelling,color=SELL_AREA==1?#00FF0080:#00000000,linewidth=2) plotshape(BUY__SIGNAL == 1 and BUY__AREA == 0, style=shape.triangledown, location=location.abovebar, color=#00FF00FF, size=size.auto) plotshape(SELL_SIGNAL == 1 and SELL_AREA == 0, style=shape.triangleup, location=location.belowbar, color=#FF0000FF, size=size.auto) // Report var label lbl = na label.delete(lbl) if verify_Draw var string reports = '' reports += (BUY__AREA == 1 ? 'LONG' : '') reports += (SELL_AREA == 1 ? 'SHORT' : '') reports += ' SETUP => % ' + str.tostring(math.round((max_ - min_) * 0.5 / close * 10000) / 100) lbl := label.new(x=barstate.islast ? time : na, y=max_, text=reports, xloc=xloc.bar_time, color=#2020AA, textcolor=#FFFFFF) reports := '' reports alertcondition(condition=verify_Draw, title='Trading Setup from NLTTa_EoRfA', message='Trading setup action from NLTTa based on EoRfA')
Never Going Back Again
https://www.tradingview.com/script/Uxbf1tOL-Never-Going-Back-Again/
allanster
https://www.tradingview.com/u/allanster/
323
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © allanster //@version=5 indicator('Never Going Back Again', 'NGBA', overlay = true, max_lines_count = 500) // Draws lines for each of up to 500 prices that have never been revisited at the present moment in time, as time progresses these levels may or may not hodl. // Adaptation of "Never Look Back Price" originally described by Timothy Peterson in his research paper entitled "Why Bitcoin's Price Is Never Looking Back". // For more information see: https://static1.squarespace.com/static/5d580747908cdc0001e6792d/t/5e93243abadd4454b360bf18/1586701372057/research+note+4.12.pdf inSource = input (defval = low, title = 'Never Going Back Again Source') inStyles = input.string(defval = 'Solid', title = 'Lines Show As', options = ['Dashed', 'Dotted', 'Solid'], inline = '1') inColors = input.color (defval = color.new(#8000ff, 0), title = ' ', inline = '1') f_lineNew(_y) => // create function to create new lines when called line.new(time, _y, time + 60 * 60 * 24, _y, xloc.bar_time, extend.right, inColors, inStyles == 'Dashed' ? line.style_dashed : inStyles == 'Dotted' ? line.style_dotted : line.style_solid) var float[] prValues = array.new_float(0) // create float array of price values var line[] prLevels = array.new_line(0) // create line array of price levels if ta.rising(inSource, 1) // if inSource rising array.push(prValues, inSource) // populate price values array with higher inSource valu element array.push(prLevels, f_lineNew(inSource)) // populate price levels array with higher inSource line element if ta.falling(inSource, 1) // if inSource falling for i = (array.size(prValues) == 0 ? na : array.size(prValues) - 1) to 0 by 1 // loop backwards through array of price values if inSource < array.get(prValues, i) // check if inSource breaks below each of the stored price values deValu = array.pop(prValues) // depopulate any broken price valu element(s) and return valu deLine = array.pop(prLevels) // depopulate any broken price line element(s) and return line line.delete(deLine) // delete any broken price line element(s) that were drawn array.push(prValues, inSource) // populate price values array with lower inSource valu element array.push(prLevels, f_lineNew(inSource)) // populate price levels array with lower inSource line element // === Flex Crude Approximation Of Tolkien Runic Language === reVeiled = input (group = ' ', inline = '2', title = 'One stRing To Rule Them All', defval = true) isSpoken = input.string(group = ' ', inline = '2', title = '', defval = 'ᚱᛁᛋK ᚩᚠ ᚱᚢᚾᛖ', options = ['ᚱᛁᛋK ᚩᚠ ᚱᚢᚾᛖ', 'Risk Of Rune']) pureFlex = input (group = ' ', title = 'Lord Of The stRings Rune Color', defval = color.new(#ffd700, 0)) dCode(_text) => // input Tolkienish output English runic = '|ᚫ|ᛒ|ᚳ|ᛞ|ᛖ|ᚠ|ᚷ|ᚻ|ᛁ|ᛁ|K|ᛚ|ᛗ|ᚾ|ᚩ|ᛈ|Kᚹ|ᚱ|ᛋ|t|ᚢ|ᚢ|ᚹ|ᛉ|ᚣ|ᛦ' + '|0|1|2|3|4|5|6|7|8|9| |᛫|᛬|\'|[|]|\n|' //runic characters nglsh = '|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z' + '|0|1|2|3|4|5|6|7|8|9| |.|:|\'|[|]|\n|' //nglih characters arrEN = str.split(nglsh, '|') // split each nglsh character into an array of indexed alphn characters arrRN = str.split(runic, '|') // split each runic character into an array of indexed runic characters arrIn = str.split(_text, '') // split each input character into an array of indexed input characters lenIn = str.length(_text) // count input characters in _text arrdC = array.new_string(lenIn, '•') // create string array of size lenIn and populate with character if barstate.islast for idxInChar = 0 to lenIn - 1 by 1 // loop through array of character elements getInChar = array.get(arrIn, idxInChar) // get each input character from input string array idxRNChar = array.indexof(arrRN, getInChar) // get index number of runic array character that matches input array character idxRNChek = idxRNChar == -1 ? 43 : idxRNChar // if unsupported runic character substitute empty character getENChar = array.get(arrEN, idxRNChek) // get nglsh character of corresponding runic index number from runic array array.set(arrdC, idxInChar, getENChar) // overwrite populated character in dCoded array with nglsh characters dCoded = array.join(arrdC, '') // create dCoded string array and return value of joined string element dCoded runicInp = '[ᚢᛖᚱᛋᛖ 1]\nᛋᚻᛖ ᛒᚱᚩKᛖ ᛞᚩᚹᚾ ᚫᚾᛞ ᛚᛖt ᛗᛖ ᛁᚾ\nᛗᚫᛞᛖ ᛗᛖ ᛋᛖᛖ ᚹᚻᛖᚱᛖ ᛁ\'ᛞ ᛒᛖᛖᚾ\n\n[ᚳᚻᚩᚱᚢᛋ]\nᛒᛖᛖᚾ ᛞᚩᚹᚾ ᚩᚾᛖ tᛁᛗᛖ\nᛒᛖᛖᚾ ᛞᚩᚹᚾ tᚹᚩ tᛁᛗᛖᛋ\nᛁ\'ᛗ ᚾᛖᚢᛖᚱ ᚷᚩᛁᚾᚷ ᛒᚫᚳK ' + 'ᚫᚷᚫᛁᚾ\n\n[ᚢᛖᚱᛋᛖ 2]\nᚣᚩᚢ ᛞᚩᚾ\'t Kᚾᚩᚹ ᚹᚻᚫt ᛁt ᛗᛖᚫᚾᛋ tᚩ ᚹᛁᚾ\nᚳᚩᛗᛖ \'ᚱᚩᚢᚾᛞ ᚫᚾᛞ ᛋᛖᛖ ᛗᛖ ᚫᚷᚫᛁᚾ\n\n[ᚳᚻᚩᚱᚢᛋ]\nᛒᛖᛖᚾ ᛞᚩᚹᚾ ᚩᚾᛖ tᛁᛗᛖ\nᛒᛖᛖᚾ ᛞᚩᚹᚾ tᚹᚩ tᛁᛗᛖᛋ\nᛁ\'ᛗ ' + 'ᚾᛖᚢᛖᚱ ᚷᚩᛁᚾᚷ ᛒᚫᚳK ᚫᚷᚫᛁᚾ\n\nᚫᚱtᛁᛋt᛬ ᚠᛚᛖᛖtᚹᚩᚩᛞ ᛗᚫᚳ\nᚫᛚᛒᚢᛗ᛬ ᚱᚢᛗᚩᚢᚱᛋ\nᚱᛖᛚᛖᚫᛋᛖᛞ᛬ 1977\nᚷᛖᚾᚱᛖ᛬ ᚱᚩᚳK\nKᛖᚣ᛬ ᚷ ᛗᚫᛁᚩᚱ' f_print(_text, _color) => // create function to print table _text when called var table _t = table.new(position.top_right, 1, 1) if barstate.islast table.cell(_t, 0, 0, _text, text_color = _color, text_halign = text.align_left, text_size = size.auto) f_print(reVeiled ? isSpoken == 'ᚱᛁᛋK ᚩᚠ ᚱᚢᚾᛖ' ? runicInp : dCode(runicInp) : string(na), pureFlex)
Nth Root
https://www.tradingview.com/script/zDfDeIBk-Nth-Root/
OztheWoz
https://www.tradingview.com/u/OztheWoz/
11
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © OztheWoz //@version=5 indicator('Nth Root') nroot(nsrc, nlen) => num = nsrc sqrt = math.pow(num, 1 / nlen) sqrt nlen = input(4, "Root Length") nopen = nroot(open, nlen) nhigh = nroot(high, nlen) nlow = nroot(low, nlen) nclose = nroot(close, nlen) cndclr = (nclose > nopen) ? color.green : color.red cndbord = (nclose > nopen) ? color.green : color.red plotcandle(nopen, nhigh, nlow, nclose, color=cndclr, bordercolor=cndbord, wickcolor=color.gray)
Box-Cox Log Bands
https://www.tradingview.com/script/Y87NXQT4-Box-Cox-Log-Bands/
RicardoSantos
https://www.tradingview.com/u/RicardoSantos/
144
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © RicardoSantos //@version=5 indicator("Box-Cox Log Bands", overlay=true) import RicardoSantos/FunctionBoxCoxTransform/1 as bct float source = input.source(close) int length = input.int(10) float lambda = input.float(-0.5) float upper_band_scale_factor = input(0.01) float lower_band_scale_factor = input(0.01) var float[] data = array.new_float(length) if barstate.isfirst for _i=0 to length-1 array.push(data, source) float(na) else array.unshift(data, source) array.pop(data) float[] transformed = bct.regular(data, lambda) float upper = math.abs(array.avg(bct.inverse(transformed, lambda+upper_band_scale_factor))) float lower = math.abs(array.avg(bct.inverse(transformed, lambda+lower_band_scale_factor))) plot(upper, color=color.aqua) plot(lower, color=color.blue)
Bulu Breakout
https://www.tradingview.com/script/B7HLDTKm-Bulu-Breakout/
biswamca2010
https://www.tradingview.com/u/biswamca2010/
8
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © biswamca2010 //@version=4 study(title="Bulu Breakout",overlay=true) //inputs period=input(title="no of bars",type=input.integer,defval=52,minval=1,maxval=500) timeframe=input(title="timeframe",type=input.string,defval="W") alertcolor=input(title="alert bar color",type=input.color,defval=color.black) ma=input(title="sma",type=input.integer,defval=44,minval=1,maxval=500) [middle,upper,lower]=bb(close,20,2) [diplus, diminus, adx] = dmi(14, 14) hi=highest(period) myhigh=security(syminfo.tickerid,timeframe,hi[1],barmerge.gaps_off,barmerge.lookahead_off) bgcolor =close > myhigh and close >upper and adx<=30 ? alertcolor :na barcolor(bgcolor) plot(myhigh,title="52Whigh",color=alertcolor,linewidth=2) plot(sma(close,ma)) plot(middle,title="MIDDLE BB") plot(upper,title="UPPERBB") plot(lower,title="LOWERBB")
neutronix community bot ML + Alerts 4h-daily (mod. capissimo)
https://www.tradingview.com/script/14zGd5Hb-neutronix-community-bot-ML-Alerts-4h-daily-mod-capissimo/
gravisxv
https://www.tradingview.com/u/gravisxv/
720
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // NEUTRONIX Community BOT Copyright gravisxv // You are fully authorized to copy, modify and rework the code according to open source license // LVQ-based Strategy © capissimo // SL-TP code from theCrypster 2020 open source study script // MESA © 2013 John F. Ehlers // Mesa code from dongyun open source study script // LVQ-based Strategy modified by gravisxv for study purpose // Neutronix v1 // Fixed repaint, added more filtering (vwap - vwma) for longer timeframes, fixed reverse signal check, added rsi period and volume settings , ALL filters are now on by default // Vwap is plotted as additional visual confirmation // Neutronix v2 // Major rework of options panel (removed most of unused AI settings) // Enabled profitable lower timeframes trading(1 minute+) via option 'aggressive stance'('Reverse signals' option might work too in certain market conditions), added take profit and stop loss alarms // Display infos about volatility and last valid trading signal, // Important: set your alarms with 'Once per bar'. The setting 'Once per bar close' works as well but it might be late. // Neutronix v2.1 // Added volatility filter multiplier option to magnify volatility filter effect // Added safety exits option as a stop measure when price is starting to move against the trade direction // Added directional movement filter for removing false signals // Added Take Profit alarm work for both long-short // Neutronix v2.2 // Quick fix on a formula // Converted to V5 // Neutronix v3 // Significant release for more automatization // Important: Signals are fully synchronized with alerts via correct candles (the problem was persistent in v2). // Removed useless options from the panel // Immediate or delayed alert mode (removed feature sry maybe next) // Added more signals for added risks-rewards in ai-automatic mode // Option to enable heikenashi smoothing // Automatic exits-trend exits with manual level tp always on (they work together) // Added DCA for short-long in emulation mode(you need to use external alert systems for safety orders) and SWING trading // Possibility of exit in immediate trend or wait at next trend // Institutional trading option catch whales movements and avoid range market situations // Scalping filters on-off switch // Changed machine learning feed data to include monetary movements // Manual mode consist of supertrend mode red/green zones and dual hma moving indicators for expert users. // Exit Long-Short Global alerts provide exit alarms when takeprofit/stoploss/changetradedirection signals are triggered // Neutronix v4 // AI signals are now more efficient with possibility of fine-tuning // Added multiple modalities for exit option // The filters now offer a full suite of parameters to remove unwanted signals // Changed DCAbot into Supertrend Pivot, scalping and swing updated too // Some changes to takeprofit/stop loss levels // --to be completed-- // No excuses to stop trading now // the gem of bots // --happy trade-- //_____ ___ ____ _ //| __ \| \/ | | | //| | \/| . . | | | //| | __ | |\/| | | | //| |_\ \| | | |_|_| // \____/\_| |_(_|_) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // _ _ _____ _ _ _____ ____ ___ _ _ ___ __ __ ____ ___ __ __ __ __ _ _ _ _ ___ _____ __ __ ____ ___ _____ //| \ | | | ____| | | | | |_ _| | _ \ / _ \ | \ | | |_ _| \ \/ / / ___| / _ \ | \/ | | \/ | | | | | | \ | | |_ _| |_ _| \ \ / / | __ ) / _ \ |_ _| //| \| | | _| | | | | | | | |_) | | | | | | \| | | | \ / | | | | | | | |\/| | | |\/| | | | | | | \| | | | | | \ V / | _ \ | | | | | | //| |\ | | |___ | |_| | | | | _ < | |_| | | |\ | | | / \ | |___ | |_| | | | | | | | | | | |_| | | |\ | | | | | | | | |_) | | |_| | | | //|_| \_| |_____| \___/ |_| |_| \_\ \___/ |_| \_| |___| /_/\_\ \____| \___/ |_| |_| |_| |_| \___/ |_| \_| |___| |_| |_| |____/ \___/ |_| // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // If you do appreciate the bot please consider a small donation to support me and/or other authors on TV(reminder Neutronix bot will ALWAYS be free): // BTC 36hcvdyoRqw8VcoEQvSKZ6AYGPFYEP4upp // XRP rf5VFsp5HnmAwiuQugQsrNALwPkCWesAGL // LTC M8U1xdoU34peZTz7b8Ve48ubLGQoGW9myn // TRON TEUziyvYmhjnuH3bzgvCdRoZBLcvMbGPqo //@version=5 indicator('neutronix community bot version Machine Learning + Alerts 4h - daily (based on capissimo ML)', '', true, max_labels_count=200, max_bars_back=5000) // LVQ-based Strategy (FX and Crypto) // Description: // Learning Vector Quantization (LVQ) can be understood as a special case of // an artificial neural network, more precisely, it applies a winner-take-all // learning-based approach. It is based on prototype supervised learning // classification task and trains its weights through a competitive // learning algorithm. // Algorithm: // Initialize weights // Train for 1 to N number of epochs // Select a training example // Compute the winning vector // Update the winning vector // Classify test sample // The LVQ algorithm offers a framework to test various indicators easily to see // if they have got any *predictive value*. One can easily add cog, wpr and others. // Note: TradingViews's playback feature helps to see this strategy in action. // The algo is tested with BTCUSD/1Hour. // Warning: This is a preliminary version! // ***Warning***: Signals LARGELY depend on hyperparams (lrate and epochs). // Style tags: Trend Following, Trend Analysis // Asset class: Equities, Futures, ETFs, Currencies and Commodities // Dataset: FX Minutes/Hours+++/Days //-------------------- Inputs trmode = input.string(defval='supertrend', title='Trading mode', options=['ai','scalping','supertrend','swing','manual']) ftt = input.string(defval='auto', title='Exit mode', options=['auto','macross', 'atr','percent']) //Candles set cs = input(close, 'Dataset') h = input(false, title = "Signals from Heikin Ashi Candles?") // aggressive = input(true, 'Institutional Trading', group='Filter options') fss = input(true, 'Ema filter ?', group='Filter options') lfema1= input.int(15, 'EMA1 period', minval=1, maxval=500, group='Filter options') lfema2 = input.int(33, 'EMA2 period', minval=1, maxval=500, group='Filter options') vff = input(false, 'Volume filter ?', group='Filter options') ths= input.int(46, 'Volume Threshold', minval=1, maxval=100, group='Filter options') // trail = input(true, 'Trailing Stop?', group='Take profits') stopPer = input.float(9, title='Stop Loss %', group='Take profits') / 100 takePer = input.float(15, title='Take Profit %', group='Take profits') / 100 lauto = input.int(14, "AUTO Exit length", group="Take profits") atfactor = input.int(3, "ATR Exit factor", group="Take profits") atperiod = input.int(12, "ATR Exit period", group="Take profits") // leftBars = input(4,title="Pivot bars", group="Pivot Reversal Supertrend settings") rightBars = input(1, group="Pivot Reversal Supertrend settings") atrPeriod = input(10, "ATR Length", group="Pivot Reversal Supertrend settings") factor = input.float(3.0, "Factor", step = 0.1, group="Pivot Reversal Supertrend settings") // lgh = input.int(15, 'Price Channel length', minval=1, maxval=99, group="Price Channel Scalping") // fasth = input.int(12, 'Fast Moving Average', minval=1, maxval=99, group="Manual DMAC Settings") slowh = input.int(46, title="Slow Moving Average", group="Manual DMAC Settings") //-------------------- System Variables //PARAMS srg = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, cs, lookahead=barmerge.lookahead_off) : cs lrate = 0.05 epochs = 5 //after 4 no improvements //epochs = 5 ds = srg p = input.int(14, title='LBW ~1-1000',maxval=1000, group='AI options') res = input.int(1, title='LBW Factor ~1-10',maxval=10, group='AI options') reverse = input(true, title = "Reverse Ai Signals ?", group='AI options') startYear = input.int(2020, 'Training Start Year', minval=2010, group='AI options') startMonth = input.int(1, 'Training Start Month', minval=1, maxval=12, group='AI options') startDay = input.int(1, 'Training Start Day', minval=1, maxval=31, group='AI options') stopYear = input.int(2021, 'Training Stop Year', minval=2010, group='AI options') stopMonth = input.int(8, 'Training Stop Month', minval=1, maxval=12, group='AI options') stopDay = input.int(1, 'Training Stop Day', minval=1, maxval=31, group='AI options') var BUY = -1 var SELL = 1 var HOLD = 0 VWAP = ta.vwap(srg) //VWAP using source candles var cc = 0 //BUY = 1 //-- some TFs and assets require reversing the signals!! IMPORTANT for LTF //SELL = -1 //-------------------- Dynamic Arrays ///PART OF LVQ ALGORITHM var int wnr = 0 // winner's signal var int signal = HOLD //-------------------- Regular arrays ///STORING OLD CANDLES AND TRAINED WEIGHTS var float[] features = array.new_float() //-- training data var float[] weights0 = array.new_float(1, 1.) //-- learning vectors var float[] weights1 = array.new_float(1, 100.0) /// LEARNING VECTOR QUANTIZATION norm(x, p) => // normalize features (x - ta.lowest(x, p)) / (ta.highest(x, p) - ta.lowest(x, p)) getwinner(features, weights0, weights1) => // compute the winning vector by Euclidean distance d0 = 0. d1 = 0. size = array.size(features) for i = 0 to size - 1 by 1 d0 := d0 + math.round(math.pow(array.get(features, i) - array.get(weights0, i), 2),2)// d1 := d1 + math.round(math.pow(array.get(features, i) - array.get(weights1, i), 2),2)// EUCLID d1 d0 > d1 ? SELL : d0 < d1 ? BUY : HOLD update(features, weights0, weights1, w, lr) => // update the weight array of the winner size = array.size(features) for i = 0 to size - 1 by 1 if w == SELL array.set(weights0, i, array.get(weights0, i) + lrate * (array.get(features, i) - array.get(weights0, i))) if w == BUY array.set(weights1, i, array.get(weights1, i) + lrate * (array.get(features, i) - array.get(weights1, i))) //-------------------- Logic //x = ds[barstate.ishistory ? 0 : 1] x = srg periodStart = timestamp(startYear, startMonth, startDay, 0, 0) periodStop = timestamp(stopYear, stopMonth, stopDay, 0, 0) // The core logic // Collect training data (i.e. features) f1 = ta.cci(x, p*res) //f2 = ta.rsi(x, 3*res) //cmo // Train the model using particular training period if time >= periodStart and time <= periodStop array.clear(features) array.push(features, f1) //array.push(features, f2) for i = 1 to epochs by 1 w = getwinner(features, weights0, weights1) update(features, weights0, weights1, w, lrate) //-- this is 'the act of learning' // Classify new input sample if time > periodStop array.clear(features) array.push(features, f1) // array.push(features, f2) wnr := getwinner(features, weights0, weights1) wnr ////////////////////// //TREND FILTER em100 = ta.ema(srg, lfema1) em200 = ta.ema(srg, lfema2) //FILTERS filtersell = true filterbuy = true filtersell := em100 < em200 filterbuy := em100 > em200 stancesell = aggressive ? srg <= VWAP : 1 stancebuy = aggressive ? srg > VWAP : 1 volumeBreak(thres) => rsivol = ta.rsi(srg, 14) osc = ta.vwma(rsivol, 18) osc >= thres fivol = volumeBreak(ths) //Kama getKAMA(src, length1, fastLength1, slowLength1) => mom = math.abs(ta.change(src, length1)) volatility = math.sum(math.abs(ta.change(src)), length1) er = volatility != 0 ? mom / volatility : 0 fastAlpha = 2 / (fastLength1 + 1) slowAlpha = 2 / (slowLength1 + 1) sc = math.pow(er * (fastAlpha - slowAlpha) + slowAlpha, 2) kama = 0.0 kama := sc * src + (1 - sc) * nz(kama[1]) kama //kamafat = getKAMA(srg, 7,2,2) kamafat = getKAMA(srg, 10,2,30) plot(ftt=='macross'?kamafat:1, color=color.blue) //--ATR Exit [ATRStop , direct] = ta.supertrend(atfactor, atperiod) plot(ftt=="atr"?ATRStop:na, color=color.black) // Tilson swing gt(src1, fast_ma_len, factor) => ta.ema(src1, fast_ma_len) * (1 + factor) - ta.ema(ta.ema(src1, fast_ma_len), fast_ma_len) * factor t3(src1, fast_ma_len, factor) => gt(gt(gt(src1, fast_ma_len, factor), fast_ma_len, factor), fast_ma_len, factor) rT3 = 0.7 tilT3 = t3(srg, 20, rT3) //Manual Settings fasthull = ta.hma(srg, fasth) slowhull = ta.hma(srg, slowh) //Price channel hh = ta.highest(high[1], lgh) ll = ta.lowest(low[1], lgh) centerln = (hh + ll) / 2 //price to track //plot(centerln, color=color.green) //plot (hh, color=color.maroon) //plot(ll, color=color.teal) //Pivot Reversal Supertrend swh = ta.pivothigh(leftBars, rightBars) swl = ta.pivotlow(leftBars, rightBars) [supertrend, direction] = ta.supertrend(factor, atrPeriod) swh_cond = not na(swh) hprice = 0.0 hprice := swh_cond ? swh : hprice[1] le = false le := swh_cond ? true : (le[1] and high > hprice ? false : le[1]) //if (le and direction < 0) // strategy.entry("PivRevLE", strategy.long, comment="PivRevLE", stop=hprice + syminfo.mintick) swl_cond = not na(swl) lprice = 0.0 lprice := swl_cond ? swl : lprice[1] se = false se := swl_cond ? true : (se[1] and low < lprice ? false : se[1]) //if (se and direction > 0) //strategy.entry("PivRevSE", strategy.short, comment="PivRevSE", stop=lprice - syminfo.mintick) // Generate signal - //SCALPING price chan if (trmode=='scalping') signal := close <= hh and stancebuy and (fss?filterbuy:1) and (vff?fivol:1) ? BUY : close >= ll and stancesell and (fss?filtersell:1) and (vff?fivol:1) ? SELL : nz(signal[1]) //AUTO if (trmode=='ai') signal := (wnr == (reverse?BUY:SELL)) and stancesell and (fss?filtersell:1) and (vff?fivol:1) ? SELL : (wnr == (reverse?SELL:BUY)) and stancebuy and (fss?filterbuy:1) and (vff?fivol:1) ? BUY : nz(signal[1]) // PivRev Supertrend (Old DCABOT) if (trmode=='supertrend') signal := le and direction < 0 and stancebuy and (fss?filterbuy:1) and (vff?fivol:1) ? BUY : se and direction > 0 and stancesell and (fss?filtersell:1) and (vff?fivol:1) ? SELL : nz(signal[1]) if (trmode=='swing') signal := tilT3 > srg and stancesell and (fss?filtersell:1) and (vff?fivol:1) ? SELL : tilT3 < srg and stancebuy and (fss?filterbuy:1) and (vff?fivol:1) ? BUY : nz(signal[1]) // changed = ta.change(signal) if changed cc := cc + 1 cc int long_short = 0 // CHECK IF OLD SIGNAL IS SHORT OR LONG TO AVOID COPY startLongTrade = changed and signal == BUY and (nz(long_short[1]) == 0 or nz(long_short[1]) == -1) startShortTrade = changed and signal == SELL and (nz(long_short[1]) == 0 or nz(long_short[1]) == 1) endLongTrade = changed and signal == SELL endShortTrade = changed and signal == BUY //IMPORTED CODE FROM TP ALERT VERSION //SL TP long_last = startLongTrade and (nz(long_short[1]) == 0 or nz(long_short[1]) == -1) short_last = startShortTrade and (nz(long_short[1]) == 0 or nz(long_short[1]) == 1) long_short := long_last ? 1 : short_last ? -1 : long_short[1] longPrice = 0. shortPrice = 0. //entry price longPrice := ta.valuewhen(trail?close:long_last,close,0)// and cs!=open?barstate.isconfirmed:1, close, 0) shortPrice := ta.valuewhen(trail?close:short_last, close, 0) //fixed sltp prices longStop = longPrice * (1 - stopPer) shortStop = shortPrice * (1 + stopPer) longTake = longPrice * (1 + takePer) shortTake = shortPrice * (1 - takePer) //plot sltp lines plot(long_short == 1 ? longStop : na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Long Fixed SL') plot(long_short == -1 ? shortStop : na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Short Fixed SL') //plot(long_short == 1 ? longTake : na, style=plot.style_linebr, color=color.new(color.green, 0), linewidth=1, title='Long Fixed TP') //plot(long_short == -1 ? shortTake : na, style=plot.style_linebr, color=color.new(color.green, 0), linewidth=1, title='Short Fixed TP') //remove first bar for SL/TP (you can't enter a trade at bar close THEN hit your SL on that same bar) -- MODIFIED longBar1 = ta.barssince(long_last) shortBar1 = ta.barssince(short_last) longBar2 = longBar1 > 1 ? true : false //longBar2 = true //no shortBar2 = shortBar1 > 1 ? true : false //shortBar2 = true longSLhit = false shortSLhit = false longSLhit := long_short == 1 and longBar2 and (low < longStop) and not changed shortSLhit := long_short == -1 and shortBar2 and (high > shortStop) and not changed //Rendering stoploss plotshape(longSLhit, style=shape.labelup, location=location.belowbar, color=color.new(color.purple, 0), size=size.tiny, title='Long SL', text=' Long SL', textcolor=color.new(color.white, 0)) plotshape(shortSLhit, style=shape.labeldown, location=location.abovebar, color=color.new(color.purple, 0), size=size.tiny, title='Short SL', text=' Short SL', textcolor=color.new(color.white, 0)) //check for TP hit during bar bool longTPhit = false bool shortTPhit = false //Exit checks: price is in target // if(ftt=="auto") longTPhit := long_short == 1 and longBar2 and (wnr == SELL and ta.rsi(srg,lauto) < 70) and not changed and not longSLhit shortTPhit := long_short == -1 and shortBar2 and (wnr == BUY and ta.rsi(srg,lauto) > 30) and not changed and not shortSLhit else if(ftt=="macross") longTPhit := long_short == 1 and longBar2 and (ta.crossunder(close,kamafat)) and not changed and not longSLhit shortTPhit := long_short == -1 and shortBar2 and (ta.crossover(close,kamafat)) and not changed and not shortSLhit else if(ftt=="atr") longTPhit := long_short == 1 and longBar2 and (ta.crossunder(low,ATRStop)) and not changed and not longSLhit shortTPhit := long_short == -1 and shortBar2 and (ta.crossover(high,ATRStop)) and not changed and not shortSLhit else if(ftt=="percent") longTPhit := long_short == 1 and longBar2 and (high > longTake) and not changed and not longSLhit shortTPhit := long_short == -1 and longBar2 and (low < shortTake) and not changed and not shortSLhit plotshape(longTPhit, style=shape.labeldown, location=location.abovebar, color=color.new(color.olive, 0), size=size.tiny, title='Long TP', text='Long TP', textcolor=color.new(color.white, 0)) plotshape(shortTPhit, style=shape.labelup, location=location.belowbar, color=color.new(color.olive, 0), size=size.tiny, title='Short TP', text='Short TP', textcolor=color.new(color.white, 0)) //reset long_short if SL/TP hit during bar long_short := (long_short == 1 or long_short == 0) and longBar2 and (longSLhit or longTPhit) ? 0 : (long_short == -1 or long_short == 0) and shortBar2 and (shortSLhit or shortTPhit) ? 0 : long_short // //-------------------- Rendering plotshape(startLongTrade, 'BUY', shape.labelup, location.belowbar, color.new(color.green, 0), size=size.small) plotshape(startShortTrade, 'SELL', shape.labeldown, location.abovebar, color.new(color.red, 0), size=size.small) plot(endLongTrade ? high : na, 'StopBuy', color.new(color.green, 0), 2, plot.style_cross) plot(endShortTrade ? low : na, 'StopSell', color.new(color.red, 0), 2, plot.style_cross) //plot(VWAP, color=color.new(color.aqua, 0), linewidth=2, title='VWap') plot(trmode=='manual'?fasthull:na, color=color.blue, linewidth=2) plot(trmode=='manual'?slowhull:na, color=color.maroon, linewidth=2) plot(trmode=='swing'?tilT3:na, color=color.new(color.red, 0)) plot(trmode=='scalping'?centerln:na, color=color.lime, linewidth=4) //-------------------- Alerting conditionTP = longTPhit or shortTPhit //alertcondition(startLongTrade and barstate.isconfirmed, 'Long', 'Go long!',alertmenow?alert.freq_all:alert.freq_once_per_bar_close) alertcondition(startLongTrade, 'Long', 'Go BUY',alert.freq_once_per_bar) alertcondition(startShortTrade, 'Short', 'Go SELL!',alert.freq_once_per_bar) // alertcondition(startLongTrade or startShortTrade, 'Alert Global Trade', 'Deal Time!',alert.freq_all) alertcondition(condition=conditionTP or startShortTrade or longSLhit, title='Exit Long Global', message='TP Hit @ ${{plot("TP")}}') alertcondition(condition=conditionTP or startLongTrade or shortSLhit, title='Exit Short Global', message='TP Hit @ ${{plot("TP")}}') alertcondition(condition=conditionTP or longSLhit or shortSLhit, title='Exit Global', message='TP Hit @ ${{plot("TP")}}') alertcondition(condition=conditionTP, title='Exit TP Global', message='TP Hit @ ${{plot("TP")}}') alertcondition(condition=longSLhit, title='Long Stop Loss', message='Long SL Hit @ ${{plot("Long SL")}}') alertcondition(condition=shortSLhit, title='Short Stop Loss', message='Short SL Hit @ ${{plot("Short SL")}}') alertcondition(condition=longSLhit or shortSLhit, title='Global Stop Loss', message='Global SL Hit @ ${{plot("Long SL")}}') alertcondition(condition=longTPhit, title='Exit Long', message='Long TP Hit @ ${{plot("Long TP")}}') alertcondition(condition=shortTPhit, title='Exit Short', message='Short TP Hit @ ${{plot("Short TP")}}') //-------------------- Backtesting (not 100% accurate but works) lot_size = 0.01 ohl3 = srg var float start_long_trade = 0. var float long_trades = 0. var float start_short_trade = 0. var float short_trades = 0. var int wins = 0 var int trade_count = 0 if startLongTrade start_long_trade := ohl3 start_long_trade if endLongTrade trade_count := 1 ldiff = ohl3 - start_long_trade wins := ldiff > 0 ? 1 : 0 long_trades := ldiff * lot_size long_trades if startShortTrade start_short_trade := ohl3 start_short_trade if endShortTrade trade_count := 1 sdiff = start_short_trade - ohl3 wins := sdiff > 0 ? 1 : 0 short_trades := sdiff * lot_size short_trades cumreturn = ta.cum(long_trades) + ta.cum(short_trades) //-- cumulative return totaltrades = ta.cum(trade_count) totalwins = ta.cum(wins) totallosses = totaltrades - totalwins == 0 ? 1 : totaltrades - totalwins //-------------------- Information var label lbl = na tbase = (time - time[1]) / 1000 tcurr = (timenow - time_close[1]) / 1000 buyz = 'BUY' sellz = 'SELL' info = 'CR=' + str.tostring(cumreturn, '#.#') + '\nTrades: ' + str.tostring(cc, '#') + '\nWin/Loss: ' + str.tostring(totalwins / totallosses, '#.##') + '\nWinrate: ' + str.tostring(totalwins / totaltrades, '#.#%') + '\nBar Time: ' + str.tostring(tcurr / tbase, '#.#%') + '\nActual volatility: ' + str.tostring(ta.atr(1), '#.##') + '\nCurrent signal: ' + (signal == 1 ? sellz : buyz) + '\nCurrent price: ' + str.tostring(close) if input(true, 'Show Information?') and barstate.islast lbl := label.new(bar_index, close, info, xloc.bar_index, yloc.price, color.new(color.blue, 100), label.style_label_left, color.black, size.small, text.align_left) label.delete(lbl[1])
Repeated Median Regression with Interactive Range Selection
https://www.tradingview.com/script/XLhHmv2h-Repeated-Median-Regression-with-Interactive-Range-Selection/
tbiktag
https://www.tradingview.com/u/tbiktag/
317
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © tbiktag // // // The script calculates linear regression between two points which can be interactively // selected on the chart. It uses a robust regression algorithm known as repeated median regression. // // // @version=5 indicator("Repeated Median Regression", overlay=true, max_bars_back = 5000) // // Get the functions from the LinearRegressionLibrary import tbiktag/LinearRegressionLibrary/1 as linreg // // --- constants --- int DEAFAULT_TIME1 = timestamp("2021-09") int DEAFAULT_TIME2 = timestamp("2021-10") // // // --- inputs --- float src = input(title = "Source", defval = close) int startTimeInput = input.time(title = "T1", defval = DEAFAULT_TIME1, confirm = true) int endTimeInput = input.time(title = "T2", defval = DEAFAULT_TIME2, confirm = true) bool showInterval = input.bool(title = "Show Channel with Width Factor = ", defval = true, inline = "lineInt",group = "Options") float mult = input.float(title = "", defval = 2, minval = 0.1, inline = "lineInt",group = "Options", tooltip = "Calculates and plots the prediction interval of the regression defined as: \n Central line ± Mean Absolute Error (MAE) times Width") bool showResult = input.bool(title = "Show Infobox", defval = true, group = "Options", tooltip = 'The box in the lower left corner shows the estimated slope and mean absolute error (MAE) of the regression.') bool extendln = input(title = "Extend Line to the Right", defval = false,group = "Options") bool showBorder = input.bool(title = "Show Interval Borders", defval = true, group = "Options", tooltip = 'Marks the beginning and end of the interval with vertical lines.') color colUp = input.color( title = "Color Scheme", defval = #71BC68, inline = "linecol",group = "Appearence") color colDw = input.color( title = "", defval = #F29388, inline = "linecol",group = "Appearence") int lw = input(title = "Line Width", defval = 2,group = "Appearence") // // // --- functions --- getBarIndexForTime(t) => // Obtain the bar index from the timestamp. The function is adopted from // the script published by TradingView: // https://www.tradingview.com/script/SkmMrMe0-CAGR-Custom-Range/ // Input: // t :: timestamp // Outup :: integer, bar index var int barindex_t = na if time[1] <= t and time >= t and na(barindex_t) barindex_t := bar_index barindex_t // // // --- calculations --- // initialize time interval int startTime = math.min(startTimeInput,endTimeInput) int endTime = math.max(startTimeInput,endTimeInput) int len = getBarIndexForTime(endTime) - getBarIndexForTime(startTime) if len < 1 runtime.error("There must be minimum one bar between two points.") // // apply regression [mSlope, mIntercept] = linreg.RepeatedMedian(src, len, getBarIndexForTime(endTime)) float startY = mIntercept float endY = mIntercept+mSlope*(len-1) float mae = linreg.metricMAE(src,len, getBarIndexForTime(endTime),mSlope,mIntercept) // // // --- output --- // plot line(s) slopeColor = mSlope>0?colUp:colDw mainLine = line.new(startTime,startY,endTime,endY,xloc=xloc.bar_time,color=slopeColor,style=line.style_solid,width=lw,extend = extendln?extend.right:extend.none) line.delete(mainLine[1]) if showInterval highLine = line.new(startTime,startY+mae*mult,endTime,endY+mae*mult,xloc=xloc.bar_time,color=slopeColor,style=line.style_dashed,width=int(lw/2),extend = extendln?extend.right:extend.none) lowLine = line.new(startTime,startY-mae*mult,endTime,endY-mae*mult,xloc=xloc.bar_time,color=slopeColor,style=line.style_dashed,width=int(lw/2),extend = extendln?extend.right:extend.none) line.delete(highLine[1]) line.delete(lowLine[1]) if showBorder borderL = line.new(startTime,startY+mae*mult,startTime,startY-mae*mult,xloc=xloc.bar_time,color=color.blue,style=line.style_solid,width=1) borderR = line.new(endTime,endY+mae*mult,endTime,endY-mae*mult,xloc=xloc.bar_time,color=color.blue,style=line.style_solid,width=1) line.delete(borderL[1]) line.delete(borderR[1]) // // display infobox if barstate.islast and showResult var infobox = table.new(position = position.bottom_left, columns = 1, rows = 3, bgcolor = slopeColor) table.cell(table_id = infobox, column = 0, row = 0, text = "Regression results",text_size = size.normal) table.cell(table_id = infobox, column = 0, row = 1, text = str.format("Slope: {0,number,#.#}",mSlope),text_size = size.normal, text_halign = text.align_left) table.cell(table_id = infobox, column = 0, row = 2, text = str.format("MAE: {0,number,#.#}",mae),text_size = size.normal, text_halign = text.align_left) //
Background Color hma
https://www.tradingview.com/script/ltyefwJd-Background-Color-hma/
eshagav
https://www.tradingview.com/u/eshagav/
20
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © eshagav //@version=4 //Inputs hmastudy("Background Color hma ", overlay=true) study("Background Color hma ", overlay=true) src = input(close, title="source") len = input(minval=1, defval=21, title="length") hma = hma(src, len) //Inputs BGColor longC = input(type= input.color, defval=color.green) shortC = input(type= input.color, defval=color.red) trans = input(type=input.integer, defval=80, minval=1, maxval=99) //Calculation long = close > hma short = close < hma plot(hma) bgcolor(color=long ? longC : shortC, transp=trans)
ADR: Average Daily Range
https://www.tradingview.com/script/M7RYA0qq-ADR-Average-Daily-Range/
cattledoger
https://www.tradingview.com/u/cattledoger/
9
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © cattledoger //@version=4 study("ADR-Average Daily Range", precision=1) len = input(26, minval=1, maxval=200, title="EMA Length") MA = sma(close,len) avg_dailytop = highest(high, 8) avg_dailylow = lowest(low, 8) dailytop = (avg_dailytop+MA)/2 dailylow = (avg_dailylow+MA)/2 super_avg = (dailytop+dailylow)/2 plot(int(super_avg), 'Midline', color=color.blue) plot(int(MA), 'SMA', color=color.aqua) plot(int(dailytop), 'Average Top', color=color.orange) plot(int(dailylow), 'Average Low', color=color.orange)
Zendog LONG DCA Trigger RSI+StochRSI
https://www.tradingview.com/script/FpVLLnMG-Zendog-LONG-DCA-Trigger-RSI-StochRSI/
zendog123
https://www.tradingview.com/u/zendog123/
318
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © zendog123 //@version=4 study("Zendog LONG DCA Trigger RSI+StochRSI", shorttitle="LONG DCA Trigger RSI+StochRSI", overlay=true) var bool IS_LONG = true //STOCH RSI condition for DCA Bot debugging source = input(type=input.source, defval=close, title="Source for RSI and Stochastic RSI", group="Stochastic RSI") smoothK = input(type=input.integer, defval=3, title="Stoch RSI SmoothK", group="Stochastic RSI") smoothD = input(type=input.integer, defval=3, title="Stoch RSI Smoothd", group="Stochastic RSI") lengthStoch = input(type=input.integer, defval=14, title="Stoch Length", group="Stochastic RSI") lengthRSIStoch = input(type=input.integer, defval=14, title="Stoch RSI Length", group="Stochastic RSI") lengthRSI = input(type=input.integer, defval=7, title="RSI Length", group="Stochastic RSI") bool cfg_show_settings_table = input(title="Show Table With Settings", defval=false, type=input.bool, group="UI") string rsi_start_operation = input(defval="<=", title="RSI Trigger ------", type=input.string, group="Deal Trigger Conditions", options=["not used", "<=", ">="], inline="1") int rsi_trigger_value = input(type=input.integer, defval=30, title="", inline="1", group="Deal Trigger Conditions") string stochk_start_operation = input(defval="<=", title="Stoch K Trigger", type=input.string, options=["not used", "<=", ">="], inline="2", group="Deal Trigger Conditions") int stochk_trigger_value = input(type=input.integer, defval=20, title="", inline="2", group="Deal Trigger Conditions") string stochd_start_operation = input(defval="not used", title="Stoch D Trigger", type=input.string, options=["not used", "<=", ">="], inline="3", group="Deal Trigger Conditions") int stochd_trigger_value = input(type=input.integer, defval=20, title="", inline="3", group="Deal Trigger Conditions") rsi = rsi(source, lengthRSI) rsiStoch = rsi(source, lengthRSIStoch) //k is blue k = sma(stoch(rsiStoch, rsiStoch, rsiStoch, lengthStoch), smoothK) //d is orange d = sma(k, smoothD) crossover = crossover(k, d) crossunder = crossunder(k, d) //RSI bool rsi_start_condition = false if rsi_start_operation != "not used" if (rsi_start_operation == "<=") rsi_start_condition := (rsi <= rsi_trigger_value) else if (rsi_start_operation == ">=") rsi_start_condition := (rsi >= rsi_trigger_value) else rsi_start_condition := true //Stoch K bool stochk_start_condition = false if stochk_start_operation != "not used" if (stochk_start_operation == "<=") stochk_start_condition := (k <= stochk_trigger_value) else if (stochk_start_operation == ">=") stochk_start_condition := (k >= stochk_trigger_value) else stochk_start_condition := true //Stoch D bool stochd_start_condition = false if stochd_start_operation != "not used" if (stochd_start_operation == "<=") stochd_start_condition := (d <= stochd_trigger_value) else if (stochd_start_operation == ">=") stochd_start_condition := (d >= stochd_trigger_value) else stochd_start_condition := true signal_trigger_dca = (rsi_start_condition and stochk_start_condition and stochd_start_condition) ? 1 : 0 _colorlong = (IS_LONG?color.new(color.green, 0):color.new(color.green, 100)) _colorshort = (IS_LONG?color.new(color.red, 100):color.new(color.red, 0)) _style = (IS_LONG?shape.arrowup:shape.arrowdown) _location = (IS_LONG?location.belowbar:location.abovebar) //just for UI plotshape(signal_trigger_dca, color=_colorlong, textcolor=_colorlong, text="BUY", style=_style, size=size.normal, location=_location) //for integration with DCA backtester or alerts, display none plot(signal_trigger_dca, title="SIGNAL", display=display.none) if cfg_show_settings_table and barstate.islastconfirmedhistory table settings = table.new(position.top_right, columns=1, rows=2, frame_width=1, frame_color=color.black) _row = 0 table.cell(settings, column=0, row=0, text="LONG SIGNAL Settings", text_halign=text.align_left, text_size=size.normal, text_color=color.white, bgcolor=#006bb3) _text = tostring(syminfo.currency)+"_"+tostring(syminfo.basecurrency)+" "+tostring(timeframe.period)+"\n\n" if rsi_start_operation != "not used" _text += "RSI-"+tostring(lengthRSI)+" "+tostring(rsi_start_operation)+" "+tostring(rsi_trigger_value)+"\n" else _text += "RSI-"+tostring(lengthRSI)+" "+tostring(rsi_start_operation)+"\n" if stochk_start_operation != "not used" _text += "Stoch-K-"+tostring(smoothK)+" "+tostring(stochk_start_operation)+" "+tostring(stochk_trigger_value)+"\n" else _text += "Stoch-K-"+tostring(smoothK)+" "+tostring(stochk_start_operation)+"\n" if stochd_start_operation != "not used" _text += "Stoch-D-"+tostring(smoothD)+" "+tostring(stochd_start_operation)+" "+tostring(stochd_trigger_value)+"\n" else _text += "Stoch-D-"+tostring(smoothD)+" "+tostring(stochd_start_operation)+"\n" _text += "\n\n\nAll settings\nK :"+tostring(smoothK)+" D: "+tostring(smoothD)+" StochLength: "+tostring(lengthStoch)+"\nRSIStochLength: "+tostring(lengthRSIStoch)+" RSI: "+tostring(lengthRSI) table.cell(settings, column=0, row=1, text=_text, text_halign=text.align_left, text_color=color.black, text_size=size.normal, bgcolor=#CACACA)
Volume Profile Heatmap
https://www.tradingview.com/script/oCuvfPRd-Volume-Profile-Heatmap/
colejustice
https://www.tradingview.com/u/colejustice/
1,355
study
5
CC-BY-NC-SA-4.0
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/ // Copyright coleJustice, LuxAlgo (https://www.tradingview.com/script/5MggSfGG-Volume-Profile-LUX/) // A variation of a Volume Profile based on code originally by LuxAlgo. The traditional bar chart is replaced with full-width bars that are brighter for high volume price levels. // Like a traditional VP, the purpose is to visualise how volume corresponds to specific price levels, allowing you to get a quick idea of where the most activity is occurring, // and where it hasn't been. This information may provide clues as to where price action may return, areas of support and resistance, and regions where price may move quickly. // Inputs are set up such that you can customize the lookback period, number of rows, and width of rows for most major timeframes individually. // Timeframes between those available will use the next lower timeframe settings (e.g., 2m chart will use the 1m settings.) // This indicator is experimental and is likely to receive further updates. //@version=5 indicator('Volume Profile Heatmap', 'Volume Profile Heatmap', true, max_bars_back=1000, max_boxes_count=500) import PineCoders/VisibleChart/3 as PCvc useVisibleRange = input.bool(true, "Use Visible Range", inline="vr", group='     Lookback       # Rows') numRows_vr = input.int(250, title='', minval=1, maxval=500, inline="vr", group='     Lookback       # Rows') lookbackLength_1m = input.int(780, ' 1m', minval=1, maxval=1000, group='     Lookback       # Rows', inline="1m") numRows_1m = input.int(250, title='', minval=1, maxval=500, group='     Lookback       # Rows', inline="1m", tooltip = "Lookback period (in bars) and number of rows for each timeframe. Timeframes between those defined here use the next closest lower timeframe.") lookbackLength_5m = input.int(390, ' 5m', minval=1, maxval=1000, group='     Lookback       # Rows', inline="5m") numRows_5m = input.int(250, title='', minval=1, maxval=500, group='     Lookback       # Rows', inline="5m") lookbackLength_15m = input.int(260, '15m', minval=1, maxval=1000, group='     Lookback       # Rows', inline="15m") numRows_15m = input.int(250, title='', minval=1, maxval=500, group='     Lookback       # Rows', inline="15m") lookbackLength_30m = input.int(260, '30m', minval=1, maxval=1000, group='     Lookback       # Rows', inline="30m") numRows_30m = input.int(250, title='', minval=1, maxval=500, group='     Lookback       # Rows', inline="30m") lookbackLength_1h = input.int(188, ' 1h', minval=1, maxval=1000, group='     Lookback       # Rows', inline="1h") numRows_1h = input.int(250, title='', minval=1, maxval=500, group='     Lookback       # Rows', inline="1h") lookbackLength_1d = input.int(120, '  D', minval=1, maxval=1000, group='     Lookback       # Rows', inline="1d") numRows_1d = input.int(250, title='', minval=1, maxval=500, group='     Lookback       # Rows', inline="1d") lookbackLength_1w = input.int(75, '  W', minval=1, maxval=1000, group='     Lookback       # Rows', inline="1w") numRows_1w = input.int(250, title='', minval=1, maxval=500, group='     Lookback       # Rows', inline="1w") lookbackLength_fallback = input.int(100, '___', minval=1, maxval=1000, group='     Lookback       # Rows', inline="fallback") numRows_fallback = input.int(250, title='', minval=1, maxval=500, group='     Lookback       # Rows', inline="fallback", tooltip='These values are used for any periods not captured between the above.') PoCThickness = input.int(4, title="Point of Control    ", tooltip = "Thickness and color of the Point of Control Plot", group="Style", inline="poc") PoCColor = input.color(color.orange, title="", group="Style", inline="poc") lowVolColor = input.color(color.new(color.aqua, 30), title="Volume Gradient   ", inline="grad", group="Style", tooltip = "Colors for the volume rows from Highest to Lowest.") highVolColor = input.color(color.new(color.white, 99), title="", inline="grad", group="Style") gradientMult = input.float(1.5, minval=0.1, step=0.1, title="Gradient Multiplier", group="Style", tooltip="Adjusts sharpness of the gradient by emphasizing bright areas and deemphasizing dim areas.") //----------------------------------------------------------------------------------------- isNewPeriod = ta.change(time('D')) var float _chartTfInMinutes = timeframe.multiplier * (timeframe.isseconds ? 1. / 60 : timeframe.isminutes ? 1. : timeframe.isdaily ? 60. * 24 : timeframe.isweekly ? 60. * 24 * 7 : timeframe.ismonthly ? 60. * 24 * 30.4375 : na) lookbackLength = _chartTfInMinutes < 5 ? lookbackLength_1m : _chartTfInMinutes < 15 ? lookbackLength_5m : _chartTfInMinutes < 30 ? lookbackLength_15m : _chartTfInMinutes < 60 ? lookbackLength_30m : _chartTfInMinutes < 120 ? lookbackLength_1h : _chartTfInMinutes < 10080 ? lookbackLength_1d : _chartTfInMinutes == 10080 ? lookbackLength_1w : lookbackLength_fallback numRows = useVisibleRange ? numRows_vr : _chartTfInMinutes < 5 ? numRows_1m : _chartTfInMinutes < 15 ? numRows_5m : _chartTfInMinutes < 30 ? numRows_15m : _chartTfInMinutes < 60 ? numRows_30m : _chartTfInMinutes < 120 ? numRows_1h : _chartTfInMinutes < 10080 ? numRows_1d : _chartTfInMinutes == 10080 ? numRows_1w : numRows_fallback //Below is a modified version of the code written by LuxAlgo for https://www.tradingview.com/script/5MggSfGG-Volume-Profile-LUX/ var rowsBoxes = array.new_box() if barstate.isfirst for i = 0 to numRows - 1 by 1 array.push(rowsBoxes, box.new(na, na, na, na)) var pocLine = line.new(na, na, na, na, width=2) if (useVisibleRange) lookbackLength := PCvc.bars() + 1 lookbackLength_fallback := PCvc.bars() + 1 leftBarIndex = PCvc.leftBarIndex() rightBarIndex = PCvc.rightBarIndex() rightBarZeroIndex = bar_index - rightBarIndex highest = useVisibleRange ? PCvc.high() : ta.highest(lookbackLength) lowest = useVisibleRange ? PCvc.low() : ta.lowest(lookbackLength) priceRange = (highest-lowest)/numRows line poc = na box rowBox = na levels = array.new_float(0) sumVol = array.new_float(0) // Table Dashboard (8 columns) For Debugging during dev //tablePosition = position.top_center //var table moodTable = table.new(tablePosition, 3, 1, border_width = 3) //f_fillCell(_column, _row, _cellText, _c_color) => //table.cell(moodTable, _column, _row, _cellText, bgcolor = color.new(_c_color, 75), text_color = _c_color) if barstate.islast //f_fillCell(0, 0, "leftMost: " + str.tostring(leftBarIndex), color.white) //f_fillCell(1, 0, "rightMost: " + str.tostring(rightBarIndex), color.white) //f_fillCell(2, 0, "bars: " + str.tostring(rightBarZeroIndex), color.white) for i = 0 to numRows by 1 array.push(levels, lowest + i / numRows * (highest - lowest)) for j = 0 to numRows - 1 by 1 sum = 0. for k = rightBarZeroIndex to lookbackLength + rightBarZeroIndex - 1 by 1 sum := high[k] > array.get(levels, j) and low[k] < array.get(levels, j + 1) ? sum + volume[k] : sum array.push(sumVol, sum) for j = 0 to numRows - 1 by 1 mult = math.pow(array.get(sumVol, j) / array.max(sumVol), gradientMult) rowBox := array.get(rowsBoxes, j) volumeLevel = array.get(levels, j) box.set_lefttop(rowBox, bar_index - lookbackLength - rightBarZeroIndex, volumeLevel-(priceRange/2)) box.set_rightbottom(rowBox, bar_index - rightBarZeroIndex, volumeLevel + (priceRange/2)) box.set_bgcolor(rowBox, color.from_gradient(mult * 99, 0, 100, highVolColor, lowVolColor)) box.set_border_width(rowBox, 0) if mult == 1 avg = math.avg(volumeLevel, array.get(levels, j + 1)) line.set_xy1(pocLine, bar_index - lookbackLength - rightBarZeroIndex + 1, avg) line.set_xy2(pocLine, bar_index, avg) line.set_color(pocLine, PoCColor) line.set_style(pocLine, line.style_dotted) line.set_width(pocLine, PoCThickness)
Williams Fractals BUY/SELL signals indicator
https://www.tradingview.com/script/rBW3jjnF-Williams-Fractals-BUY-SELL-signals-indicator/
B_L_A_C_K_S_C_O_R_P_I_O_N
https://www.tradingview.com/u/B_L_A_C_K_S_C_O_R_P_I_O_N/
249
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © B_L_A_C_K_S_C_O_R_P_I_O_N // v 1.1 // *************Recomended Conditions*************// // TF : 15m // // SL : 3% // // TP : 0.5% // // ***********************************************// //@version=4 study("Williams Fractals BUY/SELL signals indicator by ȼhąţhµяąɲǥą", overlay=true) // *************Appearance************* theme = input(type=input.string, defval="dark", options=["light","dark"], group="Appearance") show_fractals = input(false, "Show Fractals", group="Appearance") show_ema = input(false, "Show EMAs", group="Appearance") // *************colors************* color_green = color.green color_red = color.red color_yellow = color.yellow color_orange = color.orange color_blue = color.blue color_white = color.white // *************WF************* // Define "n" as the number of periods and keep a minimum value of 2 for error handling. n = input(title="Fractal Periods", defval=2, minval=2, type=input.integer, group="Williams Fractals") // UpFractal bool upflagDownFrontier = true bool upflagUpFrontier0 = true bool upflagUpFrontier1 = true bool upflagUpFrontier2 = true bool upflagUpFrontier3 = true bool upflagUpFrontier4 = true for i = 1 to n upflagDownFrontier := upflagDownFrontier and (high[n-i] < high[n]) upflagUpFrontier0 := upflagUpFrontier0 and (high[n+i] < high[n]) upflagUpFrontier1 := upflagUpFrontier1 and (high[n+1] <= high[n] and high[n+i + 1] < high[n]) upflagUpFrontier2 := upflagUpFrontier2 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+i + 2] < high[n]) upflagUpFrontier3 := upflagUpFrontier3 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+i + 3] < high[n]) upflagUpFrontier4 := upflagUpFrontier4 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+4] <= high[n] and high[n+i + 4] < high[n]) flagUpFrontier = upflagUpFrontier0 or upflagUpFrontier1 or upflagUpFrontier2 or upflagUpFrontier3 or upflagUpFrontier4 upFractal = (upflagDownFrontier and flagUpFrontier) // downFractal bool downflagDownFrontier = true bool downflagUpFrontier0 = true bool downflagUpFrontier1 = true bool downflagUpFrontier2 = true bool downflagUpFrontier3 = true bool downflagUpFrontier4 = true for i = 1 to n downflagDownFrontier := downflagDownFrontier and (low[n-i] > low[n]) downflagUpFrontier0 := downflagUpFrontier0 and (low[n+i] > low[n]) downflagUpFrontier1 := downflagUpFrontier1 and (low[n+1] >= low[n] and low[n+i + 1] > low[n]) downflagUpFrontier2 := downflagUpFrontier2 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+i + 2] > low[n]) downflagUpFrontier3 := downflagUpFrontier3 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+i + 3] > low[n]) downflagUpFrontier4 := downflagUpFrontier4 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+4] >= low[n] and low[n+i + 4] > low[n]) flagDownFrontier = downflagUpFrontier0 or downflagUpFrontier1 or downflagUpFrontier2 or downflagUpFrontier3 or downflagUpFrontier4 downFractal = (downflagDownFrontier and flagDownFrontier) plotshape(downFractal and show_fractals, style=shape.triangleup, location=location.belowbar, offset=-n, color=color_green) plotshape(upFractal and show_fractals, style=shape.triangledown, location=location.abovebar, offset=-n, color=color_red) // *************EMA************* len_a = input(20, minval=1, title="EMA Length A", group="EMA") src_a = input(close, title="EMA Source A", group="EMA") offset_a = input(title="EMA Offset A", type=input.integer, defval=0, minval=-500, maxval=500, group="EMA") out_a = ema(src_a, len_a) plot(show_ema ? out_a : na, title="EMA A", color=color_green, offset=offset_a) len_b = input(50, minval=1, title="EMA Length B", group="EMA") src_b = input(close, title="EMA Source B", group="EMA") offset_b = input(title="EMA Offset B", type=input.integer, defval=0, minval=-500, maxval=500, group="EMA") out_b = ema(src_b, len_b) ema_b_color = (theme == "dark") ? color_yellow : color_orange plot(show_ema ? out_b : na, title="EMA B", color=ema_b_color, offset=offset_b) len_c = input(100, minval=1, title="EMA Length C", group="EMA") src_c = input(close, title="EMA Source C", group="EMA") offset_c = input(title="EMA Offset C", type=input.integer, defval=0, minval=-500, maxval=500, group="EMA") out_c = ema(src_c, len_c) ema_c_color = (theme == "dark") ? color_white : color_blue plot(show_ema ? out_c : na, title="EMA C", color=ema_c_color, offset=offset_c) // *************RSI************* rsi_len = input(14, minval=1, title="RSI Length", group="RSI") rsi_src = input(close, "RSI Source", type = input.source, group="RSI") up = rma(max(change(rsi_src), 0), rsi_len) down = rma(-min(change(rsi_src), 0), rsi_len) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) // *************Calculation************* long = (out_a > out_b) and (out_b > out_c) and downFractal and low[2] > out_c and rsi[2] < rsi short = (out_a < out_b) and (out_b < out_c) and upFractal and high[2] < out_c and rsi[2] > rsi plotshape(long, style=shape.labelup, color=color_green, location=location.belowbar, title="long label", text= "L", textcolor=color_white) plotshape(short, style=shape.labeldown, color=color_red, location=location.abovebar, title="short label", text= "S", textcolor=color_white) // *************End of Signals calculation*************
Zendog SHORT DCA Trigger RSI+StochRSI
https://www.tradingview.com/script/G1HDbWrg-Zendog-SHORT-DCA-Trigger-RSI-StochRSI/
zendog123
https://www.tradingview.com/u/zendog123/
190
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © zendog123 //@version=4 study("Zendog SHORT DCA Trigger RSI+StochRSI", shorttitle="SHORT DCA Trigger RSI+StochRSI", overlay=true) var bool IS_LONG = false //STOCH RSI condition for DCA Bot debugging source = input(type=input.source, defval=close, title="Stoch RSI Source", group="Stochastic RSI") smoothK = input(type=input.integer, defval=3, title="Stoch RSI SmoothK", group="Stochastic RSI") smoothD = input(type=input.integer, defval=3, title="Stoch RSI Smoothd", group="Stochastic RSI") lengthStoch = input(type=input.integer, defval=14, title="Stoch Length", group="Stochastic RSI") lengthRSIStoch = input(type=input.integer, defval=14, title="Stoch RSI Length", group="Stochastic RSI") lengthRSI = input(type=input.integer, defval=7, title="RSI Length", group="Stochastic RSI") bool cfg_show_settings_table = input(title="Show Table With Settings", defval=false, type=input.bool, group="UI") string rsi_start_operation = input(defval=">=", title="RSI Trigger ------", type=input.string, group="Deal Trigger Conditions", options=["not used", "<=", ">="], inline="1") int rsi_trigger_value = input(type=input.integer, defval=70, title="", inline="1", group="Deal Trigger Conditions") string stochk_start_operation = input(defval=">=", title="Stoch K Trigger", type=input.string, options=["not used", "<=", ">="], inline="2", group="Deal Trigger Conditions") int stochk_trigger_value = input(type=input.integer, defval=80, title="", inline="2", group="Deal Trigger Conditions") string stochd_start_operation = input(defval="not used", title="Stoch D Trigger", type=input.string, options=["not used", "<=", ">="], inline="3", group="Deal Trigger Conditions") int stochd_trigger_value = input(type=input.integer, defval=80, title="", inline="3", group="Deal Trigger Conditions") rsi = rsi(source, lengthRSI) rsiStoch = rsi(source, lengthRSIStoch) //k is blue k = sma(stoch(rsiStoch, rsiStoch, rsiStoch, lengthStoch), smoothK) //d is orange d = sma(k, smoothD) crossover = crossover(k, d) crossunder = crossunder(k, d) //RSI bool rsi_start_condition = false if rsi_start_operation != "not used" if (rsi_start_operation == "<=") rsi_start_condition := (rsi <= rsi_trigger_value) else if (rsi_start_operation == ">=") rsi_start_condition := (rsi >= rsi_trigger_value) else rsi_start_condition := true //Stoch K bool stochk_start_condition = false if stochk_start_operation != "not used" if (stochk_start_operation == "<=") stochk_start_condition := (k <= stochk_trigger_value) else if (stochk_start_operation == ">=") stochk_start_condition := (k >= stochk_trigger_value) else stochk_start_condition := true //Stoch D bool stochd_start_condition = false if stochd_start_operation != "not used" if (stochd_start_operation == "<=") stochd_start_condition := (d <= stochd_trigger_value) else if (stochd_start_operation == ">=") stochd_start_condition := (d >= stochd_trigger_value) else stochd_start_condition := true signal_trigger_dca = (rsi_start_condition and stochk_start_condition and stochd_start_condition) ? 1 : 0 _colorlong = (IS_LONG?color.new(color.green, 0):color.new(color.green, 100)) _colorshort = (IS_LONG?color.new(color.red, 100):color.new(color.red, 0)) _style = (IS_LONG?shape.arrowup:shape.arrowdown) _location = (IS_LONG?location.belowbar:location.abovebar) //just for UI plotshape(signal_trigger_dca, color=_colorshort, textcolor=_colorshort, text="SELL", style=_style, size=size.normal, location=_location) //for integration with DCA backtester, display none plot(signal_trigger_dca, title="SIGNAL", display=display.none) if cfg_show_settings_table and barstate.islastconfirmedhistory table settings = table.new(position.bottom_right, columns=1, rows=2, frame_width=1, frame_color=color.black) _row = 0 table.cell(settings, column=0, row=0, text="SHORT SIGNAL Settings", text_halign=text.align_left, text_size=size.normal, text_color=color.white, bgcolor=#006bb3) _text = tostring(syminfo.currency)+"_"+tostring(syminfo.basecurrency)+" "+tostring(timeframe.period)+"\n\n" if rsi_start_operation != "not used" _text += "RSI-"+tostring(lengthRSI)+" "+tostring(rsi_start_operation)+" "+tostring(rsi_trigger_value)+"\n" else _text += "RSI-"+tostring(lengthRSI)+" "+tostring(rsi_start_operation)+"\n" if stochk_start_operation != "not used" _text += "Stoch-K-"+tostring(smoothK)+" "+tostring(stochk_start_operation)+" "+tostring(stochk_trigger_value)+"\n" else _text += "Stoch-K-"+tostring(smoothK)+" "+tostring(stochk_start_operation)+"\n" if stochd_start_operation != "not used" _text += "Stoch-D-"+tostring(smoothD)+" "+tostring(stochd_start_operation)+" "+tostring(stochd_trigger_value)+"\n" else _text += "Stoch-D-"+tostring(smoothD)+" "+tostring(stochd_start_operation)+"\n" _text += "\n\n\nAll settings\nK :"+tostring(smoothK)+" D: "+tostring(smoothD)+" StochLength: "+tostring(lengthStoch)+"\nRSIStochLength: "+tostring(lengthRSIStoch)+" RSI: "+tostring(lengthRSI) table.cell(settings, column=0, row=1, text=_text, text_halign=text.align_left, text_color=color.black, text_size=size.normal, bgcolor=#CACACA)
MA + VolumeArea
https://www.tradingview.com/script/FAlUqBx5-ma-volumearea/
JanLosev
https://www.tradingview.com/u/JanLosev/
42
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Crypto_Elk // I am Now a Millionaire. Thank you! Jan. //@version=5 indicator(title='JL | MArea', shorttitle='MArea', overlay=true, precision=0) ml = input(50, title='Array N') qn = input.int(defval=1, title='Number of searches in Array', options=[1,2,3,4,5,6,7,8,9,10]) shb = input(title='Up Area', defval=true) shr = input(title='Down Area', defval=true) source = input(defval=close, title='Source MA') xl1 = input.int(21, title='Length Line1', minval=1) ll1 = input(title='MA Line1', defval=true) xl2 = input.int(50, title='Length Line2', minval=1) ll2 = input(title='MA Line2', defval=true) xl3 = input.int(100, title='Length Line3', minval=1) ll3 = input(title='MA Line3', defval=true) xl4 = input.int(200, title='Length Line4', minval=1) ll4 = input(title='MA Line4', defval=true) /////////////////////////////////////////// ln1 = ta.ema(source, xl1) ln2 = ta.ema(source, xl2) ln3 = ta.ema(source, xl3) ln4 = ta.ema(source, xl4) plot(ll1 ? ln1 : na, color=color.new(#ffffff, 50), linewidth=1, title='Line1') plot(ll2 ? ln2 : na, color=color.new(#ffe500, 50), linewidth=1, title='Line2') plot(ll3 ? ln3 : na, color=color.new(#ff9800, 50), linewidth=1, title='Line3') plot(ll4 ? ln4 : na, color=color.new(#ff001a, 50), linewidth=1, title='Line4') /////////////////////////////////////////// BM = close > open ? volume : 0 RM = close < open ? volume : 0 rm = array.new_float(0) for i = 0 to ml by qn array.push(rm, RM[i]) bm = array.new_float(0) for i = 0 to ml by qn array.push(bm, BM[i]) bmax = volume == array.max(bm) ? 1 : na rmax = volume == array.max(rm) ? 1 : na /////////////////////////////////////////// con = bmax val = open <= close ? close : close var line l1Line = na var line l2Line = na if con and bar_index and shb line.set_x2(l1Line, bar_index ) line.set_extend(l1Line, extend.none) line.set_x2(l2Line, bar_index ) line.set_extend(l2Line, extend.none) l1Line := line.new(bar_index, val, bar_index, val, style=line.style_dashed, color=color.new(close > open ? #1680d4 : #ff001a,100), width=1, extend=extend.none) l2Line := line.new(bar_index, open <= close ? high : low, bar_index, open <= close ? high : low, style=line.style_dashed, color=color.new(close > open ? #1680d4 : #ff001a,100), width=1, extend=extend.none) if not na(l1Line) and not na(l2Line) and line.get_x2(l1Line) != bar_index line.set_x2(l1Line, bar_index ) line.set_x2(l2Line, bar_index ) UpB = plot(line.get_price(l1Line, bar_index), color=color.new(#1680d4, 100), linewidth=1, title='1', editable=false) DownB = plot(line.get_price(l2Line, bar_index), color=color.new(#1680d4, 100), linewidth=1, title='2', editable=false) fill(UpB, DownB, color=color.new(#1680d4, 90), title='Up Area', editable=true, fillgaps=false) /////////////////////////////////////////// con1 = rmax val1 = open <= close ? close : close var line l3Line = na var line l4Line = na if con1 and bar_index and shr line.set_x2(l3Line, bar_index ) line.set_extend(l3Line, extend.none) line.set_x2(l4Line, bar_index ) line.set_extend(l4Line, extend.none) l3Line := line.new(bar_index, val1, bar_index, val1, style=line.style_dashed, color=color.new(close > open ? #1680d4 : #ff001a,100), width=1, extend=extend.none) l4Line := line.new(bar_index, open <= close ? high : low, bar_index, open <= close ? high : low, style=line.style_dashed, color=color.new(close > open ? #1680d4 : #ff001a,100), width=1, extend=extend.none) if not na(l3Line) and not na(l4Line) and line.get_x2(l3Line) != bar_index line.set_x2(l3Line, bar_index ) line.set_x2(l4Line, bar_index ) UpR = plot(line.get_price(l3Line, bar_index), color=color.new(#ff001a, 100), linewidth=1, title='1', editable=false) DownR = plot(line.get_price(l4Line, bar_index), color=color.new(#ff001a, 100), linewidth=1, title='2', editable=false) fill(UpR, DownR, color=color.new(#ff001a, 90), title='Down Area', editable=true, fillgaps=false) ///////////////////////////////////////////
BBD Master
https://www.tradingview.com/script/1I7nhyjM-BBD-Master/
Kent_RichProFit_93
https://www.tradingview.com/u/Kent_RichProFit_93/
371
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Kent_RichProFit_93 //@version=5 indicator(title='BBD Master', overlay=false, precision=2) //10Oct21 : revision 1 //16Nov21 : revision 2, added source input, candle turn green/turn red alerts and indicator descriptions //////////////////////////////////////// //Input //////////////////////////////////////// gr1 = 'Table' ind = input.bool(title='Show Table', tooltip ='Indicator Name, Status, Alerts', defval=true, inline='00', group=gr1) alert = input.bool(title='Show alerts', defval=true, inline='00', group=gr1) text_size = input.string(title='Table Text Size:', options=['AUTO', 'TINY', 'SMALL', 'NORMAL', 'LARGE', 'HUGE'], defval='AUTO', inline='01', group=gr1) w = input.int(title='/ Table Width:', defval=9, minval=4, maxval=20, inline='01', group=gr1) gr2 ='BBD Master' bbd_src = input.source(hlc3,"BBD Source", inline='03', group=gr2, tooltip='Recommend to use default source') bbd_avg = input.int(title='BBD Moving Average =', defval=5, minval=3, maxval=20, inline='03b', group=gr2) gr3='Indicator Descriptions Label' method_label = input.bool(title='Show Indicator Brief Description', defval=false, inline='04', group=gr3) //////////////////////////////////////// //Indicator Descriptions //////////////////////////////////////// ind_l = method_label? label.new(bar_index+1, 0, 'BBD Master : ' +'\n Green candle : inflow of fund, Red candle : outflow of fund' +'\n Technical Rebound = BBD <0, candle turns from red to green, moving up towards 0' +'\n Uptrend = BBD crossover 0, continue to move up' +'\n Downtrend = BBD >0, candle turns from green to red, moving down towards 0' +'\n Consolidation or Downtrend = BBD crossunder 0, continue to move down', color= color.new(color.purple,80), textcolor= color.black, size = size.small, style=label.style_label_left, textalign=text.align_left) :na label.delete(ind_l[1]) ///////////////////////////////// //Function Y = alpha*X + (1-alpha)*Y[1] Y(X, N, M) => alpha = M / N S2 = 0.0 S2 := nz(S2[1]) - nz(X[N]) + X M2 = 0.0 M2 := na(X[N]) ? na : S2 / N A2 = 0.0 A2 := na(A2[1]) ? M2 : alpha * X + (1 - alpha) * nz(A2[1]) A2 bbd_raw = Y(bbd_src, 5, 1) - Y(bbd_src, 13, 1) bbd = (bbd_raw - Y(bbd_raw, 3, 1)) * 100 bbd_color = bbd >= nz(bbd[1]) ? color.green : color.red plotcandle(bbd, bbd, nz(bbd[1]), nz(bbd[1]), title='BBD Master', color=bbd_color, wickcolor=bbd_color, bordercolor=bbd_color) bbd_bbl = ta.sma(bbd, bbd_avg) plot(bbd_bbl, title='BBD Average Line', color=color.new(color.fuchsia, 0), linewidth=1) //////////////////////////////////////// //BBD cross over 0 Alert bbd_co = ta.crossover(bbd, 0) bbd_co_c = bbd_co ? color.new(#FC0FC0, 40) : na bbd_co_t = bbd_co ? 0 : na plotcandle(bbd_co ? bbd : na, bbd_co ? bbd : na, bbd_co ? bbd[1] : na, bbd_co ? bbd[1] : na, title='BBD crossover 0, candle alert', color=color.yellow, wickcolor=color.yellow, bordercolor=color.yellow) plotshape(alert?bbd_co_t:na, title='BBD crossover 0, Text Alert', text='0', style=shape.triangleup, location=location.absolute, color=color.new(color.black, 0), size=size.tiny) bbd_cu = ta.crossunder(bbd, 0) //////////////////////////////////////// //Turn Green or Turn Red Labels bbd_turn_g = not bbd_co and bbd[2]>bbd[1] and bbd>bbd[1] bbd_turn_r = bbd[2]<bbd[1] and bbd<bbd[1] bbd_turn_g_t = bbd_turn_g ? bbd:na plotshape(alert?bbd_turn_g_t:na, title='BBD turn Green', text='G', style=shape.triangleup, location=location.absolute, color=color.new(color.green, 0), size=size.tiny) bbd_turn_r_t = bbd_turn_r ? bbd:na plotshape(alert?bbd_turn_r_t:na, title='BBD turn Red', text='R', style=shape.triangleup, location=location.absolute, color=color.new(color.red, 0), size=size.tiny) //////////////////////////////////////// z0 = hline(0, 'zero line', linestyle=hline.style_solid, color=color.blue, linewidth=2) //////////////////////////////////////// //Table var table Qtable = table.new(position.middle_right, 5, 5, border_width=1) textsize = size.auto if text_size == 'TINY' textsize := size.tiny textsize if text_size == 'SMALL' textsize := size.small textsize if text_size == 'NORMAL' textsize := size.normal textsize if text_size == 'LARGE' textsize := size.large textsize if text_size == 'HUGE' textsize := size.huge textsize f_fillCell_10(_table, _column, _row, _label) => _cellText_10 = ind ? _label : na _cellColor_10 = ind ? color.new(color.yellow, 0) : na table.cell(_table, _column, _row, _cellText_10, bgcolor=_cellColor_10, text_color=color.black, width=w) table.cell_set_text_size(Qtable, 1, 0, textsize) if barstate.islast f_fillCell_10(Qtable, 1, 0, 'BBD Master ') bbd_g_can = not bbd_turn_g and bbd>=bbd[1] bbd_r_can = not bbd_turn_r and bbd<bbd[1] bbd_stat_text = bbd_g_can ? 'Green candle' : bbd_r_can ?'Red candle' : bbd_turn_g ? 'turn Green' : bbd_turn_r ? 'turn Red' : bbd_co ? 'crossover 0' : bbd_co ? 'crossunder 0' : na bbd_stat_color = bbd_g_can ?color.new(color.green,80) : bbd_r_can ?color.new(color.red,80) : bbd_turn_g ?color.new(color.green,80) : bbd_turn_r ? color.new(color.red,80) : bbd_co ? color.yellow: bbd_co ? color.new(color.red,80):na f_fillCell_11(_table, _column, _row, _value) => _cellText_11 = ind ? _value : na _cellColor_11 = ind ? bbd_stat_color : na table.cell(_table, _column, _row, _cellText_11, bgcolor=_cellColor_11, text_color=color.black, width=w) table.cell_set_text_size(Qtable, 1, 1, textsize) if barstate.islast f_fillCell_11(Qtable, 1, 1, bbd_stat_text) f_fillCell12(_table, _column, _row, _value) => _cellText12 = ind ? str.tostring(_value, '#.##') : na _cellColor12 = ind ? bbd_stat_color : na table.cell(_table, _column, _row, _cellText12, bgcolor=_cellColor12, text_color=color.black, width=w) table.cell_set_text_size(Qtable, 1, 2, textsize) if barstate.islast f_fillCell12(Qtable, 1, 2, bbd) // bbd_co_text = bbd_co ? 'crossover 0' : bbd_co ? 'crossunder 0' : 'No Alert' // f_fillCell_12(_table, _column, _row, _value) => // _cellText_12 = ind ? _value : na // _cellColor_12 = ind ? bbd_co ? bbd_co_c : bbd_cu ? color.new(color.red, 80) : color.new(color.gray, 80) : na // table.cell(_table, _column, _row, _cellText_12, bgcolor=_cellColor_12, text_color=color.black, width=w) // if barstate.islast // f_fillCell_12(Qtable, 1, 2, bbd_co_text) // table.cell_set_text_size(Qtable, 1, 2, textsize)
Linear Regression Fan [LuxAlgo]
https://www.tradingview.com/script/YPswXly5-Linear-Regression-Fan-LuxAlgo/
LuxAlgo
https://www.tradingview.com/u/LuxAlgo/
1,156
study
5
CC-BY-NC-SA-4.0
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/ // © LuxAlgo //@version=5 indicator("Linear Regression Fan [LuxAlgo]", "LuxAlgo - Linear Regression Fan", overlay = true, max_bars_back = 2000, max_lines_count = 500) //------------------------------------------------------------------------------ //Settings //-----------------------------------------------------------------------------{ mult = input(2.) N = input.int(4,'Lines Per Side', minval = 0) initPos = input.float(0.5, 'Initial Fan Position [0, 1]', minval = 0, maxval = 1) src = input(close) //Style showChannel = input(true, 'Show Channel') up_col = input(#2157f3, 'Upper Colors', group = 'Style') mid_col = input(#ff5d00, 'Basis', group = 'Style') dn_col = input(#ff1100, 'Lower Colors', group = 'Style') x1 = input.time(0, 'Left Coordinate', confirm = true) x2 = input.time(0, 'Right Coordinate', confirm = true) //-----------------------------------------------------------------------------} //Populate X/Y arrays //-----------------------------------------------------------------------------{ n = bar_index var y = array.new<float>(0) var x = array.new<int>(0) if time >= x1 and time <= x2 y.unshift(src) x.unshift(n) //-----------------------------------------------------------------------------} //Display Fan //-----------------------------------------------------------------------------{ if time == x2 //Get linreg coefficients and RMSE vx = x.variance() vy = y.variance() cov = y.covariance(x) a = cov / vx b = y.avg() - a * x.avg() dev = math.sqrt(vy - vy * math.pow(cov / (math.sqrt(vy) * math.sqrt(vx)), 2)) * mult //Get coordinates y1 = a*x.last() + b y2 = a*x.first() + b //Set linear regression channel if showChannel line.new(x1, y1 + dev, x2, y2 + dev, xloc.bar_time , color = up_col , style = line.style_dashed , extend = extend.right) line.new(x1, y1, x2, y2, xloc.bar_time , color = mid_col , extend = extend.right) line.new(x1, y1 - dev, x2, y2 - dev, xloc.bar_time , color = dn_col , style = line.style_dashed , extend = extend.right) //Set linear regression fan for i = 1 to N init = initPos * (y1 + dev) + (1 - initPos) * (y1 - dev) line.new(x1, init, x2, y2 + i/N * dev, xloc.bar_time , color = up_col , extend = extend.right) line.new(x1, init, x2, y2 - i/N * dev, xloc.bar_time , color = dn_col , extend = extend.right) //-----------------------------------------------------------------------------}
CDC Divergences
https://www.tradingview.com/script/Sj4c6PLq-CDC-Divergences/
piriya33
https://www.tradingview.com/u/piriya33/
1,245
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © piriya33 //@version=4 study("CDC Divergences","CDC Divergences",overlay=true, max_labels_count = 500) // Inputs for Higher Highs and Lower Lows calculations g_hhll = "Higher highs / Lower lows" src = input(close,"Price Source",type=input.source,group=g_hhll) UseDifSrc = input(false,"Use different sources for High and Low",group=g_hhll) srcHi = input(high,"High:",input.source,group=g_hhll,inline="Diffsrc") srcLo = input(low,"Low:",input.source,group=g_hhll,inline="Diffsrc") lenL = input(5,"Pivot Lookback Left:",input.integer,minval=1,group=g_hhll,inline="pivotLR") lenR = input(5,"Right:",input.integer,group=g_hhll,inline="pivotLR") chksrc = input("RSI","Check Against:",input.string,options=["RSI","MACD","Stoch","Volume","OBV"]) g_rsi = "RSI Calculations" rsi_src = input(close,"RSI source:",input.source,group=g_rsi,inline="rsi") rsi_len = input(14,"/ length:",input.integer,minval=1,group=g_rsi,inline="rsi") rsi_ob = input(70,"Overbought",input.float,group=g_rsi,inline="rsi_obos") rsi_os = input(30,"Oversold",input.float,group=g_rsi,inline="rsi_obos") g_macd = "MACD Calculations" macd_src = input(close,"MACD source:",input.source,group=g_macd) macd_fast = input(12,"MACD Lookback Fast:",input.integer,group=g_macd,inline="macdlen") macd_slow = input(26,"/ Slow:",input.integer,group=g_macd,inline="macdlen") g_sto = "Stochastic Oscillator Calculations" sto_klen = input(14,"\%k Length:",input.integer,minval=1,group=g_sto,inline="stok") sto_ksmt = input(1,"/ \%k smoothing",input.integer,minval=1,group=g_sto,inline="stok") sto_dsmt = input(3,"\%d smoothing",input.integer,minval=1, group=g_sto, inline="stod") sto_sel = input("d","Use value:",input.string,options=["d","k","min/max"], group=g_sto, inline="stod") sto_ob = input(80,"Overbought",input.float,group=g_sto,inline="sto_obos") sto_os = input(20,"Oversold",input.float,group=g_sto,inline="sto_obos") g_obv = "On Balance Volume Calculation" // Calculates Highs and Lows _lows = pivotlow(UseDifSrc ? srcLo : src, lenL,lenR) _highs = pivothigh(UseDifSrc ? srcHi : src, lenL,lenR) _low0 = valuewhen(_lows, (UseDifSrc ? srcLo : src)[lenR], 0) _high0 = valuewhen(_highs, (UseDifSrc ? srcHi : src)[lenR], 0) _low1 = valuewhen(_lows, (UseDifSrc ? srcLo : src)[lenR], 1) _high1 = valuewhen(_highs, (UseDifSrc ? srcHi : src)[lenR], 1) HH = _high0 > _high0[1] and _high0 > _high1 // Checks for Higher Highs LL = _low0 < _low0[1] and _low0 < _low1 // Cheks for Lower Lows // Plot Lines Showing Pivot Highs and Pivot Lows on occurance 0 and 1 // plot(src) // plot(_low0, color=color.red, style=plot.style_stepline, offset=-len1) // plot(_low1, color=color.orange, style=plot.style_stepline, offset=-len1) // plot(_high0, color=color.green, style=plot.style_stepline, offset=-lenL) // plot(_high1, color=color.blue, style=plot.style_stepline, linewidth=2, offset=-lenL) // Plots arrows indicating higher highs and lower lows plotshape(HH,"Higher High",style=shape.triangledown, location=location.abovebar, offset=-lenR) plotshape(LL,"Lower Low", style=shape.triangleup,location=location.belowbar,offset=-lenR) // Signals // Buy on higher high and sell on lower lows // isLong = barssince(HH) < barssince(LL) // isShort = barssince(HH) > barssince(LL) // bcolor = isLong ? color.green : isShort ? color.red : color.blue // barcolor(bcolor) // Check for convergence divergence var BullishDiv = false var BearishDiv = false if chksrc == "RSI" // Check against RSI rsi = rsi(rsi_src,rsi_len) rsi_low0 = valuewhen(_lows, rsi[lenR], 0) rsi_high0 = valuewhen(_highs, rsi[lenR], 0) rsi_low1 = valuewhen(_lows, rsi[lenR], 1) rsi_high1 = valuewhen(_highs, rsi[lenR], 1) BullishDiv := LL and rsi_low1 < rsi_os and rsi_low0 > rsi_low1 BearishDiv := HH and rsi_high1 > rsi_ob and rsi_high0 < rsi_high1 else if chksrc == "MACD" //Check Against MACD [macd,_,_] = macd(macd_src,macd_fast,macd_slow,9) macd_low0 = valuewhen(_lows, macd[lenR], 0) macd_high0 = valuewhen(_highs, macd[lenR], 0) macd_low1 = valuewhen(_lows, macd[lenR], 1) macd_high1 = valuewhen(_highs, macd[lenR], 1) BullishDiv := LL and macd_low0 > macd_low1 BearishDiv := HH and macd_high0 < macd_high1 else if (chksrc == "Stoch") // Check Against STO k = sma(stoch(close,high,low,sto_klen),sto_ksmt) d = sma(k,sto_dsmt) sto_low = sto_sel == "d" ? d : sto_sel == "k" ? k : sto_sel == "min/max" ? min(k,d) : na sto_high = sto_sel == "d" ? d : sto_sel == "k" ? k : sto_sel == "min/max" ? max(k,d) : na sto_low0 = valuewhen(_lows, sto_low[lenR], 0) sto_high0 = valuewhen(_highs, sto_high[lenR], 0) sto_low1 = valuewhen(_lows, sto_low[lenR], 1) sto_high1 = valuewhen(_highs, sto_high[lenR], 1) BullishDiv := LL and sto_low1 < sto_os and sto_low0 > sto_low1 BearishDiv := HH and sto_high1 > sto_ob and sto_high0 < sto_high1 else if chksrc == "Volume" // Check Against Volume vol = volume vol_low0 = valuewhen(_lows, vol[lenR], 0) vol_high0 = valuewhen(_highs, vol[lenR], 0) vol_low1 = valuewhen(_lows, vol[lenR], 1) vol_high1 = valuewhen(_highs, vol[lenR], 1) BullishDiv := LL and vol_low0 < vol_low1 BearishDiv := HH and vol_high0 < vol_high1 else if chksrc == "OBV" // Check Against OBV _obv = obv obv_low0 = valuewhen(_lows, _obv[lenR], 0) obv_high0 = valuewhen(_highs, _obv[lenR], 0) obv_low1 = valuewhen(_lows, _obv[lenR], 1) obv_high1 = valuewhen(_highs, _obv[lenR], 1) BullishDiv := LL and obv_low0 > obv_low1 BearishDiv := HH and obv_high0 < obv_high1 else na // Plotshapes to quickly check if code is working correctly // plotshape(BullishDiv,"Bullsih Divergence",style=shape.arrowup,location=location.belowbar, // offset=-lenR,size=size.large,color=color.green) // plotshape(BearishDiv,"Bearish Divergence",style=shape.arrowdown,location=location.abovebar, // offset=-lenR,size=size.large,color=color.red) // Plots Labels Indicating Bullish / Bearish Divergences plotLabel(_offset, _div, _style, _color, _text) => if not na(_div) label.new(bar_index[_offset], _div,_text,style=_style,color=_color) BullDivVal = BullishDiv ? _lows : na BearDivVal = BearishDiv ? _highs : na plotLabel(lenR, BullDivVal, label.style_label_up, color.green, chksrc + " Bullish Divergence") plotLabel(lenR, BearDivVal, label.style_label_down, color.red, chksrc + " Bearish Divergence")
Levels High Low
https://www.tradingview.com/script/hLbvgtXE-levels-high-low/
nikfilippov05
https://www.tradingview.com/u/nikfilippov05/
237
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © nikfilippov05 //@version=4 study("Levels High Low", shorttitle="Levels High Low", overlay=true, max_bars_back = 5000, max_lines_count = 500, max_labels_count = 500) lenH = input(title="Length High", type=input.integer, defval=20, minval=1) lenL = input(title="Length Low", type=input.integer, defval=20, minval=1) var high_label = array.new_label() var low_label = array.new_label() var high_array_lines = array.new_line() var low_array_lines = array.new_line() var high_line = close var low_line = close fun(src, len, isHigh, _style, _yloc, _color, array_label, array_lines) => p = nz(src[len]) isFound = true for i = 0 to len - 1 if isHigh and src[i] > p isFound := false if not isHigh and src[i] < p isFound := false for i = len + 1 to 2 * len if isHigh and src[i] >= p isFound := false if not isHigh and src[i] <= p isFound := false if isFound array.push(array_label, label.new(bar_index[len], p, tostring(p), style=_style, yloc=_yloc, color=_color)) array.push(array_lines, line.new(bar_index[len], p, bar_index, p, color=_color, extend=extend.right)) if array.size(array_label) > 1 for i = 1 to array.size(array_label) - 1 if label.get_y(array.get(array_label, array.size(array_label) - 1)) > label.get_y(array.get(array_label, i - 1)) and src == high label.delete(array.get(array_label, i - 1)) line.delete(array.get(array_lines, i - 1)) if label.get_y(array.get(array_label, array.size(array_label) - 1)) < label.get_y(array.get(array_label, i - 1)) and src == low label.delete(array.get(array_label, i - 1)) line.delete(array.get(array_lines, i - 1)) if array.size(array_label) > 1 if label.get_y(array.get(array_label, array.size(array_label) - 1)) < high and src == high label.delete(array.get(array_label, array.size(array_label) - 1)) line.delete(array.get(array_lines, array.size(array_label) - 1)) if label.get_y(array.get(array_label, array.size(array_label) - 1)) > low and src == low label.delete(array.get(array_label, array.size(array_label) - 1)) line.delete(array.get(array_lines, array.size(array_label) - 1)) fun(high, lenH, true, label.style_label_down, yloc.abovebar, color.lime, high_label, high_array_lines) fun(low, lenL, false, label.style_label_up, yloc.belowbar, color.red, low_label, low_array_lines)
Relative Strength Comparison
https://www.tradingview.com/script/rPoutcIE-Relative-Strength-Comparison/
imbes2
https://www.tradingview.com/u/imbes2/
60
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © imbes //@version=4 study(title="Relative Strength Comparison", precision=5, shorttitle="RSC") //Inputs //compindex=input(type=input.string, title = "Comparison Index", options=["SPY", "SPX", "NDX", "DJI", "IWM", "BTC"], defval="SPY", tooltip="Select the comparison measure") compindex = input("SPY", type=input.symbol, title = "Enter Comparison Index") showonlyprice = input(false, title="Show Only Price?", tooltip = "Good for just seeing a different ticker's price at the same time") usersi=input(type=input.bool, title = "Compare RSI?", defval=false, tooltip="Compare the RSI values instead of price") showline=input(type=input.bool, title="Show 1.0 line?", defval=false, tooltip="Use this when comparing RSI") rsilen=input(type=input.integer, title="RSI Length", defval=14, tooltip="Select the length of the RSI lookback") src=close //Ticker Info currentticker = security(syminfo.tickerid, '', close) comp = security(compindex, '' , close) currentrsi = security(syminfo.tickerid, '', rsi(src, rsilen)) comprsi = security(compindex, '', rsi(src, rsilen)) //Calcs defaultr = currentticker / comp defaultr1 = currentrsi/comprsi hline1=1.0 line1=plot(usersi==false and showonlyprice==false ? defaultr : usersi == true and showonlyprice== false ? defaultr1 : usersi==false and showonlyprice==true ? comp : na, title="Ratio Line", color=color.new(color.orange, transp=30), linewidth=1) line2=plot(usersi==true? hline1 : na, title="1.0 Line", color=color.new(color.white, 70), style=plot.style_line)
Market Sessions Open/Close Levels
https://www.tradingview.com/script/mQDsfy2H-Market-Sessions-Open-Close-Levels/
MarkMcFX
https://www.tradingview.com/u/MarkMcFX/
305
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=4 study(title="Market Sessions Open/Close Levels", shorttitle="Market Levels", overlay=true) odl = input(true, title="Sydney/Daily Open") dopen = security(syminfo.ticker, 'D', close[1], barmerge.gaps_off, barmerge.lookahead_on) dcolor = close < dopen ? color.red : color.blue plot(odl and dopen ? dopen :na , title="Sydney/Daily Open",style=plot.style_linebr, color=dcolor, linewidth=3) UTCTimeInput = input('0930-0931', title="NYSE Open") UTCTimeInput2 = input('0800-0801', title="New York Open") UTCTimeInput3 = input('0300-0301', title="London Open") UTCTimeInput4 = input('1100-1101', title="London Close") UTCTimeInput5 = input('0200-0201', title="Frankfurt Open") UTCTimeInput7 = input('1900-1901', title="Tokyo Open") OpenValueTime = time("1", UTCTimeInput) OpenValueTime2 = time("1", UTCTimeInput2) OpenValueTime3 = time("1", UTCTimeInput3) OpenValueTime4 = time("1", UTCTimeInput4) OpenValueTime5 = time("1", UTCTimeInput5) OpenValueTime7 = time("1", UTCTimeInput7) var OpenPA = 0.0 if OpenValueTime if not OpenValueTime[1] OpenPA := open var OpenPA2 = 0.0 if OpenValueTime2 if not OpenValueTime2[1] OpenPA2 := open var OpenPA3 = 0.0 if OpenValueTime3 if not OpenValueTime3[1] OpenPA3 := open var OpenPA4 = 0.0 if OpenValueTime4 if not OpenValueTime4[1] OpenPA4 := open var OpenPA5 = 0.0 if OpenValueTime5 if not OpenValueTime5[1] OpenPA5 := open var OpenPA7 = 0.0 if OpenValueTime7 if not OpenValueTime7[1] OpenPA7 := open plot(not OpenValueTime ? OpenPA : na, title="NYSE Open", color=color.black, linewidth=2, style=plot.style_linebr) plot(not OpenValueTime2 ? OpenPA2 : na, title="New York Open", color=color.black, linewidth=2, style=plot.style_linebr) plot(not OpenValueTime3 ? OpenPA3 : na, title="London Open", color=color.black, linewidth=2, style=plot.style_linebr) plot(not OpenValueTime4 ? OpenPA4 : na, title="London Close", color=color.black, linewidth=2, style=plot.style_linebr) plot(not OpenValueTime5 ? OpenPA5 : na, title="Frankfurt Open", color=color.black, linewidth=2, style=plot.style_linebr) plot(not OpenValueTime7 ? OpenPA7 : na, title="Tokyo Open", color=color.black, linewidth=2, style=plot.style_linebr)
Volume
https://www.tradingview.com/script/6AfByBST-volume/
JanLosev
https://www.tradingview.com/u/JanLosev/
101
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © JanLosev // I am Now a Millionaire. Thank you! Jan. //@version=5 indicator(title="Volume", shorttitle="Volume", overlay=false, precision=2) source = input.source(close, "Source") length = input(28, "Length") bof = input.bool(true,"Volume BTC") eof = input.bool(false,"Volume ETH") mab = input.bool(false,"EMA BTC") mae = input.bool(false,"EMA ETH") sumb = input.bool(false,"SUM BTC") sume = input.bool(false,"SUM ETH") /// BITCOIN FIAT vBTC1 = request.security("BINANCEUS:BTCUSD", "", volume) prBTC2= request.security("FTX:BTCUSD", "", source) vBTC2 = request.security("FTX:BTCUSD", "", volume) / prBTC2 vBTC3 = request.security("COINBASE:BTCUSD", "", volume) vBTC4 = request.security("KRAKEN:XBTUSD", "", volume) vBTC5 = request.security("GEMINI:BTCUSD", "", volume) vBTC6 = request.security("BITFINEX:BTCUSD", "", volume) vBTC7 = request.security("BITSTAMP:BTCUSD", "", volume) perVOLUMEbtc = vBTC1 + vBTC2 + vBTC3 + vBTC4 + vBTC5 + vBTC6 + vBTC7 colvolumeBTC = close > open ? #1680d4:#ff001a plot(bof?perVOLUMEbtc:na,"volumeBTC_DOLLAR", style=plot.style_histogram, linewidth=3, color=colvolumeBTC) sumBTC_B = (close > open ? math.sum(perVOLUMEbtc,length) : na) sumBTC_R = (close < open ? math.sum(perVOLUMEbtc,length) : na) emaBTC = ta.ema(perVOLUMEbtc,length) plot(mab?emaBTC:na,"emaBTC",linewidth=1, color=#ffffff) plot(sumb?sumBTC_B:na,"sumBTC_Blue",linewidth=1, color=#1680d4) plot(sumb?sumBTC_R:na,"sumBTC_Red",linewidth=1, color=#ff001a) /// ETHEREUM FIAT vETH1 = request.security("BINANCEUS:ETHUSD", "", volume) prETH2= request.security("FTX:ETHUSD", "", source) vETH2 = request.security("FTX:ETHUSD", "", volume) / prETH2 vETH3 = request.security("COINBASE:ETHUSD", "", volume) vETH4 = request.security("KRAKEN:ETHUSD", "", volume) vETH5 = request.security("GEMINI:ETHUSD", "", volume) vETH6 = request.security("BITFINEX:ETHUSD", "", volume) vETH7 = request.security("BITSTAMP:ETHUSD", "", volume) perVOLUMEeth = vETH1 + vETH2 + vETH3 + vETH4 + vETH5 + vETH6 + vETH7 colvolumeETH = close > open ? #1680d4:#ff001a plot(eof?perVOLUMEeth:na,"volumeETH_DOLLAR", style=plot.style_histogram, linewidth=3, color=colvolumeETH) sumETH_B = (close > open ? math.sum(perVOLUMEeth,length) : na) sumETH_R = (close < open ? math.sum(perVOLUMEeth,length) : na) emaETH = ta.ema(perVOLUMEeth,length) plot(mae?emaETH:na,"emaETH",linewidth=1, color=#ffffff) plot(sume?sumETH_B:na,"sumETH_Blue",linewidth=1, color=#1680d4) plot(sume?sumETH_R:na,"sumETH_Red",linewidth=1, color=#ff001a)
EXAMPLES:enhanced_ta
https://www.tradingview.com/script/6KvRkPuW-EXAMPLES-enhanced-ta/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
202
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © HeWhoMustNotBeNamed // __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __ // / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / | // $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ | // $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ | // $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ | // $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ | // $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ | // $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ | // $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/ // // //@version=5 import HeWhoMustNotBeNamed/enhanced_ta/4 as eta indicator("enhanced_ta_examples", overlay=true) display = input.string("ma", title="Display Indicator", options=["all", "ma", "atr", "band", "bandwidth", "bandpercent","oscillator"]) overlay = input.bool(true, title="Overlay", inline="o") nonOverlay = input.bool(true, title="NonOverlay", inline="o") //************************************ ma *************************************************** // masource = input.source(close, title="Source", group="Moving Average") matype = input.string("sma", title="Type", group="Moving Average", options=["sma", "ema", "hma", "rma", "wma", "vwma", "swma", "linreg", "median"]) malength = input.int(20, title="Length", group="Moving Average") ma = eta.ma(masource, matype, malength) displayMa = display == "ma" or (display == "all" and overlay) plot(displayMa? ma : na, title="Moving Average", color=color.blue) //************************************ ATR *************************************************** // amatype = input.string("sma", title="Type", group="ATR", options=["sma", "ema", "hma", "rma", "wma", "vwma", "swma", "linreg", "median"]) amalength = input.int(20, title="Length", group="ATR") displayPercent = input.bool(false, title="Display as Percent", group="ATR") atr = eta.atr(amatype, amalength) atrpercent = eta.atrpercent(amatype, amalength) displayAtr = display == "atr" or (display == "all" and nonOverlay) plot(displayAtr? displayPercent? atrpercent : atr : na, title="ATR (or Percent)", color = color.blue) //************************************ bands *************************************************** // bandType = input.string("BB", title="Type", group="Bands/Bandwidth/BandPercent", options=["BB", "KC", "DC"]) bmasource = input.source(close, title="Source", group="Bands/Bandwidth/BandPercent") bmatype = input.string("sma", title="Type", group="Bands/Bandwidth/BandPercent", options=["sma", "ema", "hma", "rma", "wma", "vwma", "swma", "linreg", "median"]) bmalength = input.int(20, title="Length", group="Bands/Bandwidth/BandPercent") multiplier = input.float(2.0, step=0.5, title="Multiplier", group="Bands/Bandwidth/BandPercent") useTrueRange = input.bool(true, title="Use True Range (KC)", group="Bands/Bandwidth/BandPercent") useAlternateSource = input.bool(false, title="Use Alternate Source (DC)", group="Bands/Bandwidth/BandPercent") bsticky = input.bool(true, title="Sticky", group="Bands/Bandwidth/BandPercent") displayBands = display == "band" or (display == "all" and overlay) var cloudTransparency = 90 [bbmiddle, bbupper, bblower] = eta.bb(bmasource, bmatype, bmalength, multiplier, sticky=bsticky) [kcmiddle, kcupper, kclower] = eta.kc(bmasource, bmatype, bmalength, multiplier, useTrueRange, sticky=bsticky) [dcmiddle, dcupper, dclower] = eta.dc(bmalength, useAlternateSource, bmasource, sticky=bsticky) upper = bandType == "BB"? bbupper : bandType == "KC"? kcupper : dcupper lower = bandType == "BB"? bblower : bandType == "KC"? kclower : dclower middle = bandType == "BB"? bbmiddle : bandType == "KC"? kcmiddle : dcmiddle uPlot = plot(displayBands? upper: na, title="Upper", color=color.new(color.green, cloudTransparency)) lPlot = plot(displayBands? lower: na, title="Lower", color=color.new(color.red, cloudTransparency)) mPlot = plot(displayBands? middle: na, title="Middle", color=color.new(color.blue, cloudTransparency)) fill(uPlot, mPlot, title='UpperRange', color=color.new(color.green, cloudTransparency)) fill(lPlot, mPlot, title='LowerRange', color=color.new(color.red, cloudTransparency)) //************************************ bandwidth *************************************************** // bbw = eta.bbw(bmasource, bmatype, bmalength, multiplier, sticky=bsticky) kcw = eta.kcw(bmasource, bmatype, bmalength, multiplier, useTrueRange, sticky=bsticky) dcw = eta.dcw(bmalength, useAlternateSource, bmasource, sticky=bsticky) bandwidth = bandType == "BB"? bbw : bandType == "KC"? kcw : dcw displayBandwidth = display == "bandwidth" or (display == "all" and nonOverlay) plot(displayBandwidth? bandwidth: na, title="Bandwidth", color=color.maroon) //************************************ bandpercent *************************************************** // bpercentb = eta.bpercentb(bmasource, bmatype, bmalength, multiplier, sticky=bsticky) kpercentk = eta.kpercentk(bmasource, bmatype, bmalength, multiplier, useTrueRange, sticky=bsticky) dpercentd = eta.dpercentd(bmalength, useAlternateSource, bmasource, sticky=bsticky) bandpercent = bandType == "BB"? bpercentb : bandType == "KC"? kpercentk : dpercentd displayBandPercent = display == "bandpercent" or (display == "all" and nonOverlay) plot(displayBandPercent? bandpercent: na, title="BandPercent", color=color.fuchsia) //************************************ Oscillators *************************************************** // oscType = input.string("cci", title="Oscillator Type", group="Oscillator", options=["cci", "cmo", "cog", "mfi", "roc", "rsi", "stoch", "tsi", "wpr"]) oLength = input.int(14, title="Length", group="Oscillator") shortLength = input.int(9, title="Short Length (TSI)", group="Oscillator") longLength = input.int(9, title="Long Length (TSI)", group="Oscillator") method = input.string("highlow", title="Dynamic Overvought/Oversold Calculation method", group="Oscillator", options=["highlow", "sma", "ema", "hma", "rma", "wma", "vwma", "swma", "linreg", "median"]) highlowlength = input.int(50, title="Length", group="Oscillator") osticky = input.bool(true, title="Sticky", group="Oscillator") [oscillator, overbought, oversold] = eta.oscillator(oscType, oLength, shortLength, longLength, method = method, highlowLength=highlowlength, sticky=osticky) // Just using oscillatorRange with only oscillator input // [newUpper, newLower] = eta.oscillatorRange(oscillator, method, highlowlength, oLength, osticky) displayOscillator = display == "oscillator" or (display == "all" and nonOverlay) plot(displayOscillator? oscillator: na, title="Oscillator", color=color.blue) plot(displayOscillator? overbought: na, title="Overbought", color=color.red) plot(displayOscillator? oversold: na, title="Oversold", color=color.green)
Multpile strategies [LUPOWN]
https://www.tradingview.com/script/pCk31Ggf-Multpile-strategies-LUPOWN/
Lupown
https://www.tradingview.com/u/Lupown/
4,141
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Lupown //@version=4 study(shorttitle="Multiple strategies [LPWN]", title="Multpile strategies [LUPOWN]", overlay=false) //squeeze momoentum by lazy bear show_Momen = input(true, title="-----------Show squeeze momentum-------") int lengthM = input(20, title="MOM Length", minval=1, step=1) srcM = input(close, title="MOM Source", type=input.source) int length = input(20, title="SQZ Length", minval=1, step=1) src = input(close, title="SQZ Source", type=input.source) //Momentum sz = linreg(srcM - avg(avg(highest(high, lengthM), lowest(low, lengthM)), sma(close, lengthM)), lengthM, 0) //Momentum Conditions sc1 = sz >= 0 sc2 = sz < 0 sc3 = sz >= sz[1] sc4 = sz < sz[1] clr = sc1 and sc3 ? #00FF00 : sc1 and sc4 ? #008000 : sc2 and sc4 ? #FF0000 : sc2 and sc3 ? #800000 : color.gray plot(show_Momen ? sz : na, title="Squeeze Momentum", color=clr, style=plot.style_area) //SQUEEZE lengths = input(20, title="BB Length") mult = input(2.0,title="BB MultFactor") lengthKC=input(20, title="KC Length") multKC = input(1.5, title="KC MultFactor") scale = input(75.0, title = "General scale") useTrueRange = true // Calculate BB source = close basis = sma(source, lengths) dev = multKC * stdev(source, lengths) upperBB = basis + dev lowerBB = basis - dev // Calculate KC ma = sma(source, lengthKC) range = useTrueRange ? tr : (high - low) rangema = sma(range, lengthKC) upperKC = ma + rangema * multKC lowerKC = ma - rangema * multKC sqzOn = (lowerBB > lowerKC) and (upperBB < upperKC) sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC) noSqz = (sqzOn == false) and (sqzOff == false) scolor = noSqz ? color.blue : sqzOn ? #000000 : color.gray //plotshape(show_Momen? true : na, color=scolor, style=shape.xcross) plot(show_Momen ? 0 : na, title="Squeeze Zero Line", color=scolor, linewidth=2, style=plot.style_cross, transp=0) //plotshape(show_Momen?0:na,style=shape.xcross,color=scolor,location=location.absolute) ///// ADX show_ADX = input(true, title = "------------Show ADX------------") scaleADX = input(2.0, title = "ADX scale") show_di = input(false, title = " Show +DI -DI") show_aa = input(false, "Mostrar punto 23 aparte", inline="adx line") far = input(-7, "Separacion", inline="adx line") adxlen = input(14, title = "ADX Smoothing") dilen = input(14, title = "DI Length") keyLevel = input(23, title = "Key level for ADX") show_bg = input (false, title = "Show bg color") dirmov(len) => up = change(high) down = -change(low) truerange = rma(tr, len) plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange) minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange) [plus, minus] adx(dilen, adxlen) => [plus, minus] = dirmov(dilen) sum = plus + minus adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen) [adx, plus, minus] [adxValue, diplus, diminus] = adx(dilen, adxlen) /////////////////////////////////////////////////////////////// //[diplus, diminus, adxValue] = dmi(dilen, adxlen) biggest(series) => max = 0.0 max := nz(max[1], series) if series > max max := series max // Calculate ADX Scale ni = biggest(sz) far1=far* ni/scale adx_scale = (adxValue - keyLevel) * ni/scale adx_scale2 = (adxValue - keyLevel+far) * ni/scale dip= (diplus - keyLevel) * ni/scale dim= (diminus - keyLevel) * ni/scale plot (show_di ? dip * scaleADX :na, color=color.green, title="DI+") plot (show_di ? dim * scaleADX :na, color=color.red, title="DI-") color_ADX = adxValue > adxValue[1] ? #ffffff : #a09a9a bgcolor(adxValue > adxValue[1] and adxValue > 23 and show_Momen and show_bg? clr : na, transp=95) /////////////////WHALE BY BLACKCAT1404 show_whale = input(false,title = "Show Whale detector") //functions xrf(values, length) => r_val = float(na) if length >= 1 for i = 0 to length by 1 if na(r_val) or not na(values[i]) r_val := values[i] r_val r_val xsa(src,len,wei) => sumf = 0.0 ma = 0.0 out = 0.0 sumf := nz(sumf[1]) - nz(src[len]) + src ma := na(src[len]) ? na : sumf/len out := na(out[1]) ? ma : (src*wei+out[1]*(len-wei))/len out //trend follower algorithm var2 = xrf(low,1) var3 = xsa(abs(low-var2),3,1)/xsa(max(low-var2,0),3,1)*100 var4 = ema(iff(close*1.2,var3*10,var3/10),3) var5 = lowest(low,30) var6 = highest(var4,30) var7 = iff(lowest(low,58),1,0) var8 = ema(iff(low<=var5,(var4+var6*2)/2,0),3)/618*var7 //whale pump detector //plotcandle(0,var8 * (ni/scale) ,0,var8* (ni/scale),color= var8 > 0 and show_whale ?color.yellow:na) plot(show_whale? var8 * (ni/scale) : na, title = "whale" , style = plot.style_columns,color=color.yellow, transp=80) /////////////////// //RSI show_rsi = input(true, title="------------Show RSI---------") show_RSIfondo=input(true, title="Show RSI background") rsiApart = input(0,title="RSI separation") len = input(14, minval=1, title="Length RSI ") upperR = input (70,title="Upper band") middleR = input (50,title="Middle band") lowerR = input(30,title="Lower band") rsi = rsi(src, len) rsiColor = rsi <= lowerR ? color.green : rsi >= upperR ? color.red : #da00ff rsi_scale=(rsi+rsiApart)* ni/scale b1s=(rsiApart+upperR) * ni/scale bm= (rsiApart+middleR) * ni/scale b0s=(rsiApart+lowerR) * ni/scale /////otro RSI DIVERGENCE show_rsi2 = input (true,title = "Show RSI DIVERGENCE") farRSI = input(70,title = "Adjust RSI DIVERGENCE") src_fast = close, len_fast = input(5, minval=1, title="Length Fast RSI") src_slow = close, len_slow = input(14,minval=1, title="Length Slow RSI") up_fast = rma(max(change(src_fast), 0), len_fast) down_fast = rma(-min(change(src_fast), 0), len_fast) rsi_fast = down_fast == 0 ? 100 : up_fast == 0 ? 0 : 100 - (100 / (1 + up_fast / down_fast)) up_slow = rma(max(change(src_slow), 0), len_slow) down_slow = rma(-min(change(src_slow), 0), len_slow) rsi_slow = down_slow == 0 ? 100 : up_slow == 0 ? 0 : 100 - (100 / (1 + up_slow / down_slow)) //plotfast = plot(rsi_fast, color=blue) //plotslow = plot(rsi_slow, color=orange) divergence = rsi_fast - rsi_slow //plotdiv = plot(divergence, color = divergence > 0 ? color.lime:color.red, linewidth = 2) divergence_scale = divergence * (ni/scale) rsiColor2 = divergence > 0 ? color.lime:color.red plot(show_rsi ? rsi_scale : show_rsi2 ? divergence_scale + (farRSI * ni/scale) : na, "RSI", color=show_rsi ? rsiColor : show_rsi2 ? rsiColor2 :na) ////// ///////// /////// estocastico show_stoch=input(false,title="-------Show Stochastic------") periodK = input(14, title="%K Length", minval=1) smoothK = input(1, title="%K Smoothing", minval=1) periodD = input(3, title="%D Smoothing", minval=1) k = sma(stoch(close, high, low, periodK), smoothK) d = sma(k, periodD) k1=k* ni/scale d1=d* ni/scale plot(show_stoch?k1:na, title="%K", color=#2962FF) plot(show_stoch?d1:na, title="%D", color=#FF6D00) upS=input(80,title = "Upper band") lowS=input(20,title = "Lower band") h1s=upS * ni/scale h0s=lowS * ni/scale //plot(show_stoch? h1s : na,color=bar_index % 2 == 0 ? color.white : #00000000,transp=60) //plot(show_stoch? h0s : na,color=bar_index % 2 == 0 ? color.white : #00000000,transp=60) //band1 = plot(show_rsi? b1s : show_stoch? h1s: na,color=bar_index % 2 == 0 ? color.white : #00000000,transp=60) //bandm = plot(show_rsi? bm : na,color=bar_index % 2 == 0 ? color.white : #00000000,transp=70) //band0 = plot(show_rsi? b0s : show_stoch ? h0s: na,color=bar_index % 2 == 0 ? color.white : #00000000,transp=60) /////// /////////////////AWESOME show_ao = input(false, title="-----------Show AO-------") show_aoF = input(true, title = "Show ao away 0 point") farAO = input(-30 , title = "Away from 0 point") fastLength = input(5,title="Fast Length") slowLength = input(34,title="Slow Length") ao = sma(hl2, fastLength) - sma(hl2, slowLength) //nia = biggest(aoN) //ao = aoN*nia/scale ao_f = ao + (farAO * ni /scale) aoColor = ao >= 0 ? (ao[1] < ao ? #26A69A : #B2DFDB) : (ao[1] < ao ? #FFCDD2 : #EF5350) aoPlot = plot(show_aoF and show_ao ? ao_f : show_ao ? ao : na, title="AO", style= show_aoF ? plot.style_line : show_ao ? plot.style_area: plot.style_area , color=aoColor, transp=0) // bandA = plot(show_aoF and show_ao ? farAO * ni /scale : na, color=color.white,transp=60) fill(aoPlot,bandA, color= show_aoF and show_ao ? aoColor : na,transp=90,title="AO Fill") ///////////////////// //////////////////////////////////// ///////MACD ///////////////////////////// show_macd = input(false, title="-----------Show MACD-------") show_macdF = input (true, title = "Show MACD area away 0 point") show_macdLF = input(true, title = "Show MACD lines away 0 point") macdF = input(-30 , title = "Away 0 point") show_macdL= input(false, title="Show MACD lines") fast_length = input(title="Fast Length", type=input.integer, defval=12) slow_length = input(title="Slow Length", type=input.integer, defval=26) //src = input(title="Source", type=input.source, defval=close) signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9) sma_source = input(title="Oscillator MA Type", type=input.string, defval="EMA", options=["SMA", "EMA"]) sma_signal = input(title="Signal Line MA Type", type=input.string, defval="EMA", options=["SMA", "EMA"]) macdScale = input(2,title="MACD scale") //calculating fast_ma = sma_source == "SMA" ? sma(src, fast_length) : ema(src, fast_length) slow_ma = sma_source == "SMA" ? sma(src, slow_length) : ema(src, slow_length) macd1 = fast_ma - slow_ma signal = sma_signal == "SMA" ? sma(macd1, signal_length) : ema(macd1, signal_length) hist = (macd1 - signal) //color macdColor = hist >= 0 ? (hist[1] < hist ? #26A69A : #B2DFDB) : (hist[1] < hist ? #FFCDD2 : #EF5350) histo = hist * macdScale macd=macd1*macdScale sign = signal * macdScale histo_f = histo + (macdF * ni /scale) colorlineMACD = macd > sign ? color.green : color.red histoA = plot(show_macdF and show_macd ? histo_f : show_macd ? histo : na, title="Histogram", style=show_macdF and show_macd ? plot.style_line : show_macd ? plot.style_columns : plot.style_columns , color=macdColor) plot(show_macdLF and show_macdL ? macd + (macdF * ni /scale) : show_macdL ? macd : na, title="MACD", color=colorlineMACD) plot(show_macdLF and show_macdL ? sign + (macdF * ni /scale) : show_macdL ? sign : na, title="Signal", color=color.orange) band_macd = plot(show_macdF and show_macd ? macdF * ni /scale : na, color=color.white,transp=60) fill(histoA,band_macd, color= show_macdF and show_macd ? macdColor : na,transp=90,title="MACD Fill") //////////////////////////////////////// //////////////////////END MACD ///////////////////////////////// //////////////////////////////////////// ////////////////////// KONOCORDE "Koncorde Inversiones en el Mundo by lkdml all the credits for them ///////////////////////////////// show_K = input(false, title = "---------------Show Koncorde-------------") scaleK= input(8,title = "Koncorde scale") showKF = input(true, title = "Show Koncorde away 0 point") fark= input (-30 , title = "Away from 0 point") show_KD = input(false, title = "Show Koncorde Diamond") kon_pos = input (30, title = "Position diamonds Bull") kon_posn = input (-30, title = "Position diamonds Bear") srcTprice = input(ohlc4, title="Fuente para Precio Total") srcMfi = input(hlc3, title="Fuente MFI", group="Money Flow Index") tprice=srcTprice //lengthEMA = input(255, minval=1) m=input(15, title="Media Exponencial") longitudPVI=input(90, title="Longitud PVI") longitudNVI=input(90, title="Longitud NVI") longitudMFI=input(14, title="Longitud MFI") multK=input(2.0, title="Multiplicador para derivacion estandar" , group="Bollinger Oscillator") boLength=input(25, title="Calculation length ", group="Bollinger Oscillator" ) pvim = ema(pvi, m) pvimax = highest(pvim, longitudPVI) pvimin = lowest(pvim, longitudPVI) oscp = (pvi - pvim) * 100/ (pvimax - pvimin) nvim = ema(nvi, m) nvimax = highest(nvim, longitudNVI) nvimin = lowest(nvim, longitudNVI) azul =( (nvi - nvim) * 100/ (nvimax - nvimin) ) xmf = mfi(srcMfi, longitudMFI) // Bands Calculation basisK = sma(tprice, boLength) //Find the 20-day moving average average (n1 + n2 ... + n20)/20 devK = mult * stdev(tprice, boLength) //Find the standard deviation of the 20-days upper = basisK + devK //Upper Band = 20-day Moving Average + (2 x standard deviation of the 20-days) lower = basisK - devK //Lower Band = 20-day Moving Average - (2 x standard deviation of the 20-days) OB1 = (upper + lower) / 2.0 OB2 = upper - lower BollOsc = ((tprice - OB1) / OB2 ) * 100 // percent b xrsi = rsi(tprice, 14) calc_stoch(src, length,smoothFastD ) => ll = lowest(low, length) hh = highest(high, length) k = 100 * (src - ll) / (hh - ll) sma(k, smoothFastD) stoc = calc_stoch(tprice, 21, 3) marron =( (xrsi + xmf + BollOsc + (stoc / 3))/2 ) verde = (marron + oscp) media = ema(marron,m) bandacero= showKF ? fark*ni/scale : 0 scaleK1 = (ni/scale)/scaleK //vl=plot(show_K ? verde *scaleK1: na, color=#66FF66, style=plot.style_area, title="verde")// COLOURED(102,255,102) as “verde” , GREEN //ml=plot(show_K ? marron *scaleK1: na, color= #FFCC99, style=plot.style_area, title="marron", transp=0) // COLOURED(255,204,153) as"marron" , BEIGE //al=plot(show_K ? azul *scaleK1: na, color=#126bd6, style=plot.style_area, title="azul") // COLOURED(0,255,255) as “azul” , lk1 = plot(show_K and showKF ? (marron *scaleK1) + (fark * ni /scale) : show_K ? marron *scaleK1: na, color= #330000, style=plot.style_line, linewidth=3, title="lmarron") // COLOURED(51,0,0) as “lmarron” , lk2 = plot(show_K and showKF ? (verde *scaleK1) + (fark * ni /scale) : show_K ? verde *scaleK1: na, color=#006600, style=plot.style_line, linewidth=3, title="lineav") // COLOURED(0,102,0) as “lineav” , lk3 = plot(show_K and showKF ? (azul *scaleK1) + (fark * ni /scale): show_K ? azul *scaleK1: na, color=#000066, style=plot.style_line, title="lazul" ) // COLOURED(0,0,102) as “lazul” , plot(show_K and showKF ? (media *scaleK1) + (fark * ni /scale) : show_K ? media *scaleK1: na, color=color.red, title="media", style=plot.style_line, linewidth=2) // COLOURED(255,0,0) as “media” , band0k = plot(show_K ? bandacero : na , color=color.black, title="cero") fill(lk2,band0k,color = show_K ? #66FF66 : na , title = "verde", transp = 50) fill(lk1,band0k,color = show_K ? #FFCC99 : na , title = "marron", transp = 50) fill(lk3,band0k,color = show_K ? #00FFFF : na , title = "azul", transp = 50) konBull = crossover(marron,media) and show_KD konBear = crossunder(marron,media) and show_KD konlBull=kon_pos * ni/scale konlBear=kon_posn * ni/scale plotchar(konBull ? konlBull : konBear ? konlBear : na, title = 'Koncorde diamond', char='◆', color = konBull ? color.lime : konBear ? color.maroon : color.white, location = location.absolute, size = size.tiny, transp = 0) //////////////////////////////////////// ////////////////////// END KONCORDE ///////////////////////////////// //////////////////////////////////////// ////////////////////// CCI ///////////////////////////////// show_cci = input(false, title="------------Show CCI---------") cci_len = input(14, "CCI length") cci_src = input(close, "CCI source") upperCCI = input(100, "CCI Upper band") lowerCCI = input(-100, "CCI lower band") b1cci = (upperCCI * ni/scale)*30/100 b0cci = (lowerCCI * ni/scale) *30/100 cci = cci(cci_src, cci_len) cci_scale = (30) * ((cci) * ni/scale) / 100 //cci_scale=((cci * ni/scale)/scale) *scale_cci //(cci / (ni * scale) ) + (50*ni/scale) //cci_color = c1 ? #F8B856 : c2 ? #F6AD3C : c3 ? #F5A21B : #F39800 plot(show_cci ? cci_scale : na, color=color.blue, transp=0, linewidth=2, title="CCI") //////////////////////////////////////// ////////////////////// END CCI ///////////////////////////////// /////////////////// //////// //////////////////// colorcm = show_cci ? color.blue : color.white band1 = plot(show_rsi? b1s : show_stoch? h1s : na,color=bar_index % 2 == 0 ? color.white : #00000000,transp=60) band0 = plot(show_rsi? b0s : show_stoch ? h0s: show_cci ? b0cci : na,color=bar_index % 2 == 0 ? color.white : #00000000,transp=60) bandm = plot(show_cci ? b1cci : show_rsi? bm : show_rsi2 ? (farRSI * ni/scale): na,color=bar_index % 2 == 0 ? colorcm : #00000000,transp=70) band00 = plot(show_cci? b0cci : na, color=bar_index % 2 == 0 ? color.blue : #00000000,transp=60) fill(band1,band0, color= show_rsi and show_RSIfondo? color.purple : na,transp=90,title="RSI background") ////////////// //////// /////////////////////\/ /////////////MFI i got the code fo=rom the CIPHER indicator by vumanchu ////////////////////// rsiMFIShow = input(true, title = '----------Show MFI---------', type = input.bool) rsiMFIperiod = input(60,title = 'MFI Period', type = input.integer) rsiMFIMultiplier = input(150, title = 'MFI Area multiplier', type = input.float) rsiMFIPosY = input(2.5, title = 'MFI Area Y Pos', type = input.float) // RSI+MFI f_rsimfi(_period, _multiplier, _tf) => security(syminfo.tickerid, _tf, sma(((close - open) / (high - low)) * _multiplier, _period) - rsiMFIPosY) rsiMFI = f_rsimfi(rsiMFIperiod, rsiMFIMultiplier, timeframe.period) rsiMFIColor1 = #ffffff rsiMFIColor2 = #d1d4dc rsiMFIColor = rsiMFI >= 0 ? rsiMFIColor1: rsiMFI < 0 ? rsiMFIColor2 : na rsiMFIplot = plot(rsiMFIShow ? rsiMFI * ni/scale: na, title = 'RSI+MFI Area', color =rsiMFIColor , transp = 80,style=plot.style_area) ///////////////////// ///////// ////////////////////// //WT the cipher dots use a indicator by lazy bear show_cphr = input(true,title = "------------Show Cipher dots---------") n1 = input(9, title = "Channel Length") n2 = input(12, title = "Average Length") smooth = input(3, title = "Smooth Factor") //wt CALC(n1, n2, smooth) => ap = hlc3 esa = ema(ap, n1) dw = ema(abs(ap - esa), n1) ci = (ap - esa) / (0.015 * dw) tci = ema(ci, n2) wt1 = tci wt2 = sma(wt1,smooth) wave = wt1 - wt2 wavecolor = wave >=0? color.lime : color.red [wave, wavecolor] //CIPHERR [wave, wavecolor] = CALC(n1, n2, smooth) middle = 0 condWt = cross(wave,middle) ? true : na wtjeje= show_Momen ? sz : show_ao ? ao : show_macd ? macd : na plot(condWt and show_cphr ? wtjeje : na, title = 'Buy and sell circle', color = wavecolor, style = plot.style_circles, linewidth = 3, transp = 15) /////plot ADX plot(show_aa ? far1 *scaleADX : na,color=color.white, title="Punto 23") p1 = plot(show_aa ? adx_scale2 * scaleADX : show_ADX ? adx_scale * scaleADX : na, color = color_ADX, title = "ADX", linewidth = 2) /// /////////////// // ESTADOOO show_status = input(true, title = "------Show STATUS----------") dist= input(10,title="Distancia del monitor") dashColor = input(color.new(#696969, 90), "label Color", inline="Dash Line") dashTextColor = input(color.new(#ffffff, 0), "Text Color", inline="Dash Line") if(adxValue > adxValue[1] and adxValue > 23) iadx='ADX con pendiente positiva por encima punto 23' if(adxValue > adxValue[1] and adxValue < 23) iadx='ADX con pendiente positiva por debajo punto 23' if(adxValue < adxValue[1] and adxValue < 23) iadx='ADX con pendiente negativa por debajo punto 23' if(adxValue < adxValue[1] and adxValue > 23) iadx='ADX con pendiente negativa por encima punto 23' a1=adxValue >= 23 a2=adxValue < 23 a3=adxValue >= adxValue[1] a4=adxValue < adxValue[1] iAdx = a1 and a3 ? 'Pendiente positiva ↑ 23' : a1 and a4 ? 'Pendiente negativa ↑ 23' : a2 and a4 ? 'Pendiente negativa ↓ 23' : a2 and a3 ? 'Pendiente positiva ↓ 23' : '-' iMom = sc1 and sc3 ? 'Direccionalidad alcista' : sc1 and sc4 ? 'Direccionalidad bajista' : sc2 and sc4 ? 'Direccionalidad bajista' : sc2 and sc3 ? 'Direccinalidad alcista' : '-' igral = a1 and a3 and sc1 and sc3 ? 'Fuerte movimiento alcista' : a1 and a3 and sc1 and sc4 ? 'Monitor muestra rango-caida pero\nel movimiento tiene fuerza': a1 and a3 and sc2 and sc4 ? 'Fuerte movimiento bajista' : a1 and a3 and sc2 and sc3 ? 'Monitor muestra rango-subida pero\nel movimiento tiene fuerza': a1 and a4 and sc1 and sc3 ? 'Movimiento alcista sin fuerza' : a1 and a4 and sc1 and sc4 ? 'Monitor muestra rango-caida\n pendiente negativa en ADX ': a1 and a4 and sc2 and sc4 ? 'Movimiento bajista sin fuerza' : a1 and a4 and sc2 and sc3 ? 'Monitor muestra rango-subida con \npendiente negativa en ADX ': a2 and a4 and sc1 and sc3 ? 'Movimiento alcista sin fuerza' : a2 and a4 and sc1 and sc4 ? 'Monitor muestra rango-caida sin fuerza ': a2 and a4 and sc2 and sc4 ? 'Movimiento bajista sin fuerza' : a2 and a4 and sc2 and sc3 ? 'Monitor muestra rango-subida sin fuerza ': a2 and a3 and sc1 and sc3 ? 'Movimiento alcista que \n quiere agarrar fuerza' : a2 and a3 and sc1 and sc4 ? 'Monitor muestra rango-caida,\n el movimiento quiere agarrar fuerza': a2 and a3 and sc2 and sc4 ? 'Movimiento bajista que \n quiere agarrar fuerza' : a2 and a3 and sc2 and sc3 ? 'Monitor muestra rango-subida,\n el movimiento quiere agarrar fuerza': '-' s='\n' scr_label='Info ADX: '+iAdx+s+'Info monitor: '+iMom+s+'Info general:'+s+igral // Plot Label on the chart // Plot Label on the chart if show_status lab_l = label.new( bar_index + dist, 0, '\t Estatus segun estrategia\n\t' + scr_label, color = dashColor, textcolor = dashTextColor, style = label.style_label_left, yloc = yloc.price) label.delete(lab_l[1]) // Send alert only if screener is not empty if (scr_label != '') alert('Estatus segun estrategia\n' + scr_label, freq = alert.freq_once_per_bar_close ) ////////////////////////////////// //DIVERGENCIAS BUENNNNNNNAS show_div=input(true,title="------Divergencias--------") lbR = input(title="Pivot Lookback Right", defval=1) lbL = input(title="Pivot Lookback Left", defval=1) rangeUpper = input(title="Max of Lookback Range", defval=60) rangeLower = input(title="Min of Lookback Range", defval=1) plotBull = input(title="Plot Bullish", defval=true) plotHiddenBull = input(title="Plot Hidden Bullish", defval=true) plotBear = input(title="Plot Bearish", defval=true) plotHiddenBear = input(title="Plot Hidden Bearish", defval=true) bearColor = #ff0000 bullColor = #1bff00 hiddenBullColor = #a4ff99 hiddenBearColor = #ff9e9e textColor = color.white noneColor = color.new(color.white, 100) //FUNCTIONS plFound(osc) => na(pivotlow(osc, lbL, lbR)) ? false : true phFound(osc) => na(pivothigh(osc, lbL, lbR)) ? false : true _inRange(cond) => bars = barssince(cond == true) rangeLower <= bars and bars <= rangeUpper _findDivRB(osc)=> // Osc: Higher Low oscHL = osc[lbR] > valuewhen(plFound(osc), osc[lbR], 1) and _inRange(plFound(osc)[1]) // Price: Lower Low priceLL = low[lbR] < valuewhen(plFound(osc), low[lbR], 1) bullCond = plotBull and priceLL and oscHL and plFound(osc) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL = osc[lbR] < valuewhen(plFound(osc), osc[lbR], 1) and _inRange(plFound(osc)[1]) // Price: Higher Low priceHL = low[lbR] > valuewhen(plFound(osc), low[lbR], 1) hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound(osc) //------------------------------------------------------------------------------ // Regular Bearish // Osc: Lower High oscLH = osc[lbR] < valuewhen(phFound(osc), osc[lbR], 1) and _inRange(phFound(osc)[1]) // Price: Higher High priceHH = high[lbR] > valuewhen(phFound(osc), high[lbR], 1) bearCond = plotBear and priceHH and oscLH and phFound(osc) //------------------------------------------------------------------------------ // Hidden Bearish // Osc: Higher High oscHH = osc[lbR] > valuewhen(phFound(osc), osc[lbR], 1) and _inRange(phFound(osc)[1]) // Price: Lower High priceLH = high[lbR] < valuewhen(phFound(osc), high[lbR], 1) hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound(osc) [bullCond,hiddenBullCond,bearCond,hiddenBearCond] [sz_bullCond,sz_hiddenBullCond,sz_bearCond,sz_hiddenBearCond]=_findDivRB(sz) foundDivBSZ = plFound(sz) and show_Momen and show_div ? true : false colordivBSZ = sz_bullCond ? bullColor : sz_hiddenBullCond ? hiddenBullColor : noneColor foundDivBeSZ = phFound(sz) and show_Momen and show_div ? true : false colordivBeSZ = sz_bearCond ? bearColor : sz_hiddenBearCond ? hiddenBearColor : noneColor plot( foundDivBSZ ? sz[lbR] : na, offset=-lbR, title="Regular Bullish", linewidth=1, color=colordivBSZ, transp=0 ) plot( foundDivBeSZ ? sz[lbR] : na, offset=-lbR, title="Regular Bullish", linewidth=1, color=colordivBeSZ, transp=0 ) ////////////////////RSI DIV////////////////// [rsi_bullCond,rsi_hiddenBullCond,rsi_bearCond,rsi_hiddenBearCond]=_findDivRB(rsi_scale) foundDivBRSI = plFound(rsi_scale) and show_rsi and show_div ? true : false colordivBRSI = rsi_bullCond ? bullColor : rsi_hiddenBullCond ? hiddenBullColor : noneColor foundDivBeRSI = phFound(rsi_scale) and show_rsi and show_div ? true : false colordivBeRSI = rsi_bearCond ? bearColor : rsi_hiddenBearCond ? hiddenBearColor : noneColor plot( foundDivBRSI ? rsi_scale[lbR] : na, offset=-lbR, title="Regular Bullish", linewidth=1, color=colordivBRSI, transp=0 ) plot( foundDivBeRSI ? rsi_scale[lbR] : na, offset=-lbR, title="Regular Bullish", linewidth=1, color=colordivBeRSI, transp=0 )
[LanZhu] - Bursa Index/Sector Trend With Portfolio
https://www.tradingview.com/script/9KDq5n4D-LanZhu-Bursa-Index-Sector-Trend-With-Portfolio/
Lanzhu0506
https://www.tradingview.com/u/Lanzhu0506/
36
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Lanzhu0506 // This indicator has included some codes from other author's indicator as below // Portfolio Tracker [Anan] from Mohamed3nan //@version=5 indicator('[LanZhu] - Bursa Index/Sector Trend With Portfolio') import Lanzhu0506/Bursa_Sector/13 as bursa /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /// Input & Setting /// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// // ===================== // ===Trend Indicator=== // ===================== trendIndicatorGroup = '===Index & Sector Trend===' sym = input.string(title = "Index Type", defval = "Sector", options=['Main Index', 'Sector'], group = trendIndicatorGroup) trendRes = input.timeframe(title = 'Trend Timeframe', defval = 'D', group = trendIndicatorGroup) mainIndexUpColor = input.color(title = "Main Index Uptrend Color", defval = color.new(color.blue, 50), inline='main', group = trendIndicatorGroup) mainIndexDownColor = input.color(title = "Main Index Downtrend Color", defval = color.new(color.red, 50), inline='main', group = trendIndicatorGroup) sectorUpColor = input.color(title = "Sector Uptrend Color", defval = color.new(color.lime, 50), inline='sector', group = trendIndicatorGroup) sectorDownColor = input.color(title = "Sector Downtrend Color", defval = color.new(color.purple, 50), inline='sector', group = trendIndicatorGroup) // =============== // ===Portfolio=== // =============== portfolioWatchlistGroup = '===Portfolio===' use1 = input.bool(true, '', inline='1', group=portfolioWatchlistGroup) sym1 = input.symbol('FBMKLCI', '', inline='1', group=portfolioWatchlistGroup) price1 = input.float(1, 'Price', inline='1', group=portfolioWatchlistGroup) qty1 = input.int(1, 'QTY', inline='1', group=portfolioWatchlistGroup) use2 = input.bool(false, '', inline='2', group=portfolioWatchlistGroup) sym2 = input.symbol('', '', inline='2', group=portfolioWatchlistGroup) price2 = input.float(0, 'Price', inline='2', group=portfolioWatchlistGroup) qty2 = input.int(0, 'QTY', inline='2', group=portfolioWatchlistGroup) use3 = input.bool(false, '', inline='3', group=portfolioWatchlistGroup) sym3 = input.symbol('', '', inline='3', group=portfolioWatchlistGroup) price3 = input.float(0, 'Price', inline='3', group=portfolioWatchlistGroup) qty3 = input.int(0, 'QTY', inline='3', group=portfolioWatchlistGroup) use4 = input.bool(false, '', inline='4', group=portfolioWatchlistGroup) sym4 = input.symbol('', '', inline='4', group=portfolioWatchlistGroup) price4 = input.float(0, 'Price', inline='4', group=portfolioWatchlistGroup) qty4 = input.int(0, 'QTY', inline='4', group=portfolioWatchlistGroup) use5 = input.bool(false, '', inline='5', group=portfolioWatchlistGroup) sym5 = input.symbol('', '', inline='5', group=portfolioWatchlistGroup) price5 = input.float(0, 'Price', inline='5', group=portfolioWatchlistGroup) qty5 = input.int(0, 'QTY', inline='5', group=portfolioWatchlistGroup) tableYpos = input.string('middle', '↕', inline='01', group=portfolioWatchlistGroup, options=['top', 'middle', 'bottom']) tableXpos = input.string('right', '↔', inline='01', group=portfolioWatchlistGroup, options=['left', 'center', 'right'], tooltip='Position on the chart.') tableRowHeight = input.int(0, '|', inline='02', group=portfolioWatchlistGroup, minval=0, maxval=100) tableColWidth = input.int(0, '—', inline='02', group=portfolioWatchlistGroup, minval=0, maxval=100, tooltip='0-100. Use 0 to auto-size height and width.') textSize_ = input.string('Small', 'Table Text Size', options=['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], group=portfolioWatchlistGroup) textSize = textSize_ == 'Auto' ? size.auto : textSize_ == 'Tiny' ? size.tiny : textSize_ == 'Small' ? size.small : textSize_ == 'Normal' ? size.normal : textSize_ == 'Large' ? size.large : size.huge row_col = input.color(color.blue, 'Headers', inline='03', group=portfolioWatchlistGroup) col_col = input.color(color.blue, ' ', inline='03', group=portfolioWatchlistGroup) poscol = input.color(color.green, 'Profit/Loss', inline='04', group=portfolioWatchlistGroup) neutralcolor = input.color(color.gray, '', inline='04', group=portfolioWatchlistGroup) negcol = input.color(color.red, '', inline='04', group=portfolioWatchlistGroup) /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /// Calculation & Plotting & Alert /// ////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // ===================== // ===Trend Indicator=== // ===================== string sector = bursa.getSector() float currentClose = 0 float pastClose = 0 transportCurrentClose = request.security('MYX:TRANSPORTATION', trendRes, close) transportPastClose = request.security('MYX:TRANSPORTATION', trendRes, close[1]) reitCurrentClose = request.security('MYX:REIT', trendRes, close) reitPastClose = request.security('MYX:REIT', trendRes, close[1]) utilityCurrentClose = request.security('MYX:UTILITIES', trendRes, close) utilityPastClose = request.security('MYX:UTILITIES', trendRes, close[1]) telcoCurrentClose = request.security('MYX:TELECOMMUNICATIONS', trendRes, close) telcoPastClose = request.security('MYX:TELECOMMUNICATIONS', trendRes, close[1]) healthCurrentClose = request.security('MYX:HEALTH', trendRes, close) healthPastClose = request.security('MYX:HEALTH', trendRes, close[1]) plantationCurrentClose = request.security('MYX:PLANTATION', trendRes, close) plantationPastClose = request.security('MYX:PLANTATION', trendRes, close[1]) propertyCurrentClose = request.security('MYX:PROPERTIES', trendRes, close) propertyPastClose = request.security('MYX:PROPERTIES', trendRes, close[1]) financeCurrentClose = request.security('MYX:FINANCE', trendRes, close) financePastClose = request.security('MYX:FINANCE', trendRes, close[1]) technologyCurrentClose = request.security('MYX:TECHNOLOGY', trendRes, close) technologyPastClose = request.security('MYX:TECHNOLOGY', trendRes, close[1]) industryCurrentClose = request.security('MYX:IND-PROD', trendRes, close) industryPastClose = request.security('MYX:IND-PROD', trendRes, close[1]) consumerCurrentClose = request.security('MYX:CONSUMER', trendRes, close) consumerPastClose = request.security('MYX:CONSUMER', trendRes, close[1]) constructionCurrentClose = request.security('MYX:CONSTRUCTN', trendRes, close) constructionPastClose = request.security('MYX:CONSTRUCTN', trendRes, close[1]) energyCurrentClose = request.security('MYX:ENERGY', trendRes, close) energyPastClose = request.security('MYX:ENERGY', trendRes, close[1]) klciCurrentClose = request.security('FBMKLCI', trendRes, close) klciPastClose = request.security('FBMKLCI', trendRes, close[1]) if sector == 'MYX:TRANSPORTATION' currentClose := transportCurrentClose pastClose := transportPastClose else if sector == 'MYX:REIT' currentClose := reitCurrentClose pastClose := reitPastClose else if sector == 'MYX:UTILITIES' currentClose := utilityCurrentClose pastClose := utilityPastClose else if sector == 'MYX:TELECOMMUNICATIONS' currentClose := telcoCurrentClose pastClose := telcoPastClose else if sector == 'MYX:HEALTH' currentClose := healthCurrentClose pastClose := healthPastClose else if sector == 'MYX:PLANTATION' currentClose := plantationCurrentClose pastClose := plantationPastClose else if sector == 'MYX:PROPERTIES' currentClose := propertyCurrentClose pastClose := propertyPastClose else if sector == 'MYX:FINANCE' currentClose := financeCurrentClose pastClose := financePastClose else if sector == 'MYX:TECHNOLOGY' currentClose := technologyCurrentClose pastClose := technologyPastClose else if sector == 'MYX:IND-PROD' currentClose := industryCurrentClose pastClose := industryPastClose else if sector == 'MYX:CONSUMER' currentClose := consumerCurrentClose pastClose := consumerPastClose else if sector == 'MYX:CONSTRUCTN' currentClose := constructionCurrentClose pastClose := constructionPastClose else if sector == 'MYX:ENERGY' currentClose := energyCurrentClose pastClose := energyPastClose upTrend = currentClose >= pastClose downTrend = currentClose <= pastClose klciUpTrend = klciCurrentClose >= klciPastClose klciDownTrend = klciCurrentClose <= klciPastClose plotshape(upTrend, 'Up Trend', style=shape.square, location=location.bottom, color=color.new(color.lime, 50), size=size.small) plotshape(downTrend, 'Down Trend', style=shape.square, location=location.bottom, color=color.new(color.purple, 50), size=size.small) plotshape(klciUpTrend, 'KLCI Up Trend', style=shape.square, location=location.top, color=color.new(color.blue, 50), size=size.small) plotshape(klciDownTrend, 'KLCI Down Trend', style=shape.square, location=location.top, color=color.new(color.red, 50), size=size.small) var table sectorTable = table.new(position.middle_left, 5, 1, border_width=1) table.cell(sectorTable, 0, 0, text='MYX:FBMKLCI', width=10, bgcolor=color.new(color.gray,50), text_size=size.small, text_color=color.white) table.cell(sectorTable, 1, 0, text=str.tostring(klciCurrentClose), width=10, bgcolor=color.new(klciUpTrend ? mainIndexUpColor : mainIndexDownColor, 50), text_size=size.small, text_color=color.white) table.cell(sectorTable, 2, 0, text="", width=2, bgcolor=color.new(color.white, 50)) table.cell(sectorTable, 3, 0, text=sector, width=10, bgcolor=color.new(color.gray,50), text_size=size.small, text_color=color.white) table.cell(sectorTable, 4, 0, text=str.tostring(currentClose), width=10, bgcolor=color.new(upTrend ? sectorUpColor : sectorDownColor, 50), text_size=size.small, text_color=color.white) // =============== // ===Portfolio=== // =============== var table anan = table.new(tableYpos + '_' + tableXpos, 8, 11, border_width=2) table.cell(anan, 0, 0, "Asset" , text_color = col_col, bgcolor = color.new(col_col, 80), text_size = textSize, width= tableColWidth, height= tableRowHeight) table.cell(anan, 1, 0, "Current Price" , text_color = col_col, bgcolor = color.new(col_col, 80), text_size = textSize, width= tableColWidth, height= tableRowHeight) table.cell(anan, 2, 0, "Cost Value" , text_color = col_col, bgcolor = color.new(col_col, 80), text_size = textSize, width= tableColWidth, height= tableRowHeight) table.cell(anan, 3, 0, "Holdings" , text_color = col_col, bgcolor = color.new(col_col, 80), text_size = textSize, width= tableColWidth, height= tableRowHeight) table.cell(anan, 4, 0, "Current Value" , text_color = col_col, bgcolor = color.new(col_col, 80), text_size = textSize, width= tableColWidth, height= tableRowHeight) table.cell(anan, 5, 0, "Avg. Price" , text_color = col_col, bgcolor = color.new(col_col, 80), text_size = textSize, width= tableColWidth, height= tableRowHeight) table.cell(anan, 6, 0, "P/L" , text_color = col_col, bgcolor = color.new(col_col, 80), text_size = textSize, width= tableColWidth, height= tableRowHeight) table.cell(anan, 7, 0, "P/L %" , text_color = col_col, bgcolor = color.new(col_col, 80), text_size = textSize, width= tableColWidth, height= tableRowHeight) getCurPrice(sym) => request.security(sym, '12M', close) getROC(sym) => request.security(sym, '1D', ta.roc(close, 1)) curPrice1 = getCurPrice(sym1) curPrice2 = getCurPrice(sym2) curPrice3 = getCurPrice(sym3) curPrice4 = getCurPrice(sym4) curPrice5 = getCurPrice(sym5) renderTable(cell, use, sym, qty, price) => curPrice = switch cell 1 => curPrice1 2 => curPrice2 3 => curPrice3 4 => curPrice4 5 => curPrice5 roc = getROC(sym) if use table.cell(anan, 0, cell, sym, text_color=row_col, bgcolor =color.new(row_col, 80) , text_size =textSize, width=tableColWidth, height=tableRowHeight) table.cell(anan, 1, cell, str.tostring(curPrice)+" ("+str.tostring(roc,"#.##") + "%)", text_color = roc>0 ? poscol : roc<0 ? negcol : neutralcolor , bgcolor = color.new(roc>0 ? poscol : roc<0 ? negcol : neutralcolor , 80), text_size=textSize, width=tableColWidth, height=tableRowHeight) table.cell(anan, 2, cell, str.tostring(price*qty), text_color =(curPrice*qty)>(price*qty) ? poscol : (curPrice*qty)<(price*qty) ? negcol : neutralcolor , bgcolor = color.new((curPrice*qty)>(price*qty) ? poscol : (curPrice*qty)<(price*qty) ? negcol : neutralcolor , 80), text_size=textSize, width=tableColWidth, height=tableRowHeight) table.cell(anan, 3, cell, str.tostring(qty), text_color=poscol , bgcolor = color.new(poscol , 80), text_size=textSize, width=tableColWidth, height=tableRowHeight) table.cell(anan, 4, cell, str.tostring(curPrice*qty), text_color =(curPrice*qty)>(price*qty) ? poscol : (curPrice*qty)<(price*qty) ? negcol : neutralcolor , bgcolor = color.new((curPrice*qty)>(price*qty) ? poscol : (curPrice*qty)<(price*qty) ? negcol : neutralcolor , 80), text_size=textSize, width=tableColWidth, height=tableRowHeight) table.cell(anan, 5, cell, str.tostring(price), text_color =curPrice>price ? poscol : curPrice<price ? negcol : neutralcolor , bgcolor = color.new(curPrice>price ? poscol : curPrice<price ? negcol : neutralcolor , 80), text_size=textSize, width=tableColWidth, height=tableRowHeight) table.cell(anan, 6, cell, str.tostring((curPrice*qty)-(price*qty)), text_color =(curPrice*qty)-(price*qty)>0 ? poscol : ((curPrice*qty)-(price*qty))<0 ? negcol : neutralcolor , bgcolor = color.new((curPrice*qty)-(price*qty)>0 ? poscol : ((curPrice*qty)-(price*qty))<0 ? negcol : neutralcolor , 80), text_size=textSize, width=tableColWidth, height=tableRowHeight) table.cell(anan, 7, cell, str.tostring(((curPrice*qty)-(price*qty))/(price*qty)*100,"#.##")+ "%",text_color =(curPrice*qty)-(price*qty)>0 ? poscol : ((curPrice*qty)-(price*qty))<0 ? negcol : neutralcolor , bgcolor = color.new((curPrice*qty)-(price*qty)>0 ? poscol : ((curPrice*qty)-(price*qty))<0 ? negcol : neutralcolor , 80), text_size=textSize, width=tableColWidth, height=tableRowHeight) renderTable(1 , use1, sym1, qty1, price1) renderTable(2 , use2, sym2, qty2, price2) renderTable(3 , use3, sym3, qty3, price3) renderTable(4 , use4, sym4, qty4, price4) renderTable(5 , use5, sym5, qty5, price5) float totalCost = 0 float totalCurrentValue = 0 if use1 totalCost := totalCost + (price1 * qty1) totalCurrentValue := totalCurrentValue + (curPrice1*qty1) if use2 totalCost := totalCost + (price2 * qty2) totalCurrentValue := totalCurrentValue + (curPrice2*qty2) if use3 totalCost := totalCost + (price3 * qty3) totalCurrentValue := totalCurrentValue + (curPrice3*qty3) if use4 totalCost := totalCost + (price4 * qty4) totalCurrentValue := totalCurrentValue + (curPrice4*qty4) if use5 totalCost := totalCost + (price5* qty5) totalCurrentValue := totalCurrentValue + (curPrice5*qty5) table.cell(anan, 0, 6, "Total", text_color = color.new(color.orange, 0), bgcolor=color.new(color.orange, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight) table.cell(anan, 1, 6, "", text_color = color.new(color.orange, 0), bgcolor=color.new(color.orange, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight) table.cell(anan, 2, 6, str.tostring(totalCost), text_color = color.new(color.orange, 0), bgcolor=color.new(color.orange, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight) table.cell(anan, 3, 6, "", text_color = color.new(color.orange, 0), bgcolor=color.new(color.orange, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight) table.cell(anan, 4, 6, str.tostring(totalCurrentValue), text_color = color.new(color.orange, 0), bgcolor=color.new(color.orange, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight) table.cell(anan, 5, 6, "", text_color = color.new(color.orange, 0), bgcolor=color.new(color.orange, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight) table.cell(anan, 6, 6, str.tostring(totalCurrentValue - totalCost), text_color = color.new(color.orange, 0), bgcolor=color.new(color.orange, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight) table.cell(anan, 7, 6, str.tostring(((totalCurrentValue - totalCost) / totalCost) * 100, "#.##")+ "%", text_color = color.new(color.orange, 0), bgcolor=color.new(color.orange, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
RSI 30 CROSS
https://www.tradingview.com/script/BAjepctO-RSI-30-CROSS/
thambumalvino87
https://www.tradingview.com/u/thambumalvino87/
38
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © thambumalvino87 //@version=4 study(title="RSI 30 CROSS", shorttitle="RSI,30,10", format=format.price, precision=2, resolution="",overlay=true) //study(title="Rsi 30 cross", shorttitle="rsi 30,10", overlay=true, resolution="") len = input(10, minval=1, title="Length") src = input(close, "Source", type = input.source) up = rma(max(change(src), 0), len) down = rma(-min(change(src), 0), len) offset = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500) //plot(up, color=color.blue, title="Entry", offset=offset) //plot(down, color=color.green, title="Target", offset=offset) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) chdown = 0.000 chup = 0.000 chdownf = 0.000 chupf = 0.000 chdowns = 0.000 chups = 0.000 if rsi > 30 chdown := chdown+ (up *(len-1)/0.428)-(down * (len-1)) else chup := chup+ (0.428*(down*(len-1)))-(up * (len-1)) x = close -chdown +chup if rsi > 40 chdownf := chdownf + (up *(len-1)/0.6666)-(down * (len-1)) else chupf := chupf + (0.6666*(down*(len-1)))-(up * (len-1)) xf = close -chdownf +chupf if rsi > 70 chdowns := chdowns + (up *(len-1)/2.33333)-(down * (len-1)) else chups := chups + (2.33333*(down*(len-1)))-(up * (len-1)) xs = close -chdowns +chups plot(x, color=color.red, title="Stop loss", offset=offset) plot(xf, color=color.blue, title="Stop loss", offset=offset) plot(xs, color=color.green, title="Stop loss", offset=offset) len1 = input(200, minval=1, title="Length") src1 = input(close, title="Source") out = sma(src1, len1) plot(out, color=color.black, title="MA", offset=offset) pivot = (high + low + close) / 3.0 BC = (high + low) / 2 //Below Central povit TC = (pivot - BC) + pivot //Top Central povot bc = (high + low) / 2.0 tc = (pivot - bc) + pivot R1 = (2*pivot) - low S1 = (2*pivot) - high R2 = pivot + ( high - low) S2 = pivot - ( high - low) sw = input(false, title="Show Weekly Pivots?") wtime_pvt = security(syminfo.tickerid, 'W', pivot[1], lookahead=barmerge.lookahead_on) wtime_R1 = security(syminfo.tickerid, 'W', R1[1], lookahead=barmerge.lookahead_on) wtime_S1 = security(syminfo.tickerid, 'W', S1[1], lookahead=barmerge.lookahead_on) plot(sw and wtime_pvt ? wtime_pvt : na, title="Weekly pvt",style= plot.style_line, color=color.fuchsia,linewidth=1) plot(sw and wtime_R1 ? wtime_R1 : na, title="Weekly R1",style= plot.style_line, color=color.fuchsia,linewidth=1) plot(sw and wtime_S1 ? wtime_S1 : na, title="Weekly S1",style=plot.style_line, color=color.fuchsia,linewidth=1) sm = input(false, title="Show Monthly Pivots?") mtime_pvt = security(syminfo.tickerid, 'M', pivot[1], lookahead=barmerge.lookahead_on) mtime_R1 = security(syminfo.tickerid, 'M', R1[1], lookahead=barmerge.lookahead_on) mtime_S1 = security(syminfo.tickerid, 'M', S1[1], lookahead=barmerge.lookahead_on) plot(sm and mtime_pvt ? mtime_pvt : na, title="Monthly pvt",style=plot.style_circles, color=color.lime,linewidth=2) plot(sm and mtime_R1 ? mtime_R1 : na, title="Monthly R1",style=plot.style_circles, color=color.lime,linewidth=2) plot(sm and mtime_S1 ? mtime_S1 : na, title="Monthly S1",style=plot.style_circles, color=color.lime,linewidth=2)
Volume Bias
https://www.tradingview.com/script/4CzPUuW8-Volume-Bias/
UnknownUnicorn11161970
https://www.tradingview.com/u/UnknownUnicorn11161970/
44
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © FlynnTheAlmighty //@version=5 var int MAX_BARS_BACK = 500 indicator("[FTA] Volume bias", max_bars_back = MAX_BARS_BACK) int lookBackInput = input.int(20, "Volume Look Back (bars)", minval = 2, maxval = int(MAX_BARS_BACK / 4)) // Stop the script if the chart does not contain volume data. bool noVol = na(volume) and nz(math.sum(nz(volume), 200) == 0, true) if noVol runtime.error("No volume data.") volumeBias(lookBack, maxLookBack) => bool barUp = ta.rising(close, 1) bool barDn = ta.falling(close, 1) float upVolume = 0. float dnVolume = 0. float avgVolume = math.sum(nz(volume), lookBack) int[] upBarNos = array.new_int(0) int[] dnBarNos = array.new_int(0) int bar = 1 bool volumeFound = false while (not volumeFound) and bar < maxLookBack if barUp[bar] and upVolume < avgVolume upVolume += nz(volume[bar]) array.push(upBarNos, bar) else if barDn[bar] and dnVolume < avgVolume dnVolume += nz(volume[bar]) array.push(dnBarNos, bar) bar += 1 volumeFound := upVolume >= avgVolume and dnVolume >= avgVolume float volumeBias = bar >= maxLookBack ? na : array.avg(dnBarNos) - array.avg(upBarNos) float bias = volumeBias(lookBackInput, MAX_BARS_BACK) plot(bias, "Volume Bias", bias > 0 ? color.aqua : color.fuchsia) hline(0)
Crypto Scannner for Traffic Lights Strategy
https://www.tradingview.com/script/gX5q8tBk-Crypto-Scannner-for-Traffic-Lights-Strategy/
Trading_Solutions_
https://www.tradingview.com/u/Trading_Solutions_/
174
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © maxits //@version=4 study("Crypto Scannner", overlay=false) offset = input(defval=20, title="Number of Bars offset", type=input.integer) TL() => fema = ema(close, 8) mema = ema(close, 14) sema = ema(close, 16) filter = ema(close, 600) goLong = fema > mema and mema > sema and fema > filter goShort = fema < mema and mema < sema and fema < filter position = goLong or goShort s1 = security("BINANCE:BTCUSDT", "240", TL()) s2 = security("BINANCE:ETHUSDT", "240", TL()) s3 = security("BINANCE:BNBUSDT", "240", TL()) s4 = security("BINANCE:ADAUSDT", "240", TL()) s5 = security("BINANCE:LTCUSDT", "240", TL()) s6 = security("BINANCE:BCHUSDT", "240", TL()) s7 = security("BINANCE:LINKUSDT", "240", TL()) s8 = security("BINANCE:SOLUSDT", "240", TL()) s9 = security("BINANCE:AVAXUSDT", "240", TL()) s10 = security("BINANCE:LUNAUSDT", "240", TL()) s11 = security("BINANCE:ALGOUSDT", "240", TL()) scr_label = "Screener: Traffic Lights" + "\n4H Chart" + "\nLong + Short Conditions" + "\n======================" scr_label := s1 ? scr_label + "\nBTCUSDT" : scr_label scr_label := s2 ? scr_label + "\nETHUSDT" : scr_label scr_label := s3 ? scr_label + "\nBNBUSDT" : scr_label scr_label := s4 ? scr_label + "\nADAUSDT" : scr_label scr_label := s5 ? scr_label + "\nLTCUSDT" : scr_label scr_label := s6 ? scr_label + "\nBCHUSDT" : scr_label scr_label := s7 ? scr_label + "\nLINKUSDT" : scr_label scr_label := s8 ? scr_label + "\nSOLUSDT" : scr_label scr_label := s9 ? scr_label + "\nAVAXUSDT" : scr_label scr_label := s10 ? scr_label + "\nLUNAUSDT" : scr_label scr_label := s11 ? scr_label + "\nALGOSDT" : scr_label a_label = label.new(bar_index - offset, 0, scr_label, color=color.new(color.red, 0), textcolor=color.new(color.white, 0)) label.delete(a_label[1]) TLchange() => fema = ema(close, 8) mema = ema(close, 14) sema = ema(close, 16) filter = ema(close, 600) goLong = fema > mema and mema > sema and fema > filter goShort = fema < mema and mema < sema and fema < filter position = goLong or goShort change = position[1] != position or position[2] != position or position[3] != position or position[4] != position or position[5] != position or position[6] != position c_s1 = security("BINANCE:BTCUSDT", "240", TLchange()) c_s2 = security("BINANCE:ETHUSDT", "240", TLchange()) c_s3 = security("BINANCE:BNBUSDT", "240", TLchange()) c_s4 = security("BINANCE:ADAUSDT", "240", TLchange()) c_s5 = security("BINANCE:LTCUSDT", "240", TLchange()) c_s6 = security("BINANCE:BCHUSDT", "240", TLchange()) c_s7 = security("BINANCE:LINKUSDT", "240", TLchange()) c_s8 = security("BINANCE:SOLUSDT", "240", TLchange()) c_s9 = security("BINANCE:AVAXUSDT", "240", TLchange()) c_s10 = security("BINANCE:LUNAUSDT", "240", TLchange()) c_s11 = security("BINANCE:ALGOUSDT", "240", TLchange()) c_scr_label = "Screener: Traffic Lights (Change)" + "\n4H Chart" + "\nLong + Short Conditions" + "\n==========================" c_scr_label := c_s1 ? c_scr_label + "\nBTCUSDT" : c_scr_label c_scr_label := c_s2 ? c_scr_label + "\nETHUSDT" : c_scr_label c_scr_label := c_s3 ? c_scr_label + "\nBNBUSDT" : c_scr_label c_scr_label := c_s4 ? c_scr_label + "\nADAUSDT" : c_scr_label c_scr_label := c_s5 ? c_scr_label + "\nLTCUSDT" : c_scr_label c_scr_label := c_s6 ? c_scr_label + "\nBCHUSDT" : c_scr_label c_scr_label := c_s7 ? c_scr_label + "\nLINKUSDT" : c_scr_label c_scr_label := c_s8 ? c_scr_label + "\nSOLUSDT" : c_scr_label c_scr_label := c_s9 ? c_scr_label + "\nAVAXUSDT" : c_scr_label c_scr_label := c_s10 ? c_scr_label + "\nLUNAUSDT" : c_scr_label c_scr_label := c_s11 ? c_scr_label + "\nALGOSDT" : c_scr_label c_label = label.new(bar_index, 0, c_scr_label, color=color.new(color.lime, 0), textcolor=color.new(color.white, 0)) label.delete(c_label[1])
Market Profile with TPO
https://www.tradingview.com/script/QhFOnhVk-Market-Profile-with-TPO/
drother
https://www.tradingview.com/u/drother/
5,776
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © drother //@version=5 indicator("Market Profile with TPO", overlay=true, max_labels_count = 500, max_boxes_count = 500, max_lines_count = 500, max_bars_back = 1000) auto_tick_size_b = input.bool(true, title="Auto Tick Size?", group="Tick Size") int tick_bars_back = input.int(48 , minval=1, title="Avg Tick Size - Bars Back", group="Tick Size") target_session_ht = input.float(5, minval=1, title="Average Target Session Height for Tick Size", group="Tick Size") man_tick_size = input.int(100 , minval=1, title="Manual Tick Size", group="Tick Size") value_area_pct = input.float(68.26 , minval=0.01, maxval=100, title="Value Area Percent", group="Market Profile Options", tooltip = "Values are typically 68.26 to 70")/100 open_color = input.color(title="Open TPO Text Color", defval=color.orange, group="Market Profile Options") POC_tpo_color = input.color(title="POC TPO Text Color", defval=color.red, group="Market Profile Options") POC_box_color = input.color(title="POC Box Color", defval=color.red, group="Market Profile Options") POC_line_color = input.color(title="POC Line Color", defval=color.red, group="Market Profile Options") in_value_tpo_color = input.color(title="In Value TPO Text Color", defval=color.blue, group="Market Profile Options") in_value_box_color = input.color(title="In Value Box Color", defval=color.blue, group="Market Profile Options") in_value_line_color = input.color(title="In Value Line Color", defval=color.blue, group="Market Profile Options") in_value_box_transparency = input.int(title="In Value Box Transparency", defval=70,minval=0,maxval=100, group="Market Profile Options") out_of_value_tpo_color = input.color(title="Out Of Value TPO Text Color", defval=color.green, group="Market Profile Options") //poc_box_color = input.color(title="POC Box Color", defval=color.red, group="Market Profile Options") //POC_box_transparency = input.int(title="POC Box Transparency", defval=30,minval=0,maxval=100, group="Market Profile Options") out_of_value_box_color = input.color(title="Out Of Value Box Color", defval=color.green, group="Market Profile Options") out_of_value_box_transparency = input.int(title="Out of Value Box Transparency", defval=70,minval=0,maxval=100, group="Market Profile Options") TPO_txt_size = input.string(title="TPO Letter Size", defval=size.small, options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge], group="Market Profile Options") curr_price_text = input.string(" 🔴", title="Current Price Text", group="Market Profile Options") tpo_letter_space = input.string(" ", "TPO Spacer to center over Candle", group="Market Profile Options") show_tpo_info = input.bool(title="Show TPO Info Text?", defval=true, group="Market Profile Options") info_table_txt_size = input.string(title="TPO Info Text Size", defval=size.small, options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge], group="Market Profile Options") info_table_text_color = input.color(title="Info Box Letter Color", defval=color.white, group="Market Profile Options") info_table_color = input.color(title="Info Box Background Color", defval=color.gray, group="Market Profile Options") plot_TPO_letters = input.bool(group="Market Profile Options",defval=true, title="Plot TPO Letters?") session_option_24hr = input.bool(group="Market Session", defval=true, title="Use 24hr Session? Overwrites all below settings", tooltip = "Forced to True for CFDs/Stocks") sessDays = input.string(group="Market Session", defval="1234567", title="Session Days of Week", tooltip = "1 = Sunday, 7 = Saturday") show_sess1 = input.bool(group="Market Session",defval=true, title="Show Session 1?") sess1Name = input.string(group="Market Session", defval="Asian", title="Session 1 Name") sess1Time = input.session(group="Market Session", defval="0000-0759", title="Session 1", tooltip = "Times are GMT") show_sess2 = input.bool(group="Market Session",defval=true, title="Show Session 2?") sess2Name = input.string(group="Market Session", defval="London", title="Session 1 Name") sess2Time = input.session(group="Market Session", defval="0800-1329", title="Session 2", tooltip = "Times are GMT") show_sess3 = input.bool(group="Market Session",defval=true, title="Show Session 3?") sess3Name = input.string(group="Market Session", defval="US", title="Session 1 Name") sess3Time = input.session(group="Market Session", defval="1330-1959", title="Session 3", tooltip = "Times are GMT") show_sess4 = input.bool(group="Market Session",defval=true, title="Show Session 4?") sess4Name = input.string(group="Market Session", defval="Pre Market", title="Session 1 Name") sess4Time = input.session(group="Market Session", defval="2000-0000", title="Session 4", tooltip = "Times are GMT") show_warning = input.bool(true, title="Show Tick Warning?", group="Debug") //show_warning = false //debug_option = input.bool(false, title="Debug?", group="Debug") //deb_txt_size = input.string(title="Debug Letter Size", defval=size.small, options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge], group="Debug") debug_option = false deb_txt_size = size.small bool is_in_session = false int sess_start = bar_index int which_sess = 0 if tick_bars_back > (bar_index + 1) tick_bars_back := bar_index + 1 tz = if syminfo.type == "stock" session_option_24hr := true "Etc/UTC" else if syminfo.type == "futures" "Etc/UTC" else if syminfo.type == "index" "Etc/UTC" else if syminfo.type == "forex" "Etc/UTC" else if syminfo.type == "crypto" "Etc/UTC" else if syminfo.type == "fund" "Etc/UTC" else if syminfo.type == "dr" "Etc/UTC" else if syminfo.type == "economic" session_option_24hr := true "Etc/UTC" else if syminfo.type == "cfd" session_option_24hr := true "Etc/UTC" else syminfo.timezone //functions fn_is_session_start(res, sess) => t = time(res, sess, tz) na(t[1]) and not na(t) or t[1] < t fn_is_in_session(session_rollover, session) => not na(time(session_rollover, session, tz)) fn_num_of_tpos_per_tick(price_min, price_max, bars_back) => int num_of_tpos = 0 for i=0 to bars_back if (high[i] >= price_min and low[i] <= price_max) num_of_tpos := num_of_tpos + 1 num_of_tpos fn_num_of_tpos_per_tick_arr(price_min, price_max, bars_back, array) => array.clear(array) for i=0 to bars_back if (high[i] >= price_min and low[i] < price_max) array.push(array, bars_back - i) array fn_build_tpo_letters_row(price_min, price_max, bars_back, array) => array.clear(array) for i=0 to bars_back if (high[i] >= price_min and low[i] <= price_max) array.push(array, i) array //TPOS_remaining = array.new_int(10, na) //TPO_per_loop = array.new_int(0) //array.set(TPOS_remaining, 9, 0) fn_build_VA(POC_index, TPO_array, VA_pct) => int TPOs_Left = math.round((array.sum(TPO_array)* VA_pct) - array.get(TPO_array, POC_index)) //int TPOs_used = array.get(TPOS_remaining, 9) TPO_mid_index = math.round((array.size(TPO_array)-1)/2) int VAL_index = POC_index int VAH_index = POC_index max_index = array.size(TPO_array) - 1 //array.push(TPO_per_loop, TPOs_Left) //array.push(TPO_per_loop, -1) for i=0 to max_index if TPOs_Left > 0 int VAH_2up = 0 int VAH_1up = 0 int VAL_1dn = 0 int VAL_2dn = 0 if VAH_index == max_index VAH_2up := 0 VAH_1up := 0 else if (VAH_index + 1) == max_index VAH_2up := 0 VAH_1up := array.get(TPO_array, VAH_index + 1) else VAH_2up := array.get(TPO_array, VAH_index + 2) VAH_1up := array.get(TPO_array, VAH_index + 1) if VAL_index == 0 VAL_2dn := 0 VAL_1dn := 0 else if (VAL_index -1) == 0 VAL_2dn := 0 VAL_1dn := array.get(TPO_array, VAL_index -1) else VAL_2dn := array.get(TPO_array, VAL_index -2) VAL_1dn := array.get(TPO_array, VAL_index -1) if (VAH_index + 2) <= max_index and (VAL_index - 2) >= 0 ///array.push(TPO_per_loop, 0) if (VAH_1up + VAH_2up) > (VAL_1dn + VAL_2dn) and (TPOs_Left - (VAH_1up + VAH_2up)) >= 0 TPOs_Left := TPOs_Left - VAH_1up - VAH_2up //TPOs_used := TPOs_used + VAH_1up + VAH_2up VAH_index := VAH_index + 2 else if (VAL_1dn + VAL_2dn) > (VAH_1up + VAH_2up) and (TPOs_Left - (VAL_1dn + VAL_2dn)) >= 0 TPOs_Left := TPOs_Left - VAL_1dn - VAL_2dn //TPOs_used := TPOs_used + VAL_1dn + VAL_2dn VAL_index := VAL_index - 2 else if (VAH_1up + VAH_2up) > (VAL_1dn + VAL_2dn) and TPOs_Left - VAH_1up >= 0 TPOs_Left := TPOs_Left - VAH_1up - VAH_2up //TPOs_used := TPOs_used + VAH_1up + VAH_2up VAH_index := VAH_index + 2 else if (VAL_1dn + VAL_2dn) > (VAH_1up + VAH_2up) and TPOs_Left - VAL_1dn >= 0 TPOs_Left := TPOs_Left - VAH_1up - VAH_2up //TPOs_used := TPOs_used + VAH_1up + VAH_2up VAH_index := VAH_index + 2 else if (VAH_1up + VAH_2up) == (VAL_1dn + VAL_2dn) if math.abs(VAH_index - TPO_mid_index) < math.abs(VAL_index - TPO_mid_index) and (TPOs_Left - (VAH_1up + VAH_2up)) >= 0 TPOs_Left := TPOs_Left - VAH_1up - VAH_2up //TPOs_used := TPOs_used + VAH_1up + VAH_2up VAH_index := VAH_index + 2 else if math.abs(VAH_index - TPO_mid_index) > math.abs(VAL_index - TPO_mid_index) and (TPOs_Left - (VAL_1dn + VAL_2dn)) >= 0 TPOs_Left := TPOs_Left - VAL_1dn - VAL_2dn //TPOs_used := TPOs_used + VAL_1dn + VAL_2dn VAL_index := VAL_index - 2 else if math.abs(VAH_index - TPO_mid_index) == math.abs(VAL_index - TPO_mid_index) and (TPOs_Left - (VAL_1dn + VAL_2dn)) >= 0 TPOs_Left := TPOs_Left - VAL_1dn - VAL_2dn //TPOs_used := TPOs_used + VAL_1dn + VAL_2dn VAL_index := VAL_index - 2 else if math.abs(VAH_index - TPO_mid_index) < math.abs(VAL_index - TPO_mid_index) TPOs_Left := TPOs_Left - VAH_1up //TPOs_used := TPOs_used + VAH_1up VAH_index := VAH_index + 1 else if math.abs(VAH_index - TPO_mid_index) > math.abs(VAL_index - TPO_mid_index) TPOs_Left := TPOs_Left - VAL_1dn //TPOs_used := TPOs_used + VAL_1dn VAL_index := VAL_index - 1 else if math.abs(VAH_index - TPO_mid_index) == math.abs(VAL_index - TPO_mid_index) TPOs_Left := TPOs_Left - VAL_1dn //TPOs_used := TPOs_used + VAL_1dn VAL_index := VAL_index - 1 else if VAH_1up > VAL_1dn TPOs_Left := TPOs_Left - VAH_1up //TPOs_used := TPOs_used + VAH_1up VAH_index := VAH_index + 1 else if VAH_1up < VAL_1dn TPOs_Left := TPOs_Left - VAL_1dn //TPOs_used := TPOs_used + VAL_1dn VAL_index := VAL_index - 1 else if VAH_1up == VAL_1dn if math.abs(VAH_index - TPO_mid_index) < math.abs(VAL_index - TPO_mid_index) TPOs_Left := TPOs_Left - VAH_1up //TPOs_used := TPOs_used + VAH_1up VAH_index := VAH_index + 1 else if math.abs(VAH_index - TPO_mid_index) > math.abs(VAL_index - TPO_mid_index) TPOs_Left := TPOs_Left - VAL_1dn //TPOs_used := TPOs_used + VAL_1dn VAL_index := VAL_index - 1 else if math.abs(VAH_index - TPO_mid_index) == math.abs(VAL_index - TPO_mid_index) TPOs_Left := TPOs_Left - VAL_1dn //TPOs_used := TPOs_used + VAL_1dn VAL_index := VAL_index - 1 else if (VAH_index + 1) == max_index or (VAL_index - 1) == 0 //array.push(TPO_per_loop, 1) if VAH_1up > VAL_1dn TPOs_Left := TPOs_Left - VAH_1up //TPOs_used := TPOs_used + VAH_1up VAH_index := VAH_index + 1 else if VAH_1up < VAL_1dn TPOs_Left := TPOs_Left - VAL_1dn //TPOs_used := TPOs_used + VAL_1dn VAL_index := VAL_index - 1 else if VAH_1up == VAL_1dn if math.abs(VAH_index - TPO_mid_index) < math.abs(VAL_index - TPO_mid_index) TPOs_Left := TPOs_Left - VAH_1up //TPOs_used := TPOs_used + VAH_1up VAH_index := VAH_index + 1 else if math.abs(VAH_index - TPO_mid_index) > math.abs(VAL_index - TPO_mid_index) TPOs_Left := TPOs_Left - VAL_1dn //TPOs_used := TPOs_used + VAL_1dn VAL_index := VAL_index - 1 else if math.abs(VAH_index - TPO_mid_index) == math.abs(VAL_index - TPO_mid_index) TPOs_Left := TPOs_Left - VAL_1dn //TPOs_used := TPOs_used + VAL_1dn VAL_index := VAL_index - 1 //array.set(TPOS_remaining, 3, VAH_2up) //array.set(TPOS_remaining, 4, VAH_1up) //array.set(TPOS_remaining, 5, VAL_1dn) //array.set(TPOS_remaining, 6, VAL_2dn) //array.set(TPOS_remaining, 7, (VAH_1up + VAH_2up) == (VAL_1dn + VAL_2dn) ? 1: 0) //array.set(TPOS_remaining, 8, (VAH_index + 1) == max_index or (VAL_index - 1) == 0 ? 1: 0) //else // if (VAH_index + 1) <= max_index and (VAH_1up + VAH_2up) > (VAL_1dn + VAL_2dn // TPOs_Left := TPOs_Left - VAH_1up - VAH_2up // VAH_index := VAH_index + 1 //else if (VAL_index - 1) >= 0 and (VAL_1dn + VAL_2dn) > (VAH_1up + VAH_2up) // TPOs_Left := TPOs_Left - VAL_1dn - VAL_2dn // VAL_index := VAL_index - 1 //array.push(TPO_per_loop, TPOs_Left) //array.set(TPOS_remaining, 0, TPOs_Left) //array.set(TPOS_remaining, 9, TPOs_used) //array.set(TPOS_remaining, 1, VAH_index) //array.set(TPOS_remaining, 2, VAL_index) [VAL_index, VAH_index] //labelIDs = array.new_label(0) var labelIds = array.new_label(0) var boxIDs = array.new_box(0) var last_boxIDs = array.new_box(0) var lineIDs = array.new_line(3) var lastLineIDs = array.new_line(0) TPO_price = array.new_float(0) TPO_length = array.new_int(0) sess1 = sess1Time + ":" + sessDays sess2 = sess2Time + ":" + sessDays sess3 = sess3Time + ":" + sessDays sess4 = sess4Time + ":" + sessDays sess24hr = "0000-0000:" + sessDays is_24hr_sess_open = fn_is_in_session("1440", sess24hr) is_sess1_open = fn_is_in_session("1440", sess1) is_sess2_open = fn_is_in_session("1440", sess2) is_sess3_open = fn_is_in_session("1440", sess3) is_sess4_open = fn_is_in_session("1440", sess4) sess_clear = false if timeframe.ismonthly is_in_session := true sess_start := nz(ta.barssince(ta.change(year))) which_sess := -4 else if timeframe.isweekly is_in_session := true sess_start := nz(ta.barssince(ta.change(year))) which_sess := -3 else if timeframe.isdaily is_in_session := true sess_start := nz(ta.barssince(ta.change(month))) which_sess := -2 else if session_option_24hr and timeframe.multiplier > 5 and timeframe.isminutes is_in_session := fn_is_in_session("1440", sess24hr) sess_start := nz(ta.barssince(ta.change(dayofweek))) which_sess := -1 else if timeframe.multiplier <= 5 and timeframe.isminutes is_in_session := fn_is_in_session("1440", sess24hr) sess_start := nz(ta.barssince(ta.change(hour))) which_sess := 5 else if timeframe.isseconds is_in_session := fn_is_in_session("1440", sess24hr) sess_start := nz(ta.barssince(ta.change(minute))) which_sess := 6 else if fn_is_in_session("1440", sess1) and show_sess1 is_in_session := fn_is_in_session("1440", sess1) sess_start := nz(ta.barssince(fn_is_session_start("1440", sess1))) which_sess := 1 else if fn_is_in_session("1440", sess2) and show_sess2 is_in_session := fn_is_in_session("1440", sess2) sess_start := nz(ta.barssince(fn_is_session_start("1440", sess2))) which_sess := 2 else if fn_is_in_session("1440", sess3) and show_sess3 is_in_session := fn_is_in_session("1440", sess3) sess_start := nz(ta.barssince(fn_is_session_start("1440", sess3))) which_sess := 3 else if fn_is_in_session("1440", sess4) and show_sess4 is_in_session := fn_is_in_session("1440", sess4) sess_start := nz(ta.barssince(fn_is_session_start("1440", sess4))) which_sess := 4 else is_in_session := false sess_start := 0 which_sess := 5 if syminfo.type == "economic" //sess_start := 0 is_in_session := false sess_start_bar = int(bar_index-sess_start) float tick_size = syminfo.mintick tick_size := if auto_tick_size_b and sess_start == 0 avg_bar_ht = ta.sma(high, tick_bars_back) - ta.sma(low, tick_bars_back) float auto_tick_size = math.round_to_mintick(avg_bar_ht / target_session_ht) if auto_tick_size == 0 auto_tick_size := syminfo.mintick auto_tick_size else if sess_start == 0 and not auto_tick_size_b man_tick_size * syminfo.mintick else tick_size := tick_size[sess_start] tick_size_ticks = tick_size / syminfo.mintick half_tick = math.round_to_mintick(tick_size*.5) var TPO_Name_list = array.from("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","!","@","#","$","%","&","*") var TPO_Names = array.new_string(0) int required_names = (sess_start) - (array.size(TPO_Names)) name_mult = int(array.size(TPO_Names) / array.size(TPO_Name_list)) if required_names >= 0 for i = 0 to required_names int tpos_to_add = nz((array.size(TPO_Names))) - array.size(TPO_Name_list)*name_mult array.push(TPO_Names, array.get(TPO_Name_list, tpos_to_add)) float highest_high = high float lowest_low = low for i = 0 to sess_start if high[i] > highest_high highest_high := high[i] if low[i] < lowest_low lowest_low := low[i] TPO_max = float(int(highest_high/tick_size)*tick_size) TPO_min = float(int(lowest_low/tick_size)*tick_size) TPO_rows = (TPO_max - TPO_min)/tick_size open_tick = int((open/tick_size)) * tick_size int total_tpo_count = 0 TPO_mid = math.round_to_mintick((TPO_min + TPO_max)/2) TPO_POC = float(0) TPO_VAL = float(0) int VAL_index = na int VAH_index = na TPO_VAH = float(0) var label red_pill = na label.delete(red_pill) TPO_low_curr_bar = int((low/tick_size)) * tick_size TPO_high_curr_bar = int((high/tick_size)) * tick_size TPO_rows_curr_bar = (TPO_high_curr_bar - TPO_low_curr_bar)/tick_size test_array_1 = array.new_float(0) test_array_2 = array.new_float(0) test_array_3 = array.new_string(0) test_array_4 = array.new_float(0) if is_in_session if sess_start == 0 array.concat(last_boxIDs, boxIDs) if array.size(lastLineIDs) > 497 line.delete(array.shift(lastLineIDs)) line.delete(array.shift(lastLineIDs)) line.delete(array.shift(lastLineIDs)) array.concat(lastLineIDs, lineIDs) array.set(lineIDs, 0, na) array.set(lineIDs, 1, na) array.set(lineIDs, 2, na) array.clear(boxIDs) array.clear(test_array_1) array.clear(test_array_2) array.clear(test_array_3) array.clear(test_array_4) if array.size(boxIDs) > 0 for i=0 to array.size(boxIDs)-1 box.delete(array.shift(boxIDs)) array.clear(boxIDs) if array.size(labelIds) > 0 for i=0 to array.size(labelIds)-1 label.delete(array.shift(labelIds)) array.clear(labelIds) for i = 0 to TPO_rows // build tpo size array price_tick_min = TPO_min + i * tick_size price_tick_max = price_tick_min + tick_size - syminfo.mintick num_of_tpos = fn_num_of_tpos_per_tick(price_tick_min, price_tick_max, sess_start) array.push(TPO_length, num_of_tpos) array.push(TPO_price, price_tick_min) //calculate POC and Value Area total_tpo_count := array.sum(TPO_length) max_TPOs = array.max(TPO_length) TPO_POC := if array.indexof(TPO_length, max_TPOs) == array.lastindexof(TPO_length, max_TPOs) float poc_price = array.get(TPO_price, array.indexof(TPO_length, max_TPOs)) poc_price else float poc_price = na int poc_index = na max_TPOs = array.max(TPO_length) poc_possible_price = array.new_float(0) poc_possible_dist_to_mid = array.new_float(0) for i = 0 to array.size(TPO_length)-1 if array.get(TPO_length, i) == max_TPOs array.push(poc_possible_price, array.get(TPO_price, i)) array.push(poc_possible_dist_to_mid, math.abs(array.get(TPO_price, i) - TPO_mid)) int counter = 0 for i = 0 to array.size(poc_possible_price)-1 if array.size(poc_possible_price) > counter if array.min(poc_possible_dist_to_mid) != array.get(poc_possible_dist_to_mid, counter) array.remove(poc_possible_dist_to_mid, counter) array.remove(poc_possible_price, counter) else counter := counter + 1 if array.indexof(poc_possible_dist_to_mid, array.min(poc_possible_dist_to_mid)) == array.lastindexof(poc_possible_dist_to_mid, array.min(poc_possible_dist_to_mid)) poc_index := array.indexof(poc_possible_dist_to_mid, array.min(poc_possible_dist_to_mid)) else poc_index := 0 poc_price := array.get(poc_possible_price, poc_index) poc_price POC_index = array.indexof(TPO_price, TPO_POC) [_VAL_index, _VAH_index] = fn_build_VA(POC_index, TPO_length, value_area_pct) TPO_VAL := array.get(TPO_price, _VAL_index) TPO_VAH := array.get(TPO_price, _VAH_index) last_box_color = out_of_value_tpo_color for i = 0 to TPO_rows // build tpo and box arrays price_tick_min = array.get(TPO_price, i) price_tick_max = price_tick_min + tick_size tpo_row_index_data = array.new_int() fn_num_of_tpos_per_tick_arr(price_tick_min, price_tick_max, sess_start, tpo_row_index_data) array.reverse(tpo_row_index_data) num_of_tpos = array.size(tpo_row_index_data) //array.push(TPO_length, num_of_tpos) // build current TPO boxes and Letters left_side = sess_start_bar is_poc = price_tick_min == TPO_POC ? true : false if is_poc line.delete(array.get(lineIDs, 0)) POC_line = line.new(left_side, price_tick_min + half_tick, bar_index + 1, price_tick_min + half_tick, color=POC_line_color) array.set(lineIDs, 0, POC_line) //right_side = is_poc? bar_index + 1 : sess_start_bar + num_of_tpos right_side = sess_start_bar + num_of_tpos is_in_value = price_tick_min >= TPO_VAL and price_tick_min <= TPO_VAH if price_tick_min == TPO_VAH VAH_line_id = array.get(lineIDs, 1) line.delete(array.get(lineIDs, 1)) VAH_line = line.new(left_side, price_tick_max, bar_index + 1, price_tick_max, color=in_value_line_color) array.set(lineIDs, 1, VAH_line) if price_tick_min == TPO_VAL VAL_line_id = array.get(lineIDs, 2) line.delete(array.get(lineIDs, 2)) VAL_line = line.new(left_side, price_tick_min, bar_index + 1, price_tick_min, color=in_value_line_color) array.set(lineIDs, 2, VAL_line) //POC_tpo_color box_color = is_poc? POC_box_color : is_in_value? in_value_box_color : out_of_value_box_color //tpo_color = is_poc? POC_tpo_color : is_in_value? in_value_tpo_color : out_of_value_tpo_color //box_color = out_of_value_box_color transparency = is_in_value ? in_value_box_transparency : out_of_value_box_transparency //transparency = out_of_value_box_transparency int total_boxes = array.size(boxIDs) + array.size(last_boxIDs) if array.size(boxIDs) > 0 last_box_ID = array.get(boxIDs, array.size(boxIDs)-1) last_box_right = box.get_right(last_box_ID) last_box_bot = box.get_bottom(last_box_ID) if right_side == last_box_right and not is_poc and last_box_bot != TPO_POC and last_box_color == box_color box.set_top(last_box_ID, price_tick_max) array.push(test_array_3, str.tostring(price_tick_min)) else if total_boxes > 499 and array.size(last_boxIDs) > 0 box.delete(array.shift(last_boxIDs)) total_boxes := array.size(boxIDs) + array.size(last_boxIDs) if total_boxes > 499 and array.size(boxIDs) > 0 box.delete(array.shift(boxIDs)) tpo_box = box.new(left=left_side, top=price_tick_max, right=right_side, bottom=price_tick_min, bgcolor=color.new(box_color, transparency), border_color = na) array.push(boxIDs, tpo_box) else if total_boxes > 499 and array.size(last_boxIDs) > 0 box.delete(array.shift(last_boxIDs)) total_boxes := array.size(boxIDs) + array.size(last_boxIDs) if total_boxes > 499 and array.size(boxIDs) > 0 box.delete(array.shift(boxIDs)) tpo_box = box.new(left=left_side, top=price_tick_max, right=right_side, bottom=price_tick_min, bgcolor=color.new(box_color, transparency), border_color = na) array.push(boxIDs, tpo_box) curr_box_ID = array.get(boxIDs, array.size(boxIDs)-1) if plot_TPO_letters and barstate.islast //if plot_TPO_letters //string tpo_row_text = na if array.size(tpo_row_index_data) > 0 for i=0 to array.size(tpo_row_index_data) - 1 if array.size(labelIds) > 499 label.delete(array.shift(labelIds)) letter_index = int(array.get(tpo_row_index_data, i)) tpo_color = is_poc ? POC_tpo_color : price_tick_min == open_tick[sess_start - letter_index]? open_color : is_in_value? in_value_tpo_color : out_of_value_tpo_color tpo_letter = tpo_letter_space + array.get(TPO_Names, letter_index) //tpo_row_text := tpo_row_text + tpo_letter tpo_label = label.new(x=left_side + i, y=price_tick_min, textcolor=tpo_color, text=tpo_letter, style=label.style_none, textalign=text.align_left, size=TPO_txt_size) array.push(labelIds, tpo_label) last_box_color := box_color curr_price_y = int((close/tick_size)) * tick_size curr_price_y_index = if array.includes(TPO_price, curr_price_y) array.indexof(TPO_price, curr_price_y) else sess_start_bar curr_price_x = array.get(TPO_length, curr_price_y_index) + sess_start_bar red_pill := label.new (x=curr_price_x, y=curr_price_y, text=curr_price_text, style=label.style_none, textalign=text.align_left, size=TPO_txt_size) if not is_in_session or barstate.islastconfirmedhistory label.delete(red_pill) current_sess = if which_sess == -4 "Monthly" else if which_sess == -3 "Weekly" else if which_sess == -2 "Daily" else if which_sess == -1 "24Hr" else if which_sess == 1 sess1Name else if which_sess == 2 sess2Name else if which_sess == 3 sess3Name else if which_sess == 4 sess4Name else if which_sess == 5 "1 Hour" else if which_sess == 6 "1 Minute" else "n/a" current_bar = is_in_session ? str.tostring(array.get(TPO_Names, sess_start)) : "n/a" info_text_1 = "Ticks: " + str.tostring(tick_size / syminfo.mintick) info_text_2 = "Tick Size: $" + str.tostring(tick_size) info_text_3 = "Total TPOs: " + str.tostring(total_tpo_count) info_text_4 = "Current Bar: " + current_bar info_text_5 = "Current Session: " + current_sess warning_display_tick_b = total_tpo_count > 495 warning_display_tick_s = "Please Increase Tick Size\nuntil under 500 Total TPOs" open_price = int((open/tick_size)) * tick_size cell_info = str.tostring(array.sum(TPO_length)) var table ticktestarray = table.new(position.bottom_right, 1, 20, bgcolor = info_table_color, frame_width = 2, frame_color = color.black) var table ticksizetable = table.new(position.top_right, 1, 5, bgcolor = info_table_color, frame_width = 2, frame_color = color.black) if show_tpo_info tpo_count_color = total_tpo_count > 495 ? color.red : info_table_text_color table.cell(ticksizetable, 0, 0, text=info_text_1, text_color = info_table_text_color, text_size = info_table_txt_size) table.cell(ticksizetable, 0, 1, text=info_text_2, text_color = info_table_text_color, text_size = info_table_txt_size) table.cell(ticksizetable, 0, 2, text=info_text_3, text_color = tpo_count_color, text_size = info_table_txt_size) table.cell(ticksizetable, 0, 3, text=info_text_4, text_color = info_table_text_color, text_size = info_table_txt_size) table.cell(ticksizetable, 0, 4, text=info_text_5, text_color = info_table_text_color, text_size = info_table_txt_size) else table.clear(ticksizetable,0,0,0,2) var table tick_warning = table.new(position.middle_right, 1, 1, bgcolor = color.red, frame_width = 2, frame_color = color.black) if warning_display_tick_b and show_warning table.cell(tick_warning, 0, 0, text=warning_display_tick_s, text_color = color.white, text_size = size.large) else table.clear(tick_warning,0,0,0,0 ) if debug_option table.cell(ticktestarray, 0, 0, text="sess_start " + str.tostring(sess_start), text_color = color.white, text_size = deb_txt_size) //table.cell(ticktestarray, 0, 1, text="syminfo.mintick " + str.tostring(syminfo.mintick), text_color = color.white, text_size = deb_txt_size) table.cell(ticktestarray, 0, 2, text="tick_size " + str.tostring(tick_size), text_color = color.white, text_size = deb_txt_size) table.cell(ticktestarray, 0, 3, text="timeframe.multiplier " + str.tostring(timeframe.multiplier), text_color = color.white, text_size = deb_txt_size) //table.cell(ticktestarray, 0, 4, text="_auto_tick_size " + str.tostring(_auto_tick_size), text_color = color.white, text_size = deb_txt_size) //table.cell(ticktestarray, 0, 5, text="_man_tick_size " + str.tostring(_man_tick_size), text_color = color.white, text_size = deb_txt_size) else table.clear(ticktestarray,0,0,0,19)
EMArea
https://www.tradingview.com/script/avNJHIcL-EMArea/
csirisomboonrat
https://www.tradingview.com/u/csirisomboonrat/
5
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © csirisomboonrat //@version=5 indicator("Short indicator", overlay=true) src = close // input for RSI differest Timeframe rsi = ta.rsi(src, 7) // ********************************************************************************************** // // *********************** Storchastihttps://www.tradingview.com/chart/PTzN6SrG/#cs RSI SECTION ******************************************** // // ********************************************************************************************** // smoothK = 3 smoothD = 3 lengthRSI = 14 lengthStoch = 14 rsi1 = ta.rsi(src, lengthRSI) k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK) d = ta.sma(k, smoothD) // ------------------------------ End section STO RSI ---------------------------------- // // ********************************************************************************************** // // ************************************ ADX SECTION ******************************************** // // ********************************************************************************************** // len = 14 TrueRange = math.max(math.max(high - low, math.abs(high - nz(close[1]))), math.abs(low - nz(close[1]))) DirectionalMovementPlus = high - nz(high[1]) > nz(low[1]) - low ? math.max(high - nz(high[1]), 0) : 0 DirectionalMovementMinus = nz(low[1]) - low > high - nz(high[1]) ? math.max(nz(low[1]) - low, 0) : 0 SmoothedTrueRange = 0.0 SmoothedTrueRange := nz(SmoothedTrueRange[1]) - nz(SmoothedTrueRange[1]) / len + TrueRange SmoothedDirectionalMovementPlus = 0.0 SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - nz(SmoothedDirectionalMovementPlus[1]) / len + DirectionalMovementPlus SmoothedDirectionalMovementMinus = 0.0 SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - nz(SmoothedDirectionalMovementMinus[1]) / len + DirectionalMovementMinus DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100 DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100 DX = math.abs(DIPlus - DIMinus) / (DIPlus + DIMinus) * 100 ADX = ta.sma(DX, len) Dtrend = math.abs(DIPlus) - math.abs(DIMinus) + 20 // If Dtrend > 0 => Uptrend And Dtrend <0 => Downtrend // ------------------------------ End section ADX ---------------------------------- // normalize_bb(float upper, float lower, int days) => // BolingerBand Ranking normalize_bb = 0.0 mult = 2.0 basis = ta.sma(upper, days) dev = mult * ta.stdev(upper, days) // Expand deviation to 1.1X from original Bollinger Band // upper = basis + dev // Get upper band // secondupper = basis + (1.5* dev) // Crete new band that higher than original upperband call "secondupper" (1.3X * 1.1X of original) // thirdupper = basis + (1.8* dev) fourthupper = basis + (2.1* dev) if upper > basis dd = (upper - basis) / (fourthupper - basis) normalize_bb := math.pow(dd, 0.33) * 50 + 50 basis_l = ta.sma(lower, days) dev_l = mult * ta.stdev(lower, days) fourthlower = basis_l - (2.1* dev_l) if lower < basis_l dd_l = (basis_l - lower) / (basis_l - fourthlower) normalize_bb := 50 - math.pow(dd_l, 0.33) * 50 normalize_bb em_area(w,x,y,z) => ema100 = ta.ema(close,w) ema50 = ta.ema(close, x) ema21 = ta.ema(close, y) ema13 = ta.ema(close, z) ema1d = ema100 - ema21 ema2d = ema50 - ema13 em_area = math.abs(ema1d) * math.abs(ema2d) / math.pow((math.abs(ema1d) + math.abs(ema2d))/2,2) if (ema100 < ema50 and ema50 < ema21) em_area := 50 + em_area * 50 else if ema100 > ema50 and ema50 > ema21 em_area := 50 - (em_area * 50) else em_area := 50 em_area // Getting inputs fast_length = 12 slow_length = 26 signal_length = 9 sma_source = "EMA" sma_signal = "EMA" // Plot colors // Calculating fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length) slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length) macd = fast_ma - slow_ma signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length) hist = macd - signal color=(hist>=0 ? (hist[1] < hist ? 2 : 1) : (hist[1] < hist ? -1 : -2)) test_md = color for i = 1 to 6 if color[i] > 0 test_md := test_md + color[i] else test_md := test_md + 2 emarea = em_area(100,50,21,14) // long = 0 // if emarea <= 5 and nbb <= 12 and rsii <= 25 //long := 1 //if long == 1 and ta.sma(long, 10) == 0.4 //my_label = label.new(bar_index, open, text="Long", yloc=yloc.belowbar, style=label.style_label_up) // plot(long, color=color.green) plot(test_md) kdcross = ta.crossunder(k,d) short = 0 if rsi > 70 and k > d and k > 85 short := 1 if short == 1 and ta.sma(short, 10) == 0.4 and test_md <= 10 and emarea == 50 short_label = label.new(bar_index, close, text="Short", yloc=yloc.abovebar, style=label.style_label_down, color=color.red)
Oscillators Switch
https://www.tradingview.com/script/nEW5pRyF-Oscillators-Switch/
RozaniGhani-RG
https://www.tradingview.com/u/RozaniGhani-RG/
40
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © RozaniGhani-RG //@version=5 indicator('Oscillators Switch', shorttitle ='OSC') // 0. Tooltip // 1. input.string // 2. input.color // 3. input.source // 4. input.int // 5. Dependencies : input.string and input.color // 6. Dependencies : input.string, input.source and input.int // 7. Plot // ————————————————————————————————————————————————————————————————————————————— 0. Tooltip { T0 = ' CMO : Chande Momentum Oscillator' + '\n RSI : Relative Strength Index' + '\n STO : Stochastic' + '\n TSI : True Strength Index' + '\n UO : Ultimate Oscillator' // } // ————————————————————————————————————————————————————————————————————————————— 1. input.string { string i_s_osc = input.string('RSI', 'Oscillator', options = ['RSI', 'STO', 'UO', 'TSI', 'CMO'], tooltip = T0) // } // ————————————————————————————————————————————————————————————————————————————— 2. input.color { i_c_cmo = input.color(#2962FF, 'CMO', inline = '1') i_c_rsi = input.color(#7E57C2, 'RSI ', inline = '2') i_c_sto = input.color(#2962FF, 'STO', inline = '3') i_c_tsi = input.color(#2962FF, 'TSI ', inline = '4') i_c_uo = input.color(#F44336, 'UO ', inline = '5') // } // ————————————————————————————————————————————————————————————————————————————— 3. input.source { i_s_cmo = input.source(close, '', inline = '1') i_s_rsi = input.source(close, '', inline = '2') i_s_sto = input.source(close, '', inline = '3') i_s_tsi = input.source(close, '', inline = '4') i_s_uo = input.source(hl2, '', inline = '5') // } // ————————————————————————————————————————————————————————————————————————————— 4. input.int { i_i0_cmo = input.int(14, '', inline = '1') i_i0_rsi = input.int(14, '', inline = '2') i_i0_sto = input.int(14, '', inline = '3') i_i0_tsi = input.int(25, '', inline = '4'), i_i1_tsi = input.int(13, '', inline = '4') i_i0_uo = input.int(5, '', inline = '5'), i_i1_uo = input.int(34, '', inline = '5') // } // ————————————————————————————————————————————————————————————————————————————— 5. Dependencies : input.string and input.color { color col = switch i_s_osc 'CMO' => i_c_cmo 'RSI' => i_c_rsi 'STO' => i_c_sto 'TSI' => i_c_tsi 'UO' => i_c_uo // } // ————————————————————————————————————————————————————————————————————————————— 6. Dependencies : input.string, input.source and input.int { float osc = switch i_s_osc 'CMO' => ta.cmo( i_s_cmo, i_i0_cmo) 'RSI' => ta.rsi( i_s_rsi, i_i0_rsi) 'STO' => ta.stoch(i_s_sto, high, low, i_i0_sto) 'TSI' => ta.tsi( i_s_tsi, i_i0_tsi, i_i1_tsi) 'UO' => ta.sma( i_s_uo, i_i0_uo) - ta.sma(i_s_uo, i_i1_uo) // } // ————————————————————————————————————————————————————————————————————————————— 7. Plot { plot(osc, color = col) // }
Run Timer
https://www.tradingview.com/script/vpCaRlSM-Run-Timer/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
102
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © HeWhoMustNotBeNamed // __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __ // / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / | // $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ | // $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ | // $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ | // $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ | // $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ | // $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ | // $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/ // // // //@version=5 indicator("Run Timer", overlay=true) key = input.string("TRIAL", title="Key", group="Auth", confirm=true) trialBars = input.int(5, title="Trial Period (In Bars)", group="Auth") f_getTimer()=> var timestart = timenow barcount = ta.barssince(barstate.islastconfirmedhistory) mseconds = timenow-timestart seconds = mseconds/1000 minutes = seconds/60 hours = minutes/60 days = hours/24 tmSeconds = mseconds%1000 tSeconds = seconds%60 tMinutes = minutes%60 tHours = hours%24 [days, tHours, tMinutes, tSeconds, tmSeconds, barcount] [days, tHours, tMinutes, tSeconds, tmSeconds, barcount] = f_getTimer() validKey = (key == "1234" or nz(barcount,0) <= trialBars) var timer = table.new(position=position.top_center, columns=10, rows=1, border_width=0) backgroundColor = validKey? color.green : color.red table.cell(table_id=timer, column=0, row=0, text=str.tostring(days, "00"), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal) table.cell(table_id=timer, column=1, row=0, text="/", bgcolor=backgroundColor, text_color=color.white, text_size=size.normal) table.cell(table_id=timer, column=2, row=0, text=str.tostring(tHours, "00"), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal) table.cell(table_id=timer, column=3, row=0, text=":", bgcolor=backgroundColor, text_color=color.white, text_size=size.normal) table.cell(table_id=timer, column=4, row=0, text=str.tostring(tMinutes, "00"), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal) table.cell(table_id=timer, column=5, row=0, text=":", bgcolor=backgroundColor, text_color=color.white, text_size=size.normal) table.cell(table_id=timer, column=6, row=0, text=str.tostring(tSeconds, "00"), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal) table.cell(table_id=timer, column=7, row=0, text=".", bgcolor=backgroundColor, text_color=color.white, text_size=size.normal) table.cell(table_id=timer, column=8, row=0, text=str.tostring(tmSeconds), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
Baekdoo multi cumulative disparity
https://www.tradingview.com/script/sjWzzVUK-Baekdoo-multi-cumulative-disparity/
traderbaekdoosan
https://www.tradingview.com/u/traderbaekdoosan/
61
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © traderbaekdoosan //@version=4 study("Baekdoo multi cumulative disparity") //exponential MA used weighted disparity with 0 as the same value of the ema(close,period) value w_disp(Period)=>close/ema(close,Period)*100-100 p=5 m=2 maxd=250 short=5 middle=20 long=60 NP=w_disp(p)+w_disp(p+1*m)+w_disp(p+2*m)+w_disp(p+3*m)+w_disp(p+4*m)+w_disp(p+5*m)+w_disp(p+6*m)+w_disp(p+7*m)+ w_disp(p+8*m)+w_disp(p+9*m)+w_disp(p+10*m)+w_disp(p+11*m)+w_disp(p+12*m)+w_disp(p+13*m)+w_disp(p+14*m)+w_disp(p+15*m)+ w_disp(p+16*m)+w_disp(p+17*m)+w_disp(p+18*m)+w_disp(p+19*m)+w_disp(p+20*m)+w_disp(p+21*m)+w_disp(p+22*m)+w_disp(p+23*m)+ w_disp(p+24*m)+w_disp(p+25*m)+w_disp(p+26*m)+w_disp(p+27*m)+w_disp(p+28*m)+w_disp(p+29*m)+w_disp(p+30*m)+w_disp(p+31*m)+ w_disp(p+32*m)+w_disp(p+33*m)+w_disp(p+34*m)+w_disp(p+35*m)+w_disp(p+36*m)+w_disp(p+37*m)+w_disp(p+38*m)+w_disp(p+39*m)+ w_disp(p+40*m)+w_disp(p+41*m)+w_disp(p+42*m)+w_disp(p+43*m)+w_disp(p+44*m)+w_disp(p+45*m)+w_disp(p+46*m)+w_disp(p+47*m)+ w_disp(p+48*m)+w_disp(p+49*m)+w_disp(p+50*m)+w_disp(p+51*m)+w_disp(p+52*m)+w_disp(p+53*m)+w_disp(p+54*m)+w_disp(p+55*m)+ w_disp(p+56*m)+w_disp(p+57*m)+w_disp(p+58*m)+w_disp(p+59*m)+w_disp(p+60*m)+w_disp(p+61*m)+w_disp(p+62*m)+w_disp(p+63*m)+ w_disp(p+64*m)+w_disp(p+65*m)+w_disp(p+66*m)+w_disp(p+67*m)+w_disp(p+68*m)+w_disp(p+69*m)+w_disp(p+70*m)+w_disp(p+71*m)+ w_disp(p+72*m)+w_disp(p+73*m)+w_disp(p+74*m)+w_disp(p+75*m)+w_disp(p+76*m)+w_disp(p+77*m)+w_disp(p+78*m)+w_disp(p+79*m)+ w_disp(p+80*m)+w_disp(p+81*m)+w_disp(p+82*m)+w_disp(p+83*m)+w_disp(p+84*m)+w_disp(p+85*m)+w_disp(p+86*m)+w_disp(p+87*m)+ w_disp(p+88*m)+w_disp(p+89*m)+w_disp(p+90*m)+w_disp(p+91*m)+w_disp(p+92*m)+w_disp(p+93*m)+w_disp(p+94*m)+w_disp(p+95*m) NPR = 100*NP/max(abs(highest(NP,maxd)), abs(lowest(NP,maxd))) //연중 최고값과의 비율 NPR_long=ema(NPR,long) NPR_middle=ema(NPR,middle) NPR_short=ema(NPR,short) plot(NPR_long, color=color.red) plot(NPR_middle, color=color.blue) plot(NPR_short, color=color.blue) target=plot(NPR, color=color.yellow) //base = hline(0.0, "baseline", color=color.white, linestyle=hline.style_dashed) target2=plot(0.0, color=color.white) fill(target, target2, color = NPR<0 ? color.rgb(100, 150, 243, 90) : na, title="Background")
Shariah & PN17 Bursa Malaysia
https://www.tradingview.com/script/BikS0gG0-Shariah-PN17-Bursa-Malaysia/
mukhlisahmadmy
https://www.tradingview.com/u/mukhlisahmadmy/
29
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © mukhlisahmadmy //DISCLAIMER *************************************************************************************************// // This Shariah Indicator ONLY and MERELY applicable to be used with BURSA MALAYSIA STOCK MARKET // List of Shariah Stock Was Extracted From: // - https://www.bursamalaysia.com/market_information/equities_prices // List of PN17 & GN3 Stock Was Extracted From: // - https://www.bursamalaysia.com/trade/trading_resources/listing_directory/pn17_and_gn13_companies // This Indicator Was Built by Referring To: // -https://www.tradingview.com/script/tKoaNdYm-Saham-Syariah-Indonesia-The-Most-Liquid-Sharia-Stocks-Indonesia/ //************************************************************************************************************// //HOW DOES THE INDICATOR WORK*********************************************************************************// // 0. This is an overlay type of indicator. (Panel on chart) // 1. This indicator list all shariah stock including warrant up to the month & year stated on the panel. // 2. User may update the list (delete or adding) accordingly - refer to comment in the code // 3. Panel of the indicator may be relocated in the indicator setting - default: TOP RIGHT // 4. Panel will indicate Red Color with 'PN17' text for PN17/G3 stock // 5. Panel will indicate Green Color with 'S' text for shariah stock // 6. Panel will indicate none for non-shariah stock // 7. If shariah stock was listed as PN17/GN3 stock, panel will indicate as PN17 //************************************************************************************************************// //@version=5 indicator(title="Shariah & PN17 Bursa Malaysia", shorttitle="S", overlay=true) TablePos = input.string(title="Location", defval="Top Right", options=["Top Right", "Middle Right", "Bottom Right", "Top Center", "Middle Center", "Bottom Center", "Top Left", "Middle Left", "Bottom Left"], group = "Display Panel") _tablePos= TablePos== "Top Right" ? position.top_right: TablePos== "Middle Right" ? position.middle_right: TablePos== "Bottom Right" ? position.bottom_right: TablePos== "Top Center" ? position.top_center: TablePos== "Middle Center"? position.middle_center: TablePos== "Bottom Center"? position.bottom_center: TablePos== "Top Left" ? position.top_left: TablePos== "Middle Left" ? position.middle_left:position.bottom_left Size = input.string(title="Size", defval="Small", options=["Normal", "Small", "Tiny"], group = "Display Panel") _size= Size == "Normal"? size.normal:Size == "Small"? size.small: size.tiny //Code Required Frequent Update Referring to Bursa Malaysia Website.................................................... pn17_gn3 = array.new_string(20, "") //<<-Number of PN17 & GN3 Stock shariah = array.new_string(971, "") //<<-Number of shariah Stock update_date = "22/06/15" //<<-Year/Month/Date Updated //PN17 & GN3 Stocks List array.push(pn17_gn3,'AAX') array.push(pn17_gn3,'AMEDIA') array.push(pn17_gn3,'BARAKAH') array.push(pn17_gn3,'BERTAM') array.push(pn17_gn3,'CAPITALA') array.push(pn17_gn3,'CAPITALA-WA') array.push(pn17_gn3,'CAP') array.push(pn17_gn3,'COMCORP') array.push(pn17_gn3,'DOLMITE') array.push(pn17_gn3,'EATECH') array.push(pn17_gn3,'FSBM') array.push(pn17_gn3,'IQZAN') array.push(pn17_gn3,'IREKA') array.push(pn17_gn3,'JERASIA') array.push(pn17_gn3,'KHEESAN') array.push(pn17_gn3,'KTB') array.push(pn17_gn3,'MPCORP') array.push(pn17_gn3,'PRKCORP') array.push(pn17_gn3,'PGB') array.push(pn17_gn3,'SAPNRG') array.push(pn17_gn3,'SCOMIES') array.push(pn17_gn3,'SCOMI') array.push(pn17_gn3,'SCOMI-WB') array.push(pn17_gn3,'SEACERA') array.push(pn17_gn3,'SERBADK') array.push(pn17_gn3,'SERBADK-WA') array.push(pn17_gn3,'THHEAVY') array.push(pn17_gn3,'TOPBLDS') array.push(pn17_gn3,'IDMENSN') array.push(pn17_gn3,'GNB') //Bursa Malaysia Shariah Stocks List array.push(shariah,'DNEX') array.push(shariah,'TOPGLOV') array.push(shariah,'WIDAD') array.push(shariah,'YONGTAI') array.push(shariah,'YEWLEE') array.push(shariah,'SERBADK') array.push(shariah,'JETSON') array.push(shariah,'JSB') array.push(shariah,'SUPERMX') array.push(shariah,'LGMS') array.push(shariah,'SERBADK-WA') array.push(shariah,'HIBISCS') array.push(shariah,'IRIS') array.push(shariah,'CYPARK') array.push(shariah,'NWP') array.push(shariah,'BPLANT') array.push(shariah,'SAPNRG') array.push(shariah,'HEXIND') array.push(shariah,'PWORTH') array.push(shariah,'JADEM') array.push(shariah,'DSONIC') array.push(shariah,'HIAPTEK') array.push(shariah,'AEMULUS') array.push(shariah,'CNERGEN') array.push(shariah,'ICONIC') array.push(shariah,'MERIDIAN') array.push(shariah,'HARTA') array.push(shariah,'PA') array.push(shariah,'SEDANIA') array.push(shariah,'KNM') array.push(shariah,'JTIASA') array.push(shariah,'MNHLDG') array.push(shariah,'CAPITALA') array.push(shariah,'FFB') array.push(shariah,'MYEG') array.push(shariah,'SIAB') array.push(shariah,'DYNACIA') array.push(shariah,'SCIB') array.push(shariah,'EVERGRN') array.push(shariah,'GENETEC') array.push(shariah,'TANCO') array.push(shariah,'INARI') array.push(shariah,'PTRANS') array.push(shariah,'QES') array.push(shariah,'ATAIMS') array.push(shariah,'AXIATA') array.push(shariah,'NOVAMSC') array.push(shariah,'JAG') array.push(shariah,'EKOVEST') array.push(shariah,'DATAPRP') array.push(shariah,'BSTEAD') array.push(shariah,'CITAGLB') array.push(shariah,'GREATEC') array.push(shariah,'AHB') array.push(shariah,'ARTRONIQ') array.push(shariah,'NESTCON') array.push(shariah,'STRAITS-WA') array.push(shariah,'KOSSAN') array.push(shariah,'WCT') array.push(shariah,'DESTINI') array.push(shariah,'COCOLND') array.push(shariah,'VS') array.push(shariah,'CAREPLS') array.push(shariah,'DSONIC-WA') array.push(shariah,'PMETAL') array.push(shariah,'HENGYUAN') array.push(shariah,'CTOS') array.push(shariah,'JSB-WB') array.push(shariah,'SIMEPROP') array.push(shariah,'EMICO') array.push(shariah,'CRG') array.push(shariah,'VELESTO-WA') array.push(shariah,'ASIAPLY') array.push(shariah,'TSH') array.push(shariah,'PERMAJU') array.push(shariah,'CMSB') array.push(shariah,'TENAGA') array.push(shariah,'XL') array.push(shariah,'AIMFLEX') array.push(shariah,'BAHVEST') array.push(shariah,'SIME') array.push(shariah,'DANCO') array.push(shariah,'MRCB') array.push(shariah,'MINDA') array.push(shariah,'DIALOG') array.push(shariah,'JAKS') array.push(shariah,'FRONTKN-WB') array.push(shariah,'SWIFT') array.push(shariah,'ALAM') array.push(shariah,'SDS') array.push(shariah,'MAHSING') array.push(shariah,'GPACKET') array.push(shariah,'SCOPE') array.push(shariah,'SPSETIA') array.push(shariah,'VINVEST') array.push(shariah,'LAYHONG') array.push(shariah,'YBS') array.push(shariah,'MESTRON-WA') array.push(shariah,'UCREST') array.push(shariah,'CENSOF') array.push(shariah,'CENSOF') array.push(shariah,'STRAITS') array.push(shariah,'MQTECH') array.push(shariah,'MASTEEL') array.push(shariah,'NIHSIN') array.push(shariah,'BSLCORP') array.push(shariah,'MPAY') array.push(shariah,'CORAZA') array.push(shariah,'IOICORP') array.push(shariah,'HWGB') array.push(shariah,'SYSCORP') array.push(shariah,'IFCAMSC') array.push(shariah,'ANCOMLB') array.push(shariah,'VC') array.push(shariah,'OWG') array.push(shariah,'KPOWER') array.push(shariah,'TAFI') array.push(shariah,'BIOHLDG') array.push(shariah,'RSAWIT') array.push(shariah,'HARNLEN-WB') array.push(shariah,'PHARMA') array.push(shariah,'ECOFIRS') array.push(shariah,'BPURI') array.push(shariah,'TALAMT') array.push(shariah,'TEXCHEM') array.push(shariah,'ALRICH') array.push(shariah,'WPRTS') array.push(shariah,'ECONBHD') array.push(shariah,'NEXGRAM') array.push(shariah,'TDM') array.push(shariah,'EURO') array.push(shariah,'MI') array.push(shariah,'MEDIAC') array.push(shariah,'MRCB-WB') array.push(shariah,'BORNOIL') array.push(shariah,'NYLEX') array.push(shariah,'OCK') array.push(shariah,'SCOPE-WB') array.push(shariah,'FRONTKN') array.push(shariah,'DUFU') array.push(shariah,'BINTAI') array.push(shariah,'MESTRON') array.push(shariah,'JHM') array.push(shariah,'ICON') array.push(shariah,'DAYANG') array.push(shariah,'G3') array.push(shariah,'HHGROUP') array.push(shariah,'HARBOUR') array.push(shariah,'VERTICE') array.push(shariah,'FIAMMA') array.push(shariah,'TWL') array.push(shariah,'PUC') array.push(shariah,'OWG-WA') array.push(shariah,'THPLANT') array.push(shariah,'DYNACIA-WA') array.push(shariah,'TAFI-WA') array.push(shariah,'CAPITALA-WA') array.push(shariah,'RL') array.push(shariah,'AT') array.push(shariah,'REDTONE') array.push(shariah,'RGTBHD') array.push(shariah,'PASUKGB') array.push(shariah,'SCBUILD') array.push(shariah,'VC-WC') array.push(shariah,'MYCRON') array.push(shariah,'MUHIBAH') array.push(shariah,'GTRONIC') array.push(shariah,'KGROUP') array.push(shariah,'KRONO') array.push(shariah,'BAUTO') array.push(shariah,'CJCEN') array.push(shariah,'AYS') array.push(shariah,'MEGASUN') array.push(shariah,'PECCA') array.push(shariah,'CEPAT') array.push(shariah,'SCNWOLF') array.push(shariah,'SAUDEE') array.push(shariah,'KAREX') array.push(shariah,'UZMA') array.push(shariah,'IJM') array.push(shariah,'IOIPG') array.push(shariah,'MTRONIC') array.push(shariah,'PTRANS-WB') array.push(shariah,'PETRONM') array.push(shariah,'MFLOUR') array.push(shariah,'SMI') array.push(shariah,'CAB') array.push(shariah,'MILUX') array.push(shariah,'GADANG') array.push(shariah,'SMTRACK') array.push(shariah,'BARAKAH') array.push(shariah,'JADI') array.push(shariah,'YLI') array.push(shariah,'CWG-WA') array.push(shariah,'WONG') array.push(shariah,'ANCOMNY') array.push(shariah,'UEMS') array.push(shariah,'CNH') array.push(shariah,'UWC') array.push(shariah,'ANNJOO') array.push(shariah,'ANNJOO') array.push(shariah,'FGV') array.push(shariah,'MNC') array.push(shariah,'KOBAY') array.push(shariah,'D&O') array.push(shariah,'MOBILIA') array.push(shariah,'VS-WB') array.push(shariah,'OPCOM') array.push(shariah,'NADIBHD') array.push(shariah,'MGRC') array.push(shariah,'OCR') array.push(shariah,'PWRWELL') array.push(shariah,'BONIA') array.push(shariah,'PENTA') array.push(shariah,'EDUSPEC') array.push(shariah,'MALAKOF') array.push(shariah,'IHH') array.push(shariah,'CENGILD') array.push(shariah,'HARNLEN') array.push(shariah,'ACME') array.push(shariah,'SYF') array.push(shariah,'TWL-WD') array.push(shariah,'BSLCORP-WA') array.push(shariah,'GOB') array.push(shariah,'AJIYA') array.push(shariah,'DIGI') array.push(shariah,'PCHEM') array.push(shariah,'DPS') array.push(shariah,'LKL') array.push(shariah,'GBGAQRS') array.push(shariah,'SKBSHUT') array.push(shariah,'MAXIS') array.push(shariah,'MESB') array.push(shariah,'TASHIN') array.push(shariah,'MRDIY') array.push(shariah,'VELESTO') array.push(shariah,'MOBILIA-WA') array.push(shariah,'COMFORT-WB') array.push(shariah,'PESTECH') array.push(shariah,'MKLAND') array.push(shariah,'SOP') array.push(shariah,'MTRONIC-OR') array.push(shariah,'TITIJYA') array.push(shariah,'LCTITAN') array.push(shariah,'FITTERS') array.push(shariah,'RGTECH') array.push(shariah,'GPACKET-WB') array.push(shariah,'SCIENTX') array.push(shariah,'INNO') array.push(shariah,'AXTERIA') array.push(shariah,'KGB') array.push(shariah,'EPMB') array.push(shariah,'ECOWLD') array.push(shariah,'LUXCHEM') array.push(shariah,'EG') array.push(shariah,'HWATAI') array.push(shariah,'CCK') array.push(shariah,'OPTIMAX-WA') array.push(shariah,'PRIVA') array.push(shariah,'NOTION') array.push(shariah,'MSM') array.push(shariah,'SCOMNET') array.push(shariah,'AEON') array.push(shariah,'GFM') array.push(shariah,'GUH') array.push(shariah,'TAANN') array.push(shariah,'LIONIND') array.push(shariah,'HEVEA') array.push(shariah,'AME') array.push(shariah,'ECOMATE') array.push(shariah,'ATECH') array.push(shariah,'BIG') array.push(shariah,'LBALUM') array.push(shariah,'SLVEST') array.push(shariah,'VIZIONE-WE') array.push(shariah,'WTK') array.push(shariah,'KAB') array.push(shariah,'PA-WB') array.push(shariah,'DNONCE') array.push(shariah,'CGB') array.push(shariah,'ECOWLD-WB') array.push(shariah,'FM') array.push(shariah,'YB') array.push(shariah,'CHHB-WB') array.push(shariah,'GASMSIA') array.push(shariah,'LBS') array.push(shariah,'NICE') array.push(shariah,'GDEX') array.push(shariah,'CFM') array.push(shariah,'TECHBND') array.push(shariah,'POHKONG') array.push(shariah,'TALIWRK') array.push(shariah,'KSL') array.push(shariah,'SCNWOLF-WA') array.push(shariah,'JIANKUN') array.push(shariah,'CHINWEL') array.push(shariah,'TAMBUN') array.push(shariah,'CUSCAPI') array.push(shariah,'PWROOT') array.push(shariah,'HHHCORP') array.push(shariah,'FPGROUP') array.push(shariah,'EDARAN') array.push(shariah,'MISC') array.push(shariah,'PMBTECH') array.push(shariah,'LITRAK') array.push(shariah,'ANNUM') array.push(shariah,'KFIMA') array.push(shariah,'COMFORT') array.push(shariah,'TCS-WA') array.push(shariah,'GAMUDA') array.push(shariah,'L&G') array.push(shariah,'TEKSENG') array.push(shariah,'NCT') array.push(shariah,'KARYON') array.push(shariah,'KAB-WA') array.push(shariah,'MICROLN') array.push(shariah,'DRBHCOM') array.push(shariah,'HEXTAR') array.push(shariah,'SCGM') array.push(shariah,'CSCENIC') array.push(shariah,'TASCO') array.push(shariah,'EASTLND') array.push(shariah,'KPJ') array.push(shariah,'ZELAN') array.push(shariah,'RGTBHD-WB') array.push(shariah,'KGB-WB') array.push(shariah,'SERNKOU') array.push(shariah,'LAGENDA') array.push(shariah,'TECHNAX') array.push(shariah,'ECOFIRS-WD') array.push(shariah,'VIZIONE-WD') array.push(shariah,'WONG-WA') array.push(shariah,'CSCSTEL') array.push(shariah,'PANTECH') array.push(shariah,'SASBADI') array.push(shariah,'HOMERIZ') array.push(shariah,'MELEWAR') array.push(shariah,'BPURI-WA') array.push(shariah,'SERSOL') array.push(shariah,'SALCON') array.push(shariah,'CARIMIN') array.push(shariah,'OPENSYS') array.push(shariah,'CHHB') array.push(shariah,'AVI') array.push(shariah,'HONGSENG') array.push(shariah,'TOPBLDS') array.push(shariah,'MITRA') array.push(shariah,'ENGTEX-WB') array.push(shariah,'GDB') array.push(shariah,'AMEDIA') array.push(shariah,'SKPRES-WB') array.push(shariah,'FPI') array.push(shariah,'SKBSHUT-WA') array.push(shariah,'TOYOVEN-WB') array.push(shariah,'EWINT') array.push(shariah,'PBA') array.push(shariah,'TROP') array.push(shariah,'ESCERAM') array.push(shariah,'RL-WA') array.push(shariah,'ADVENTA') array.push(shariah,'AT-WC') array.push(shariah,'SEALINK') array.push(shariah,'GDB-WA') array.push(shariah,'VIS') array.push(shariah,'HUPSENG') array.push(shariah,'TM') array.push(shariah,'PUNCAK') array.push(shariah,'JCY') array.push(shariah,'POS') array.push(shariah,'JAKS-WC') array.push(shariah,'VIZIONE') array.push(shariah,'KANGER') array.push(shariah,'PIE') array.push(shariah,'HPMT') array.push(shariah,'VIS-WB') array.push(shariah,'BURSA') array.push(shariah,'GKENT') array.push(shariah,'BDB') array.push(shariah,'IVORY') array.push(shariah,'MERIDIAN-WC') array.push(shariah,'SAPNRG-WA') array.push(shariah,'SUNWAY') array.push(shariah,'MBL') array.push(shariah,'PEKAT') array.push(shariah,'TAKAFUL') array.push(shariah,'NGGB') array.push(shariah,'PRESTAR') array.push(shariah,'ABLEGLOB') array.push(shariah,'SCABLE') array.push(shariah,'SYSTECH') array.push(shariah,'ROHAS') array.push(shariah,'TOMYPAK') array.push(shariah,'SALUTE') array.push(shariah,'PARKSON') array.push(shariah,'GLOTEC') array.push(shariah,'MFCB') array.push(shariah,'INNATURE') array.push(shariah,'TGUAN') array.push(shariah,'RANHILL') array.push(shariah,'MAGNI') array.push(shariah,'FOCUSP') array.push(shariah,'SMETRIC') array.push(shariah,'3A') array.push(shariah,'KLK') array.push(shariah,'KRETAM') array.push(shariah,'SENHENG') array.push(shariah,'POHUAT') array.push(shariah,'XINHWA-WA') array.push(shariah,'BJFOOD') array.push(shariah,'PELIKAN') array.push(shariah,'HUAYANG') array.push(shariah,'MCT') array.push(shariah,'TMCLIFE') array.push(shariah,'SERSOL-WA') array.push(shariah,'QL') array.push(shariah,'MESB-WA') array.push(shariah,'EDEN') array.push(shariah,'GIIB') array.push(shariah,'TNLOGIS') array.push(shariah,'MINHO') array.push(shariah,'AWANTEC-WA') array.push(shariah,'CEKD') array.push(shariah,'HANDAL') array.push(shariah,'TIMECOM') array.push(shariah,'OPTIMAX') array.push(shariah,'PPHB') array.push(shariah,'SWKPLNT') array.push(shariah,'UNISEM') array.push(shariah,'VITROX') array.push(shariah,'SUPERLN') array.push(shariah,'GREENYB') array.push(shariah,'AGES') array.push(shariah,'HHGROUP-WA') array.push(shariah,'ARBB') array.push(shariah,'WELLCAL') array.push(shariah,'STAR') array.push(shariah,'KSSC') array.push(shariah,'HSPLANT') array.push(shariah,'SKPRES') array.push(shariah,'PGF') array.push(shariah,'GCB') array.push(shariah,'MCEMENT') array.push(shariah,'PHB') array.push(shariah,'SWSCAP-WB') array.push(shariah,'TELADAN') array.push(shariah,'ZHULIAN') array.push(shariah,'OMH') array.push(shariah,'SUCCESS') array.push(shariah,'PRTASCO') array.push(shariah,'PARAMON') array.push(shariah,'PARAMON') array.push(shariah,'PETGAS') array.push(shariah,'HIGHTEC') array.push(shariah,'PICORP') array.push(shariah,'MIECO') array.push(shariah,'OVH') array.push(shariah,'SOLUTN') array.push(shariah,'KPOWER-WA') array.push(shariah,'ADVCON') array.push(shariah,'UCHITEC') array.push(shariah,'TRIVE') array.push(shariah,'T7GLOBAL-WC') array.push(shariah,'EFORCE') array.push(shariah,'AAX') array.push(shariah,'AZRB') array.push(shariah,'UOADEV') array.push(shariah,'ESCERAM-WB') array.push(shariah,'WEGMANS-WC') array.push(shariah,'SMETRIC-WA') array.push(shariah,'MPI') array.push(shariah,'ANZO') array.push(shariah,'ASB') array.push(shariah,'ASTINO') array.push(shariah,'CWG') array.push(shariah,'PARAMON-WA') array.push(shariah,'LEONFB') array.push(shariah,'GCAP') array.push(shariah,'MBMR') array.push(shariah,'VC-WB') array.push(shariah,'HONGSENG-WB') array.push(shariah,'EDGENTA') array.push(shariah,'T7GLOBAL') array.push(shariah,'ASDION') array.push(shariah,'MFLOUR-WC') array.push(shariah,'FIHB') array.push(shariah,'LIIHEN') array.push(shariah,'KERJAYA') array.push(shariah,'MASTEEL-WB') array.push(shariah,'JKGLAND') array.push(shariah,'BPPLAS') array.push(shariah,'MHB') array.push(shariah,'ELSOFT') array.push(shariah,'PRLEXUS') array.push(shariah,'TOYOVEN') array.push(shariah,'KPPROP') array.push(shariah,'ACO') array.push(shariah,'ABLEGRP') array.push(shariah,'SUNCON') array.push(shariah,'ULICORP') array.push(shariah,'ENGTEX') array.push(shariah,'ENGTEX') array.push(shariah,'MALTON') array.push(shariah,'KAWAN') array.push(shariah,'EITA') array.push(shariah,'SBCCORP') array.push(shariah,'COMPUGT') array.push(shariah,'MCLEAN') array.push(shariah,'MENANG-WC') array.push(shariah,'WIDAD-WA') array.push(shariah,'LEESK') array.push(shariah,'THETA') array.push(shariah,'KUB') array.push(shariah,'SENDAI') array.push(shariah,'YGL') array.push(shariah,'MHC') array.push(shariah,'KEINHIN') array.push(shariah,'CHOOBEE') array.push(shariah,'INTA') array.push(shariah,'JAYCORP') array.push(shariah,'AXREIT') array.push(shariah,'NTPM') array.push(shariah,'SWSCAP') array.push(shariah,'SNC') array.push(shariah,'TELADAN-WA') array.push(shariah,'RESINTC') array.push(shariah,'TCS') array.push(shariah,'CHUAN') array.push(shariah,'SCGBHD') array.push(shariah,'SOLID') array.push(shariah,'NOVA') array.push(shariah,'VERTICE-WA') array.push(shariah,'TJSETIA') array.push(shariah,'KIMLUN') array.push(shariah,'ALAQAR') array.push(shariah,'MATRIX') array.push(shariah,'CBIP') array.push(shariah,'SAMAIDEN') array.push(shariah,'UTDPLT') array.push(shariah,'RCECAP') array.push(shariah,'K1') array.push(shariah,'BIMB') array.push(shariah,'PPB') array.push(shariah,'ARANK') array.push(shariah,'KMLOONG') array.push(shariah,'TRC') array.push(shariah,'MAXIM') array.push(shariah,'MTAG') array.push(shariah,'OCNCASH') array.push(shariah,'SYMLIFE') array.push(shariah,'CAMRES') array.push(shariah,'CAMRES') array.push(shariah,'PERDANA') array.push(shariah,'PESONA') array.push(shariah,'PARAGON') array.push(shariah,'BINACOM') array.push(shariah,'DPS-WB') array.push(shariah,'SLVEST-WA') array.push(shariah,'SALCON-WB') array.push(shariah,'BENALEC') array.push(shariah,'FIMACOR') array.push(shariah,'PTT') array.push(shariah,'GCB-WB') array.push(shariah,'GHLSYS') array.push(shariah,'BTM') array.push(shariah,'OCK-WB') array.push(shariah,'KOMARK') array.push(shariah,'CHINHIN') array.push(shariah,'KOMARK-WC') array.push(shariah,'SPRING') array.push(shariah,'AWC') array.push(shariah,'KHJB') array.push(shariah,'KMLOONG-WB') array.push(shariah,'PRLEXUS-WB') array.push(shariah,'MUDA') array.push(shariah,'PADINI') array.push(shariah,'N2N') array.push(shariah,'CHGP') array.push(shariah,'E&O') array.push(shariah,'SAM') array.push(shariah,'WOODLAN') array.push(shariah,'HOMERIZ-WB') array.push(shariah,'LOTUS') array.push(shariah,'SIGN') array.push(shariah,'XL-WA') array.push(shariah,'UMW') array.push(shariah,'ANEKA') array.push(shariah,'FLEXI') array.push(shariah,'HOHUP') array.push(shariah,'PWROOT-WA') array.push(shariah,'HPPHB') array.push(shariah,'F&N') array.push(shariah,'ECOHLDS') array.push(shariah,'VSTECS') array.push(shariah,'AHEALTH') array.push(shariah,'FAREAST') array.push(shariah,'PNEPCB') array.push(shariah,'RKI') array.push(shariah,'APB') array.push(shariah,'EUPE') array.push(shariah,'FSBM') array.push(shariah,'FSBM') array.push(shariah,'KANGER-WB') array.push(shariah,'SCOMNET-WA') array.push(shariah,'SNC-WB') array.push(shariah,'WATTA') array.push(shariah,'PENERGY') array.push(shariah,'MAGNA') array.push(shariah,'BOILERM') array.push(shariah,'INTA-WA') array.push(shariah,'CRESNDO') array.push(shariah,'HTPADU') array.push(shariah,'CAPITALA-LA') array.push(shariah,'BKAWAN') array.push(shariah,'HUBLINE') array.push(shariah,'CAELY') array.push(shariah,'EASTLND-WB') array.push(shariah,'PLENITU') array.push(shariah,'SAPIND') array.push(shariah,'GLOMAC') array.push(shariah,'PTARAS') array.push(shariah,'FAVCO') array.push(shariah,'KPS') array.push(shariah,'PETDAG') array.push(shariah,'SLP') array.push(shariah,'IQGROUP') array.push(shariah,'NAIM') array.push(shariah,'MCEHLDG') array.push(shariah,'FAJAR') array.push(shariah,'GENP') array.push(shariah,'TIMWELL') array.push(shariah,'KLCC') array.push(shariah,'SEB') array.push(shariah,'CABNET') array.push(shariah,'GMUTUAL') array.push(shariah,'HSSEB') array.push(shariah,'MMAG-WB') array.push(shariah,'N2N-WB') array.push(shariah,'OMESTI') array.push(shariah,'PASDEC') array.push(shariah,'SEG') array.push(shariah,'TEXCYCL') array.push(shariah,'VINVEST-WE') array.push(shariah,'PJBUMI') array.push(shariah,'SPRITZER') array.push(shariah,'BIPORT') array.push(shariah,'OKA') array.push(shariah,'MMSV') array.push(shariah,'AJI') array.push(shariah,'TOCEAN') array.push(shariah,'HLIND') array.push(shariah,'HLIND') array.push(shariah,'SCIENTX-WC') array.push(shariah,'SJC') array.push(shariah,'GPHAROS') array.push(shariah,'LIONPSIM') array.push(shariah,'SAB') array.push(shariah,'AWANTEC') array.push(shariah,'ANCOMNY-WB') array.push(shariah,'SENDAI-WA') array.push(shariah,'CRESBLD') array.push(shariah,'SURIA') array.push(shariah,'ENEST') array.push(shariah,'TRIMODE') array.push(shariah,'AMWAY') array.push(shariah,'CAELY-WB') array.push(shariah,'SHL') array.push(shariah,'TONGHER') array.push(shariah,'ITRONIC') array.push(shariah,'PESTECH-WA') array.push(shariah,'GLBHD') array.push(shariah,'PENSONI') array.push(shariah,'IBRACO') array.push(shariah,'GOPENG') array.push(shariah,'KEN') array.push(shariah,'SEAL') array.push(shariah,'SMRT') array.push(shariah,'KHIND') array.push(shariah,'GOLDETF') array.push(shariah,'NESTLE') array.push(shariah,'PDZ') array.push(shariah,'MKH') array.push(shariah,'TGL') array.push(shariah,'APOLLO') array.push(shariah,'EUROSP') array.push(shariah,'HOMERIZ-WC') array.push(shariah,'LYC') array.push(shariah,'UPA') array.push(shariah,'HAILY') array.push(shariah,'KESM') array.push(shariah,'KNUSFOR') array.push(shariah,'SCIB-WB') array.push(shariah,'BTECH') array.push(shariah,'CIHLDG') array.push(shariah,'DIN040000223') array.push(shariah,'MSNIAGA') array.push(shariah,'SDRED') array.push(shariah,'UMCCA') array.push(shariah,'XOXTECH') array.push(shariah,'CARZO') array.push(shariah,'IMASPRO') array.push(shariah,'WASEONG') array.push(shariah,'BLDPLNT') array.push(shariah,'DLADY') array.push(shariah,'IHS046000824') array.push(shariah,'ALSREIT') array.push(shariah,'APM') array.push(shariah,'DKLS') array.push(shariah,'MBL-WA') array.push(shariah,'METFSID') array.push(shariah,'MGB') array.push(shariah,'AASIA') array.push(shariah,'ACEINNO') array.push(shariah,'ACME-WA') array.push(shariah,'ADVPKG') array.push(shariah,'AEM') array.push(shariah,'AEM-WB') array.push(shariah,'AFUJIYA') array.push(shariah,'AIM') array.push(shariah,'ALRICH-WA') array.push(shariah,'AME-WA') array.push(shariah,'AMLEX') array.push(shariah,'AMTEL') array.push(shariah,'AMTEL-WA') array.push(shariah,'ANZO-WB') array.push(shariah,'AORB') array.push(shariah,'ARK') array.push(shariah,'ASIABRN') array.push(shariah,'ASIAPLY-PA') array.push(shariah,'ASIAPLY-WB') array.push(shariah,'ATTA') array.push(shariah,'ATTA-WC') array.push(shariah,'AURORA') array.push(shariah,'AWC-WA') array.push(shariah,'AXTERIA-WA') array.push(shariah,'AYER') array.push(shariah,'AZRB-WA') array.push(shariah,'BABA') array.push(shariah,'BAHVEST-WA') array.push(shariah,'BCB') array.push(shariah,'BERTAM') array.push(shariah,'BHIC') array.push(shariah,'BORNOIL-WC') array.push(shariah,'BORNOIL-WD') array.push(shariah,'BPPLAS-WA') array.push(shariah,'BTM-WB') array.push(shariah,'BVLH') array.push(shariah,'CEPCO') array.push(shariah,'CETECH') array.push(shariah,'CHGP-WA') array.push(shariah,'CHINA100-MYR') array.push(shariah,'CITAGLB-WA') array.push(shariah,'CITAGLB-WB') array.push(shariah,'CLOUD') array.push(shariah,'CME') array.push(shariah,'CME-WA') array.push(shariah,'CSCENIC-WA') array.push(shariah,'CVIEW') array.push(shariah,'CYL') array.push(shariah,'DBHD') array.push(shariah,'DFCITY') array.push(shariah,'DIN045801028') array.push(shariah,'DKSH') array.push(shariah,'DOMINAN') array.push(shariah,'DPHARMA') array.push(shariah,'EATECH') array.push(shariah,'ECONBHD-WA') array.push(shariah,'EDUSPEC-WB') array.push(shariah,'EIG') array.push(shariah,'EITA-WA') array.push(shariah,'EMETALL') array.push(shariah,'ENCORP') array.push(shariah,'ENGKAH') array.push(shariah,'ENGKAH-WB') array.push(shariah,'ENRA') array.push(shariah,'ENRA-WA') array.push(shariah,'ESAFE') array.push(shariah,'EWEIN') array.push(shariah,'EWEIN-WB') array.push(shariah,'FAJAR-WC') array.push(shariah,'FARLIM') array.push(shariah,'FBBHD') array.push(shariah,'FIHB-PA') array.push(shariah,'FIHB-PB') array.push(shariah,'G3-WA') array.push(shariah,'GBGAQRS-WB') array.push(shariah,'GDEX-WC') array.push(shariah,'GETS') array.push(shariah,'GIIB-WA') array.push(shariah,'GPP') array.push(shariah,'GUOCO') array.push(shariah,'HCK') array.push(shariah,'HCK-WA') array.push(shariah,'HIL-WB') array.push(shariah,'HONGSENG-WA') array.push(shariah,'HSSEB-WA') array.push(shariah,'HUBLINE-WC') array.push(shariah,'ICON-WA') array.push(shariah,'ICTZONE') array.push(shariah,'IDEAL') array.push(shariah,'INCKEN') array.push(shariah,'IQZAN') array.push(shariah,'IREKA') array.push(shariah,'JAKS-WB') array.push(shariah,'JISHAN') array.push(shariah,'KAMDAR') array.push(shariah,'KERJAYA-WB') array.push(shariah,'KGROUP-WC') array.push(shariah,'KIALIM') array.push(shariah,'KIMHIN') array.push(shariah,'KIMLUN-WA') array.push(shariah,'KKB') array.push(shariah,'KOTRA') array.push(shariah,'KPSCB') array.push(shariah,'KYM') array.push(shariah,'LBS-PA') array.push(shariah,'LEBTECH') array.push(shariah,'LFECORP') array.push(shariah,'LOTUS-WB') array.push(shariah,'LSH') array.push(shariah,'LSTEEL') array.push(shariah,'LTKM') array.push(shariah,'LYSAGHT') array.push(shariah,'MASTER') array.push(shariah,'MCOM') array.push(shariah,'MELATI') array.push(shariah,'MELEWAR-WB') array.push(shariah,'MENANG') array.push(shariah,'MENTIGA') array.push(shariah,'MERCURY') array.push(shariah,'METFUS50') array.push(shariah,'MFGROUP') array.push(shariah,'MHCARE') array.push(shariah,'MIKROMB') array.push(shariah,'MINETEC') array.push(shariah,'MITRA-WE') array.push(shariah,'MJPERAK') array.push(shariah,'MMAG') array.push(shariah,'MMIS') array.push(shariah,'MNC-WB') array.push(shariah,'MPCORP') array.push(shariah,'MPSOL') array.push(shariah,'MPSOL-WA') array.push(shariah,'MUH') array.push(shariah,'MUIPROP') array.push(shariah,'MYCRON-WA') array.push(shariah,'MYETFDJ') array.push(shariah,'MYETFID') array.push(shariah,'NEXGRAM-WB') array.push(shariah,'NEXGRAM-WC') array.push(shariah,'NEXGRAM-WD') array.push(shariah,'NHFATT') array.push(shariah,'NICE-WB') array.push(shariah,'NOTION-WC') array.push(shariah,'NPC') array.push(shariah,'NPS') array.push(shariah,'OCB') array.push(shariah,'OFI') array.push(shariah,'OIB') array.push(shariah,'OIB-WA') array.push(shariah,'OMESTI-WC') array.push(shariah,'ORNA') array.push(shariah,'OWG-WB') array.push(shariah,'PAOS') array.push(shariah,'PARKWD') array.push(shariah,'PASDEC-WA') array.push(shariah,'PASUKGB-WA') array.push(shariah,'PCCS') array.push(shariah,'PCCS-WA') array.push(shariah,'PDZ-WB') array.push(shariah,'PDZ-WC') array.push(shariah,'PEB') array.push(shariah,'PENSONI-WB') array.push(shariah,'PERMAJU-WA') array.push(shariah,'PERSTIM') array.push(shariah,'PGLOBE') array.push(shariah,'PHB-WB') array.push(shariah,'PJBUMI-WA') array.push(shariah,'PLB') array.push(shariah,'PLS') array.push(shariah,'PLS-WA') array.push(shariah,'PMBTECH-WA') array.push(shariah,'PMHLDG') array.push(shariah,'PNEPCB-WA') array.push(shariah,'PNEPCB-WB') array.push(shariah,'POLYDM') array.push(shariah,'PRTASCO-WA') array.push(shariah,'PUC-WA') array.push(shariah,'PWF') array.push(shariah,'QUALITY') array.push(shariah,'RALCO') array.push(shariah,'REX') array.push(shariah,'RGS') array.push(shariah,'RTSTECH') array.push(shariah,'RVIEW') array.push(shariah,'S&FCAP') array.push(shariah,'S&FCAP-WC') array.push(shariah,'SAMAIDEN-WA') array.push(shariah,'SAPNRG-PA') array.push(shariah,'SAPRES') array.push(shariah,'SAUDEE-WB') array.push(shariah,'SAUDEE-WB') array.push(shariah,'SCIPACK') array.push(shariah,'SCIPACK-WB') array.push(shariah,'SCOMI') array.push(shariah,'SCOMI-WB') array.push(shariah,'SEACERA') array.push(shariah,'SEEHUP') array.push(shariah,'SEERS') array.push(shariah,'SERNKOU-WA') array.push(shariah,'SGBHD') array.push(shariah,'SHH') array.push(shariah,'SJC-WA') array.push(shariah,'SLIC') array.push(shariah,'SMCAP') array.push(shariah,'SMCAP-WC') array.push(shariah,'SMILE') array.push(shariah,'SMILE-WA') array.push(shariah,'SMISCOR') array.push(shariah,'SPRING-WA') array.push(shariah,'SPSETIA-PA') array.push(shariah,'SPSETIA-PB') array.push(shariah,'STELLA') array.push(shariah,'SUNMOW') array.push(shariah,'SUNSURIA') array.push(shariah,'SUNWAY-WB') array.push(shariah,'SUPREME') array.push(shariah,'TAS') array.push(shariah,'TCHONG') array.push(shariah,'TECHBND-WA') array.push(shariah,'THHEAVY') array.push(shariah,'THRIVEN') array.push(shariah,'TITIJYA-PA') array.push(shariah,'TOPVISN') array.push(shariah,'TPC') array.push(shariah,'TRIVE-WC') array.push(shariah,'TSRCAP') array.push(shariah,'TURIYA') array.push(shariah,'UMS') array.push(shariah,'UMSNGB') array.push(shariah,'UNIMECH') array.push(shariah,'UNIWALL') array.push(shariah,'UTAMA') array.push(shariah,'VERSATL') array.push(shariah,'VOLCANO') array.push(shariah,'WAJA') array.push(shariah,'WANGZNG') array.push(shariah,'WARISAN') array.push(shariah,'WEGMANS') array.push(shariah,'WEGMANS-WB') array.push(shariah,'WTHORSE') array.push(shariah,'XINHWA') array.push(shariah,'Y&G') array.push(shariah,'YKGI') array.push(shariah,'YNHPROP') array.push(shariah,'YONGTAI-PA') array.push(shariah,'YSPSAH') array.push(shariah,'ZECON') //End of Code Required Frequent Update Referring to Bursa Malaysia Website.................................................... pn17_listed = array.includes(pn17_gn3, syminfo.ticker)? 1 : 0 pn17ctr = pn17_listed == 1 ? "PN17" : "" shariah_listed = array.includes(shariah, syminfo.ticker)? 1 : 0 shariahctr = shariah_listed == 1 ? "S" : "" var table t = table.new(_tablePos, 2, 1, border_width = 1) if (barstate.islast) table.cell(t, 0, 0, pn17_listed ? update_date:shariah_listed?update_date:"", width = 7, bgcolor = pn17_listed ? #FFFFFF : shariah_listed?#FFFFFF:na, text_color = #000000, text_size = _size) table.cell(t, 1, 0, pn17_listed ? pn17ctr : shariahctr, width = 4, bgcolor = pn17_listed ? #FF0000 : shariah_listed?#00B050:na, text_color = #FFFFFF, text_size = _size)
3rd Wave
https://www.tradingview.com/script/CP2aNLbk-3rd-Wave/
LonesomeTheBlue
https://www.tradingview.com/u/LonesomeTheBlue/
7,168
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © LonesomeTheBlue //@version=5 indicator('3rd Wave', overlay=true, max_bars_back=500, max_lines_count=500, max_labels_count=500) // import necessary functions to calculate and show the zigzag import LonesomeTheBlue/CreateAndShowZigzag/1 as ZigZag prd = input.int(defval=8, title='ZigZag Period', minval=2, maxval=50, group='setup') ret_rate_min = input.float(defval=0.382, title='Min/Max Retracements', minval=0.100, maxval=0.900, inline='retrate', group='setup') ret_rate_max = input.float(defval=0.786, title='', minval=0.100, maxval=0.900, inline='retrate', group='setup') checkvol_support = input.bool(defval=true, title='Check Volume Support', group='setup') target1_enb = input.bool(defval=true, title='Target 1', inline='t1', group='targets') target1_ret = input.float(defval=1., title='', inline='t1', group='targets', tooltip = "%X of wave 1 from the begining of wave 2") target2_enb = input.bool(defval=true, title='Target 2', inline='t2', group='targets') target2_ret = input.float(defval=1.618, title='', inline='t2', group='targets', tooltip = "%X of wave 1 from the begining of wave 2") target3_enb = input.bool(defval=false, title='Target 3', inline='t3', group='targets') target3_ret = input.float(defval=2.618, title='', inline='t3', group='targets', tooltip = "%X of wave 1 from the begining of wave 2") target4_enb = input.bool(defval=false, title='Target 4', inline='t4', group='targets') target4_ret = input.float(defval=3.618, title='', inline='t4', group='targets', tooltip = "%X of wave 1 from the begining of wave 2") showwave12 = input.bool(defval=true, title='Show Wave 1 and 2', group='colors') showbo = input.bool(defval=true, title='Zone', inline='bocol', group='colors') bupcol = input.color(defval=color.rgb(0, 255, 0, 85), title='', inline='bocol', group='colors') bdncol = input.color(defval=color.rgb(255, 0, 0, 85), title='', inline='bocol', group='colors') showzigzag = input.bool(defval=false, title='Zig Zag', inline='zzcol', group='colors') upcol = input.color(defval=color.lime, title='', inline='zzcol', group='colors') dncol = input.color(defval=color.red, title='', inline='zzcol', group='colors') // definitions for zigzag arrays var max_array_size = 10 // max length for zigzag array var zigzag = array.new_float(0) oldzigzag = array.copy(zigzag) // keep old zigzag // get the zigzag dir = ZigZag.getZigzag(zigzag, prd, max_array_size) // show the zigzag if showzigzag ZigZag.showZigzag(zigzag, oldzigzag, dir, upcol, dncol) int len = array.size(zigzag) >= 8 ? bar_index - math.round(array.get(zigzag, 7)) : 1 bool vol_support = (not checkvol_support or (checkvol_support and ta.linreg(volume, len, 0) - ta.linreg(volume, len, 1) > 0)) var bool can_check_it = true bool thereisbo = false if (dir != dir[1]) can_check_it := true can_check_it // check if there is possible 3rd wave and show breakout if there is any if array.size(zigzag) >= 8 and can_check_it w12 = math.abs(array.get(zigzag, 2) - array.get(zigzag, 4)) / math.abs(array.get(zigzag, 4) - array.get(zigzag, 6)) if w12 >= ret_rate_min and w12 <= ret_rate_max and (dir == 1 and high > array.get(zigzag, 4) or dir == -1 and low < array.get(zigzag, 4)) can_check_it := false if vol_support thereisbo := true // draw bo if showbo box.new(left=math.round(array.get(zigzag, 7)), top=array.get(zigzag, 4), right=bar_index, bottom=array.get(zigzag, 6), border_color=color.blue, border_width=1, border_style=line.style_dotted, bgcolor=dir == 1 ? bupcol : bdncol) if showwave12 line.new(x1=math.round(array.get(zigzag, 7)), y1=array.get(zigzag, 6), x2=math.round(array.get(zigzag, 5)), y2=array.get(zigzag, 4)) line.new(x1=math.round(array.get(zigzag, 5)), y1=array.get(zigzag, 4), x2=math.round(array.get(zigzag, 3)), y2=array.get(zigzag, 2)) label.new(x=math.round(array.get(zigzag, 7)), y=array.get(zigzag, 6), text='0', color=color.new(color.white, 100), textcolor=color.blue, style=dir == 1 ? label.style_label_up : label.style_label_down) label.new(x=math.round(array.get(zigzag, 5)), y=array.get(zigzag, 4), text='1', color=color.new(color.white, 100), textcolor=color.blue, style=dir == 1 ? label.style_label_down : label.style_label_up) label.new(x=math.round(array.get(zigzag, 3)), y=array.get(zigzag, 2), text='2', color=color.new(color.white, 100), textcolor=color.blue, style=dir == 1 ? label.style_label_up : label.style_label_down) // draw label label.new(x=bar_index, y=array.get(zigzag, 6), color=dir == 1 ? upcol : dncol, style=dir == 1 ? label.style_triangleup : label.style_triangledown, size=size.small) base = array.get(zigzag, 2) wave1 = math.abs(array.get(zigzag, 4) - array.get(zigzag, 6)) if target1_enb line.new(x1=bar_index, y1=math.max(base + dir * wave1 * target1_ret, 0), x2=math.round(array.get(zigzag, 7)), y2=math.max(base + dir * wave1 * target1_ret, 0), style=line.style_dashed) if target2_enb line.new(x1=bar_index, y1=math.max(base + dir * wave1 * target2_ret, 0), x2=math.round(array.get(zigzag, 7)), y2=math.max(base + dir * wave1 * target2_ret, 0), style=line.style_dashed) if target3_enb line.new(x1=bar_index, y1=math.max(base + dir * wave1 * target3_ret, 0), x2=math.round(array.get(zigzag, 7)), y2=math.max(base + dir * wave1 * target3_ret, 0), style=line.style_dashed) if target4_enb line.new(x1=bar_index, y1=math.max(base + dir * wave1 * target4_ret, 0), x2=math.round(array.get(zigzag, 7)), y2=math.max(base + dir * wave1 * target4_ret, 0), style=line.style_dashed) alertcondition(thereisbo and dir == 1, title = "Breakout Long", message = "Breakout Long") alertcondition(thereisbo and dir == -1, title = "Breakout Short", message = "Breakout Short")
BitMEX BTC Volatility Index
https://www.tradingview.com/script/P7JMdpLe-BitMEX-BTC-Volatility-Index/
BigPhilBxl
https://www.tradingview.com/u/BigPhilBxl/
42
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © BigPhilBxl //@version=5 indicator("BitMEX BTC Volatility Index") btc_volatility_symbol = input.symbol(title="BTC Volatility", defval="BVOL24H") btc_volatility = request.security(btc_volatility_symbol, timeframe=timeframe.period, expression=close) plot(btc_volatility, color=btc_volatility > 5 ? color.red : color.green, linewidth=2)
Exponential Regression From Arrays
https://www.tradingview.com/script/rYa88u09-Exponential-Regression-From-Arrays/
rumpypumpydumpy
https://www.tradingview.com/u/rumpypumpydumpy/
309
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © rumpypumpydumpy //@version=5 indicator('Exponential Regression', overlay = true, max_lines_count = 500) f_exponential_regression_from_arrays(_x_array, _price_array) => int _size_y = array.size(_price_array) int _size_x = array.size(_x_array) float[] _y_array = array.new_float(_size_y) for _i = 0 to _size_y - 1 array.set(_y_array, _i, math.log(array.get(_price_array, _i))) float _sum_x = array.sum(_x_array) float _sum_y = array.sum(_y_array) float _sum_xy = 0.0 float _sum_x2 = 0.0 float _sum_y2 = 0.0 if _size_y == _size_x for _i = 0 to _size_y - 1 float _x_i = nz(array.get(_x_array, _i)) float _y_i = nz(array.get(_y_array, _i)) _sum_xy := _sum_xy + _x_i * _y_i _sum_x2 := _sum_x2 + math.pow(_x_i, 2) _sum_y2 := _sum_y2 + math.pow(_y_i, 2) _sum_y2 float _a = (_sum_y * _sum_x2 - _sum_x * _sum_xy) / (_size_x * _sum_x2 - math.pow(_sum_x, 2)) float _b = (_size_x * _sum_xy - _sum_x * _sum_y) / (_size_x * _sum_x2 - math.pow(_sum_x, 2)) float[] _f = array.new_float() for _i = 0 to _size_y - 1 float _vector = _a + _b * array.get(_x_array, _i) array.push(_f, _vector) _slope = (array.get(_f, 0) - array.get(_f, _size_y - 1)) / (array.get(_x_array, 0) - array.get(_x_array, _size_x - 1)) _y_mean = array.avg(_y_array) float _SS_res = 0.0 float _SS_tot = 0.0 for _i = 0 to _size_y - 1 float _f_i = array.get(_f, _i) float _y_i = array.get(_y_array, _i) _SS_res := _SS_res + math.pow(_f_i - _y_i, 2) _SS_tot := _SS_tot + math.pow(_y_mean - _y_i, 2) _SS_tot _r_sq = 1 - _SS_res / _SS_tot float _sq_err_sum = 0 for _i = 0 to _size_y - 1 _sq_err_sum += math.pow(array.get(_f, _i) - array.get(_y_array, _i), 2) _dev = math.sqrt(_sq_err_sum / _size_y) [_f, _slope, _r_sq, _dev] src = input(close, title = "Source") n = input(100, title='Length') mult = input(1.000, title='dev mult') var float[] price_array = array.new_float(n) var int[] x_array = array.new_int(n) array.unshift(price_array, src) array.pop(price_array) array.unshift(x_array, bar_index) array.pop(x_array) var line[] reg_line_array = array.new_line() var line[] dev_up_line_array = array.new_line() var line[] dev_dn_line_array = array.new_line() var label r2_label = label.new(x = na, y = na, style = label.style_label_lower_left, color = #00000000, textcolor = color.blue, size=size.normal, textalign = text.align_left) float[] dev_up_array = array.new_float() float[] dev_dn_array = array.new_float() var int step = na var int line_n = na if barstate.isfirst line_n := math.min(n, 250) for i = 0 to line_n - 1 array.unshift(reg_line_array, line.new(x1=na, y1=na, x2=na, y2=na, color=color.red)) if n > 250 step := math.ceil(n / 250) else step := 1 for i = 0 to math.floor(line_n / 2) - 1 array.unshift(dev_up_line_array, line.new(x1=na, y1=na, x2=na, y2=na, color=color.blue)) array.unshift(dev_dn_line_array, line.new(x1=na, y1=na, x2=na, y2=na, color=color.blue)) if barstate.islast [predictions, slope, r_sq, dev] = f_exponential_regression_from_arrays(x_array, price_array) for i = 0 to array.size(predictions) - 1 array.push(dev_up_array, math.exp(array.get(predictions, i) + mult * dev)) array.push(dev_dn_array, math.exp(array.get(predictions, i) - mult * dev)) for i = 0 to array.size(predictions) - 2 - step by step line.set_xy1(array.get(reg_line_array, i / step), x=bar_index - i, y=math.exp(array.get(predictions, i))) line.set_xy2(array.get(reg_line_array, i / step), x=bar_index - i - step, y=math.exp(array.get(predictions, i + step))) for i = 0 to array.size(dev_up_array) - 2 - step by step * 2 line.set_xy1(array.get(dev_up_line_array, i / (step * 2)), x=bar_index - i, y=array.get(dev_up_array, i)) line.set_xy2(array.get(dev_up_line_array, i / (step * 2)), x=bar_index - i - step, y=array.get(dev_up_array, i + step)) line.set_xy1(array.get(dev_dn_line_array, i / (step * 2)), x=bar_index - i, y=array.get(dev_dn_array, i)) line.set_xy2(array.get(dev_dn_line_array, i / (step * 2)), x=bar_index - i - step, y=array.get(dev_dn_array, i + step)) label.set_xy(r2_label, x = bar_index + 1, y = array.get(dev_dn_array, 0)) label.set_text(r2_label, text = "R " + str.tostring(math.sqrt(r_sq)) + "\nR² " + str.tostring(r_sq))
Buying climax and Selling climax
https://www.tradingview.com/script/PJsnQ8ou-Buying-climax-and-Selling-climax/
Shauryam_or
https://www.tradingview.com/u/Shauryam_or/
294
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Shauryam_or //@YaheeSweety is writer of Boring and Explosive Candles - //@version=5 //Modified on 20180913 //Defining Title and Name of Pine Script indicator('buying climax and selling climax', overlay=true) rsi = ta.rsi(close, 14) //------------------------------------------------------------- // Script for Explosive Candles // Part 1: taking user input // Part 2: Defining Variable and performing calculation // Part 3: giving BLUE color to candle based on calculation mp = input(2.0, title='Multiplier for Explo.Mov.') ratio = input(50, title='Range-Body Ratio for Explo.Mov.') cand = input(100, title='Average Number of Candles for Explo.Mov.') range_1 = ta.atr(cand) candr = math.abs(high - low) bodyr = math.abs(open - close) prev = math.abs(high[1] - low[1]) nextabs = math.abs(high - low) explose = bodyr / candr >= ratio / 100 and candr >= range_1 * mp and volume > 2 * volume[3] and nextabs > 2 * prev barcolor(explose ? color.black : na, title='Explosive Move') var line l1 = na var line l2 = na price1 = high price2 = low dS1 = true if explose l1 := line.new(bar_index[1], price1, bar_index, price1, color=color.red, style=line.style_solid, width=1, extend=dS1 ? extend.right : extend.both) l2 := line.new(bar_index[1], price2, bar_index, price2, color=color.green, style=line.style_solid, width=1, extend=dS1 ? extend.right : extend.both) line.delete(l1[1]) line.delete(l2[1]) alertcondition(explose, "Climax bar", "New Climax Found")
log-log Regression From Arrays
https://www.tradingview.com/script/w8tf6FqM-log-log-Regression-From-Arrays/
rumpypumpydumpy
https://www.tradingview.com/u/rumpypumpydumpy/
1,011
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © rumpypumpydumpy //@version=5 indicator('log-log Regression', overlay = true, max_lines_count = 500) f_loglog_regression_from_arrays(_time_array, _price_array) => int _size_y = array.size(_price_array) int _size_x = array.size(_time_array) float[] _y_array = array.new_float(_size_y) float[] _x_array = array.new_float(_size_x) for _i = 0 to _size_y - 1 array.set(_y_array, _i, math.log(array.get(_price_array, _i))) array.set(_x_array, _i, math.log(array.get(_time_array, _i))) float _sum_x = array.sum(_x_array) float _sum_y = array.sum(_y_array) float _sum_xy = 0.0 float _sum_x2 = 0.0 float _sum_y2 = 0.0 if _size_y == _size_x for _i = 0 to _size_y - 1 float _x_i = nz(array.get(_x_array, _i)) float _y_i = nz(array.get(_y_array, _i)) _sum_xy := _sum_xy + _x_i * _y_i _sum_x2 := _sum_x2 + math.pow(_x_i, 2) _sum_y2 := _sum_y2 + math.pow(_y_i, 2) _sum_y2 float _a = (_sum_y * _sum_x2 - _sum_x * _sum_xy) / (_size_x * _sum_x2 - math.pow(_sum_x, 2)) float _b = (_size_x * _sum_xy - _sum_x * _sum_y) / (_size_x * _sum_x2 - math.pow(_sum_x, 2)) float[] _f = array.new_float() for _i = 0 to _size_y - 1 float _vector = _a + _b * array.get(_x_array, _i) array.push(_f, _vector) _slope = (array.get(_f, 0) - array.get(_f, _size_y - 1)) / (array.get(_x_array, 0) - array.get(_x_array, _size_x - 1)) _y_mean = array.avg(_y_array) float _SS_res = 0.0 float _SS_tot = 0.0 for _i = 0 to _size_y - 1 float _f_i = array.get(_f, _i) float _y_i = array.get(_y_array, _i) _SS_res := _SS_res + math.pow(_f_i - _y_i, 2) _SS_tot := _SS_tot + math.pow(_y_mean - _y_i, 2) _SS_tot _r_sq = 1 - _SS_res / _SS_tot float _sq_err_sum = 0 for _i = 0 to _size_y - 1 _sq_err_sum += math.pow(array.get(_f, _i) - array.get(_y_array, _i), 2) _dev = math.sqrt(_sq_err_sum / _size_y) [_f, _slope, _r_sq, _dev] src = input(close, title = "Source") n = input(100, title='Length') mult = input(1.000, title='dev mult') var float[] price_array = array.new_float(n) var int[] x_array = array.new_int(n) array.unshift(price_array, src) array.pop(price_array) array.unshift(x_array, bar_index) array.pop(x_array) var line[] reg_line_array = array.new_line() var line[] dev_up_line_array = array.new_line() var line[] dev_dn_line_array = array.new_line() var label r2_label = label.new(x = na, y = na, style = label.style_label_lower_left, color = #00000000, textcolor = color.blue, size=size.normal, textalign = text.align_left) float[] dev_up_array = array.new_float() float[] dev_dn_array = array.new_float() var int step = na var int line_n = na if barstate.isfirst line_n := math.min(n, 250) for i = 0 to line_n - 1 array.unshift(reg_line_array, line.new(x1=na, y1=na, x2=na, y2=na, color=color.red)) if n > 250 step := math.ceil(n / 250) else step := 1 for i = 0 to math.floor(line_n / 2) - 1 array.unshift(dev_up_line_array, line.new(x1=na, y1=na, x2=na, y2=na, color=color.blue)) array.unshift(dev_dn_line_array, line.new(x1=na, y1=na, x2=na, y2=na, color=color.blue)) if barstate.islast [predictions, slope, r_sq, dev] = f_loglog_regression_from_arrays(x_array, price_array) for i = 0 to array.size(predictions) - 1 array.push(dev_up_array, math.exp(array.get(predictions, i) + mult * dev)) array.push(dev_dn_array, math.exp(array.get(predictions, i) - mult * dev)) for i = 0 to array.size(predictions) - 2 - step by step line.set_xy1(array.get(reg_line_array, i / step), x=bar_index - i, y=math.exp(array.get(predictions, i))) line.set_xy2(array.get(reg_line_array, i / step), x=bar_index - i - step, y=math.exp(array.get(predictions, i + step))) for i = 0 to array.size(dev_up_array) - 2 - step by step * 2 line.set_xy1(array.get(dev_up_line_array, i / (step * 2)), x=bar_index - i, y=array.get(dev_up_array, i)) line.set_xy2(array.get(dev_up_line_array, i / (step * 2)), x=bar_index - i - step, y=array.get(dev_up_array, i + step)) line.set_xy1(array.get(dev_dn_line_array, i / (step * 2)), x=bar_index - i, y=array.get(dev_dn_array, i)) line.set_xy2(array.get(dev_dn_line_array, i / (step * 2)), x=bar_index - i - step, y=array.get(dev_dn_array, i + step)) label.set_xy(r2_label, x = bar_index + 1, y = array.get(dev_dn_array, 0)) label.set_text(r2_label, text = "R " + str.tostring(math.sqrt(r_sq)) + "\nR² " + str.tostring(r_sq))
Kaufman's Efficiency Ratio Indicator
https://www.tradingview.com/script/j9hCD2lP-Kaufman-s-Efficiency-Ratio-Indicator/
DojiEmoji
https://www.tradingview.com/u/DojiEmoji/
104
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © DojiEmoji //@version=5 indicator("Kaufman's ER", overlay=false) kaufman_ER(src, len) => // { float total_abs_chng = 0 // [B] for i = 1 to len by 1 total_abs_chng += math.abs(src[i - 1] - src[i]) total_abs_chng float net_chng = src - src[len] // [A] float er = net_chng / total_abs_chng * 100 // = ([A]/[B]) * 100 er // } bool is_dir = input(true, title="Directional") period = input(10, title="Lookback period") ER = is_dir ? kaufman_ER(close, period) : math.abs(kaufman_ER(close, period)) // Modes var string MODE_STATIC = 'Static threshold' var string MODE_DYNAMIC = 'Dynamic threshold' var string mode = input.string(title='If checked above: Presets', defval=MODE_STATIC, options=[MODE_STATIC, MODE_DYNAMIC]) // Static mode int static_low = input.int(25, minval=0, maxval=100, title="Threshold for low", group="Static mode") int static_high = input.int(50, minval=0, maxval=100, title="Threshold for high", group="Static mode") var color color_low = input.color(color.new(color.green, 0),title="Color (low)", group="Static mode") var color color_mid = input.color(color.new(color.yellow , 0),title="Color (mid)", group="Static mode") var color color_high = input.color(color.new(color.red, 0),title="Color (high)", group="Static mode") // // Dynamic mode float ER_bar = ta.sma(math.abs(ER), period) float ER_sigma = ta.stdev(math.abs(ER), period) float ER_sigma_mult = input.float(0.5, 'Dynamic mode: stdev multiplier', step=0.1, group="Dynamic mode") float dynamic_low = ER_bar - ER_sigma * ER_sigma_mult float dynamic_high = ER_bar + ER_sigma * ER_sigma_mult // bool is_low = na bool is_mid = na bool is_high = na if mode == MODE_STATIC is_low := math.abs(ER) <= static_low is_mid := math.abs(ER) >= static_low and math.abs(ER) < static_high is_high := math.abs(ER) >= static_high else if mode == MODE_DYNAMIC is_low := math.abs(ER) <= dynamic_low is_mid := math.abs(ER) >= dynamic_low and math.abs(ER) < dynamic_high is_high := math.abs(ER) >= dynamic_high hline(static_high, linestyle=hline.style_dashed, title="High", color=color.new(color.gray, 50), editable=true) hline(static_low, linestyle=hline.style_dashed, title="low", color=color.new(color.gray, 50), editable=true) var int coeff = is_dir ? -1 : 1 hline(coeff*static_high, linestyle=hline.style_dashed, title="High", color=color.new(color.gray, 50), editable=true) hline(coeff*static_low, linestyle=hline.style_dashed, title="low", color=color.new(color.gray, 50), editable=true) p0 = plot(0, color=color.new(color.gray, 0), title="Zeroline") p1 = plot(ER, "Efficiency ratio", color=is_high ? color_high : is_mid ? color_mid : color_low, style=plot.style_columns)
PROFIT INDICATOR
https://www.tradingview.com/script/2zYguVlj-PROFIT-INDICATOR/
dhawal123
https://www.tradingview.com/u/dhawal123/
289
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © MANNU //@version=4 study(title="MANNU MATRIX", shorttitle="MANNU MATRIX", overlay=true) showpivot = input(defval = false, title="Show CPR") showVWAP = input(title="Show VWAP", type=input.bool, defval=false) showEMA20 = input(title="Show EMA-20", type=input.bool, defval=false) showEMA50 = input(title="Show EMA-50", type=input.bool, defval=false) showEMA200 = input(title="Show EMA-200", type=input.bool, defval=false) showSMA50 = input(title="Show SMA-50", type=input.bool, defval=false) showSMA200 = input(title="Show SMA-200", type=input.bool, defval=false) showBB = input(title="Show BB", type=input.bool, defval=false) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////// EMA - 5/20/50/100/200 /////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// EMA20_Len = input(20, minval=1, title="EMA20_Length") //EMA20_src = input(close, title="EMA20_Source") //EMA20_offset = input(title="EMA20_Offset", type=input.integer, defval=0, minval=-500, maxval=500) EMA20_out = ema(close, EMA20_Len) plot(showEMA20 ? EMA20_out:na, title="EMA20", color=color.red, offset=0,linewidth=2) EMA50_Len = input(50, minval=1, title="EMA50_Length") //EMA50_src = input(close, title="EMA50_Source") //EMA50_offset = input(title="EMA50_Offset", type=input.integer, defval=0, minval=-500, maxval=500) EMA50_out = ema(close, EMA50_Len) plot(showEMA50 ? EMA50_out:na, title="EMA50", color=color.blue, offset=0,linewidth=2) EMA200_Len = input(200, minval=1, title="EMA200_Length") //EMA200_src = input(close, title="EMA200_Source") //EMA200_offset = input(title="EMA200_Offset", type=input.integer, defval=0, minval=-500, maxval=500) EMA200_out = ema(close, EMA200_Len) plot(showEMA200 ? EMA200_out:na, title="EMA200", color=color.yellow, offset=0,linewidth=2) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////// SMA - 9/20/50/100/200 /////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// SMA50_Len = input(50, minval=1, title="SMA50_Length") //SMA50_src = input(close, title="SMA50_Source") //SMA50_offset = input(title="SMA50_Offset", type=input.integer, defval=0, minval=-500, maxval=500) SMA50_out = sma(close, SMA50_Len) plot(showSMA50 ? SMA50_out:na, title="SMA50", color=color.maroon, offset=0,linewidth=2) SMA200_Len = input(200, minval=1, title="SMA200_Length") //SMA200_src = input(close, title="SMA200_Source") //SMA200_offset = input(title="SMA200_Offset", type=input.integer, defval=0, minval=-500, maxval=500) SMA200_out = sma(close, SMA200_Len) plot(showSMA200 ? SMA200_out:na, title="SMA200", color=color.aqua, offset=0,linewidth=2) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////// VWAP ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //vwaplength = input(title="VWAP Length", type=input.integer, defval=1) //cvwap = ema(vwap,vwaplength) cvwap1 = vwap(hlc3) plotvwap = plot(showVWAP ? cvwap1 : na,title="VWAP",color=color.black, transp=0, linewidth=2) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////// CENTRAL PIVOT RANGE (CPR) ////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// res = input(title="Resolution", type=input.resolution, defval="D") res1 = input(title="Resolution", type=input.resolution, defval="W") res2 = input(title="Resolution", type=input.resolution, defval="M") H = security(syminfo.tickerid, res, high[1], barmerge.gaps_off, barmerge.lookahead_on) L = security(syminfo.tickerid, res, low[1], barmerge.gaps_off, barmerge.lookahead_on) C = security(syminfo.tickerid, res, close[1], barmerge.gaps_off, barmerge.lookahead_on) WH = security(syminfo.tickerid, res1, high[1], barmerge.gaps_off, barmerge.lookahead_on) WL = security(syminfo.tickerid, res1, low[1], barmerge.gaps_off, barmerge.lookahead_on) WC = security(syminfo.tickerid, res1, close[1], barmerge.gaps_off, barmerge.lookahead_on) MH = security(syminfo.tickerid, res2, high[1], barmerge.gaps_off, barmerge.lookahead_on) ML = security(syminfo.tickerid, res2, low[1], barmerge.gaps_off, barmerge.lookahead_on) MC = security(syminfo.tickerid, res2, close[1], barmerge.gaps_off, barmerge.lookahead_on) TTH = security(syminfo.tickerid, res, high, barmerge.gaps_off, barmerge.lookahead_on) TTL = security(syminfo.tickerid, res, low, barmerge.gaps_off, barmerge.lookahead_on) TTC = security(syminfo.tickerid, res, close, barmerge.gaps_off, barmerge.lookahead_on) PP = (H + L + C) / 3 TC = (H + L)/2 BC = (PP - TC) + PP R1 = (PP * 2) - L R2 = PP + (H - L) R3 = H + 2*(PP - L) R4 = PP * 3 + (H - 3 * L) S1 = (PP * 2) - H S2 = PP - (H - L) S3 = L - 2*(H - PP) S4 = PP*3 - (3*H - L) WPP = (WH + WL + WC)/3 WTC = (WH + WL)/2 WBC = (WPP - WTC) + WPP MPP = (MH + ML + MC)/3 MTC = (MH + ML)/2 MBC = (MPP - MTC) + MPP TOPP = (TTH + TTL + TTC)/3 TOTC = (TTH + TTL)/2 TOBC = (TOPP - TOTC) + TOPP TR1 = (TOPP * 2) - TTL TR2 = TOPP + (TTH - TTL) TS1 = (TOPP * 2) - TTH TS2 = TOPP - (TTH - TTL) plot(showpivot ? PP : na, title="PP", style=plot.style_stepline, color=color.blue, linewidth=2) plot(showpivot ? TC : na, title="TC", style=plot.style_circles, color=color.blue, linewidth=1) plot(showpivot ? BC : na, title="BC", style=plot.style_circles, color=color.blue, linewidth=1) plot(showpivot ? WPP : na, title="WPP", style=plot.style_stepline, color=color.black, linewidth=2) plot(showpivot ? WTC : na, title="WTC", style=plot.style_stepline, color=color.black, linewidth=2) plot(showpivot ? WBC : na, title="WBC", style=plot.style_stepline, color=color.black, linewidth=2) plot(showpivot ? MPP : na, title="MPP", style=plot.style_stepline, color=color.black, linewidth=2) plot(showpivot ? MTC : na, title="MTC", style=plot.style_stepline, color=color.black, linewidth=2) plot(showpivot ? MBC : na, title="MBC", style=plot.style_stepline, color=color.black, linewidth=2) plot(showpivot ? S1 : na, title="S1", style=plot.style_stepline, color=color.green, linewidth=1) plot(showpivot ? S2 : na, title="S2", style=plot.style_stepline, color=color.green, linewidth=1) plot(showpivot ? S3 : na, title="S3", style=plot.style_stepline, color=color.green, linewidth=1) plot(showpivot ? S4 : na, title="S4", style=plot.style_stepline, color=color.green, linewidth=1) plot(showpivot ? R1 : na, title="R1", style=plot.style_stepline, color=color.red, linewidth=1) plot(showpivot ? R2 : na, title="R2", style=plot.style_stepline, color=color.red, linewidth=1) plot(showpivot ? R3 : na, title="R3", style=plot.style_stepline, color=color.red, linewidth=1) plot(showpivot ? R4 : na, title="R4", style=plot.style_stepline, color=color.red, linewidth=1) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////// PREVIOUS DAY ///////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// prevDayHigh = security(syminfo.tickerid, 'D', high[1], lookahead=true) prevDayLow = security(syminfo.tickerid, 'D', low[1], lookahead=true) plot( showpivot and prevDayHigh ? prevDayHigh : na, title="Prev Day High", style=plot.style_circles, linewidth=2, color=color.red, transp=0) plot( showpivot and prevDayLow ? prevDayLow : na, title="Prev Day Low", style=plot.style_circles, linewidth=2, color=color.green, transp=0) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////// PREVIOUS WEEKLY /////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// prevWeekHigh = security(syminfo.tickerid, 'W', high[1], lookahead=true) prevWeekLow = security(syminfo.tickerid, 'W', low[1], lookahead=true) plot( showpivot and prevWeekHigh ? prevWeekHigh : na, title="Prev Week High", style=plot.style_stepline, linewidth=2, color=color.red, transp=0) plot( showpivot and prevWeekLow ? prevWeekLow : na, title="Prev Week Low", style=plot.style_stepline, linewidth=2, color=color.green, transp=0) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////// PREVIOUS MONTH ///////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// prevMonthHigh = security(syminfo.tickerid, 'M', high[1], lookahead=true) prevMonthLow = security(syminfo.tickerid, 'M', low[1], lookahead=true) plot( showpivot and prevMonthHigh ? prevMonthHigh : na, title="Prev Month High", style=plot.style_stepline, linewidth=2, color=color.red, transp=0) plot( showpivot and prevMonthLow ? prevMonthLow : na, title="Prev Month Low", style=plot.style_stepline, linewidth=2, color=color.green, transp=0) //HAlftrend amplitude = input(title="Amplitude", defval=3) channelDeviation = input(title="Channel Deviation", defval=2) showArrows = input(title="Show Arrows", defval=true) showChannels = input(title="Show Channels", defval=false) var int trend1 = 0 var int nextTrend = 0 var float maxLowPrice = nz(low[1], low) var float minHighPrice = nz(high[1], high) var float up = 0.0 var float down = 0.0 float atrHigh = 0.0 float atrLow = 0.0 float arrowUp = na float arrowDown = na atr2 = atr(100) / 2 dev1 = channelDeviation * atr2 highPrice = high[abs(highestbars(amplitude))] lowPrice = low[abs(lowestbars(amplitude))] highma = sma(high, amplitude) lowma = sma(low, amplitude) if nextTrend == 1 maxLowPrice := max(lowPrice, maxLowPrice) if highma < maxLowPrice and close < nz(low[1], low) trend1 := 1 nextTrend := 0 minHighPrice := highPrice else minHighPrice := min(highPrice, minHighPrice) if lowma > minHighPrice and close > nz(high[1], high) trend1 := 0 nextTrend := 1 maxLowPrice := lowPrice if trend1 == 0 if not na(trend1[1]) and trend1[1] != 0 up := na(down[1]) ? down : down[1] arrowUp := up - atr2 else up := na(up[1]) ? maxLowPrice : max(maxLowPrice, up[1]) atrHigh := up + dev1 atrLow := up - dev1 else if not na(trend1[1]) and trend1[1] != 1 down := na(up[1]) ? up : up[1] arrowDown := down + atr2 else down := na(down[1]) ? minHighPrice : min(minHighPrice, down[1]) atrHigh := down + dev1 atrLow := down - dev1 ht = trend1 == 0 ? up : down var color buyColor = color.green var color sellColor = color.red htColor = trend1 == 0 ? buyColor : sellColor htPlot = plot(ht, title="HalfTrend", linewidth=2, color=htColor) //atrHighPlot = plot(showChannels ? atrHigh : na, title="ATR High", style=plot.style_circles, color=sellColor) //atrLowPlot = plot(showChannels ? atrLow : na, title="ATR Low", style=plot.style_circles, color=buyColor) //fill(htPlot, atrHighPlot, title="ATR High Ribbon", color=sellColor) //fill(htPlot, atrLowPlot, title="ATR Low Ribbon", color=buyColor) buySignal = not na(arrowUp) and (trend1 == 0 and trend1[1] == 1) sellSignal = not na(arrowDown) and (trend1 == 1 and trend1[1] == 0) plotshape(showArrows and buySignal ? atrLow : na, title="Arrow Up" ,text="Buy" , style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, location=location.absolute, size=size.small,color=buyColor) //plotshape(showArrows and sellSignal ? atrHigh : na, title="Arrow Down", style=shape.triangledown, location=location.absolute, size=size.tiny, color=sellColor) plotshape(showArrows and sellSignal ? atrHigh : na, title="Arrow Down",text="Sell", size=size.tiny, color=color.red, textcolor=color.white,style=shape.labeldown , location=location.absolute, size=size.small, color=sellColor) alertcondition(buySignal, title="Alert: Buy", message="Buy") alertcondition(sellSignal, title="Alert: Sell", message="Sell") ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////// BOLLINGER BANDS///////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// length1 = 20 //input(20, minval=1) src1 = close //input(close, title="BB_Source") mult = 2 //input(2.0, minval=0.001, maxval=50, title="BB_StdDev") basis = sma(src1, length1) dev = mult * stdev(src1, length1) upper = basis + dev lower = basis - dev p1 = plot(showBB ? upper : na, "Upper", color=color.red, editable=true) p2 = plot(showBB ? lower: na, "Lower", color=color.green, editable=true) plot(showBB ? basis : na, "Basis", color=#872323, editable=true) fill(p1, p2, title = "Background", color=#198787, transp=95) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////// FIB LEVELS ///////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Fib levels //------------------------------------------------------------------------------ extendType =input(true, title="Extend lines?") ? extend.right : extend.none show_price =input(true, title="show price?") Reverse =input(false, title="Reverse Direction?") //------------------------------------------------------------------------------ FPeriod = input(100, title="lookback length") Fhigh = highest(FPeriod) Flow = lowest(FPeriod) SwingHigh = highestbars(high, FPeriod) SwingLow = lowestbars(low, FPeriod) downfib = Reverse ? SwingHigh > SwingLow : SwingHigh < SwingLow X1_offset = downfib ? SwingHigh : SwingLow X2_offset =15 bar_index_duration = time - time[1] // time between bars X1 = X1_offset * bar_index_duration // starting level x position X2 = X2_offset * bar_index_duration // ending level x position lbl_X2 = ((show_price ? 15 : 6) + X2_offset) * bar_index_duration // label x position F000 =downfib ? Flow : Fhigh F236 =downfib ? (Fhigh-Flow) * 0.236 + Flow : Fhigh - (Fhigh-Flow) * 0.236 F382 =downfib ? (Fhigh-Flow) * 0.382 + Flow : Fhigh - (Fhigh-Flow) * 0.382 F500 =downfib ? (Fhigh-Flow) * 0.500 + Flow : Fhigh - (Fhigh-Flow) * 0.500 F618 =downfib ? (Fhigh-Flow) * 0.618 + Flow : Fhigh - (Fhigh-Flow) * 0.618 F786 =downfib ? (Fhigh-Flow) * 0.786 + Flow : Fhigh - (Fhigh-Flow) * 0.786 F100 =downfib ? Fhigh : Flow F000_color =color.new(color.orange,0) F236_color =color.new(color.orange,0) F382_color =color.new(color.orange,0) F500_color =color.new(color.orange,0) F618_color =color.new(color.orange,0) F786_color =color.new(color.orange,0) F100_color =color.new(color.orange,0) F000_lbl =show_price ? "0% [" + tostring(F000) + " ]" : "0%" F236_lbl =show_price ? "23.6% [" + tostring(F236) + " ]" : "23.6%" F382_lbl =show_price ? "38.2% [" + tostring(F382) + " ]" : "38.2%" F500_lbl =show_price ? "50% [" + tostring(F500) + " ]" : "50%" F618_lbl =show_price ? "61.8% [" + tostring(F618) + " ]" : "61.8%" F786_lbl =show_price ? "78.6% [" + tostring(F786) + " ]" : "78.6%" F100_lbl =show_price ? "100% [" + tostring(F100) + " ]" : "100%" //------------------------------------------------------------------------------ //Setup line & Label Appearance line_style =line.style_solid label_style =label.style_none label_size =size.normal //------------------------------------------------------------------------------ // 0 line if true ln = line.new( x1 = time + X1, y1 = F000, x2 = time + X2, y2 = F000, xloc =xloc.bar_time, extend =extendType, color =F000_color, style =line_style, width =1 ) line.delete(ln[1]) if true lbl = label.new( x =time + lbl_X2, y =F000, xloc =xloc.bar_time, yloc =yloc.price, text =F000_lbl, color =F000_color, textcolor =F000_color, style =label_style, size =label_size ) label.delete(lbl[1]) //------------------------------------------------------------------------------ //236 line if true ln = line.new( x1 = time + X1, y1 = F236, x2 = time + X2, y2 = F236, xloc =xloc.bar_time, extend =extendType, color =F236_color, style =line_style, width =1 ) line.delete(ln[1]) if true lbl = label.new( x =time + lbl_X2, y =F236, xloc =xloc.bar_time, yloc =yloc.price, text =F236_lbl, color =F236_color, textcolor =F236_color, style =label_style, size =label_size ) label.delete(lbl[1]) //------------------------------------------------------------------------------ // 382 line if true ln = line.new( x1 = time + X1, y1 = F382, x2 = time + X2, y2 = F382, xloc =xloc.bar_time, extend =extendType, color =F382_color, style =line_style, width =1 ) line.delete(ln[1]) if true lbl = label.new( x =time + lbl_X2, y =F382, xloc =xloc.bar_time, yloc =yloc.price, text =F382_lbl, color =F382_color, textcolor =F382_color, style =label_style, size =label_size ) label.delete(lbl[1]) //------------------------------------------------------------------------------ //500 line if true ln = line.new( x1 = time + X1, y1 = F500, x2 = time + X2, y2 = F500, xloc =xloc.bar_time, extend =extendType, color =F500_color, style =line_style, width =1 ) line.delete(ln[1]) if true lbl = label.new( x =time + lbl_X2, y =F500, xloc =xloc.bar_time, yloc =yloc.price, text =F500_lbl, color =F500_color, textcolor =F500_color, style =label_style, size =label_size ) label.delete(lbl[1]) //------------------------------------------------------------------------------ //618 line if true ln = line.new( x1 = time + X1, y1 = F618, x2 = time + X2, y2 = F618, xloc =xloc.bar_time, extend =extendType, color =F618_color, style =line_style, width =1 ) line.delete(ln[1]) if true lbl = label.new( x =time + lbl_X2, y =F618, xloc =xloc.bar_time, yloc =yloc.price, text =F618_lbl, color =F618_color, textcolor =F618_color, style =label_style, size =label_size ) label.delete(lbl[1]) //------------------------------------------------------------------------------ //786 line if true ln = line.new( x1 = time + X1, y1 = F786, x2 = time + X2, y2 = F786, xloc =xloc.bar_time, extend =extendType, color =F786_color, style =line_style, width =1 ) line.delete(ln[1]) if true lbl = label.new( x =time + lbl_X2, y =F786, xloc =xloc.bar_time, yloc =yloc.price, text =F786_lbl, color =F786_color, textcolor =F786_color, style =label_style, size =label_size ) label.delete(lbl[1]) //------------------------------------------------------------------------------ //100 line if true ln = line.new( x1 = time + X1, y1 = F100, x2 = time + X2, y2 = F100, xloc =xloc.bar_time, extend =extendType, color =F100_color, style =line_style, width =1 ) line.delete(ln[1]) if true lbl = label.new( x =time + lbl_X2, y =F100, xloc =xloc.bar_time, yloc =yloc.price, text =F100_lbl, color =F100_color, textcolor =F100_color, style =label_style, size =label_size ) label.delete(lbl[1]) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////// Multiple HMA//////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //inputs src=close useCurrentRes = input(true, title="Use Current Chart Resolution?") resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=input.resolution, defval="D") len = input(33, title="Moving Average Length - LookBack Period") //periodT3 = input(defval=7, title="Tilson T3 Period", minval=1) factorT3 = input(defval=7, title="Tilson T3 Factor - *.10 - so 7 = .7 etc.", minval=0) atype = input(4,minval=1,maxval=8,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA, 6=RMA, 7=TEMA, 8=Tilson T3") spc=input(false, title="Show Price Crossing 1st Mov Avg - Highlight Bar?") cc = input(true,title="Change Color Based On Direction?") smoothe = input(2, minval=1, maxval=10, title="Color Smoothing - Setting 1 = No Smoothing") doma2 = input(false, title="Optional 2nd Moving Average") spc2=input(false, title="Show Price Crossing 2nd Mov Avg?") len2 = input(50, title="Moving Average Length - Optional 2nd MA") sfactorT3 = input(defval=7, title="Tilson T3 Factor - *.10 - so 7 = .7 etc.", minval=0) atype2 = input(1,minval=1,maxval=8,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA, 6=RMA, 7=TEMA, 8=Tilson T3") cc2 = input(true,title="Change Color Based On Direction 2nd MA?") warn = input(false, title="***You Can Turn On The Show Dots Parameter Below Without Plotting 2nd MA to See Crosses***") warn2 = input(false, title="***If Using Cross Feature W/O Plotting 2ndMA - Make Sure 2ndMA Parameters are Set Correctly***") sd = input(false, title="Show Dots on Cross of Both MA's") res_MHMA = useCurrentRes ? timeframe.period : resCustom //hull ma definition hullma = wma(2*wma(src, len/2)-wma(src, len), round(sqrt(len))) //TEMA definition ema1 = ema(src, len) ema2 = ema(ema1, len) ema3 = ema(ema2, len) tema = 3 * (ema1 - ema2) + ema3 //Tilson T3 factor = factorT3 *.10 gd(src, len, factor) => ema(src, len) * (1 + factor) - ema(ema(src, len), len) * factor t3(src, len, factor) => gd(gd(gd(src, len, factor), len, factor), len, factor) tilT3 = t3(src, len, factor) avg = atype == 1 ? sma(src,len) : atype == 2 ? ema(src,len) : atype == 3 ? wma(src,len) : atype == 4 ? hullma : atype == 5 ? vwma(src, len) : atype == 6 ? rma(src,len) : atype == 7 ? 3 * (ema1 - ema2) + ema3 : tilT3 //2nd Ma - hull ma definition hullma2 = wma(2*wma(src, len2/2)-wma(src, len2), round(sqrt(len2))) //2nd MA TEMA definition sema1 = ema(src, len2) sema2 = ema(sema1, len2) sema3 = ema(sema2, len2) stema = 3 * (sema1 - sema2) + sema3 //2nd MA Tilson T3 sfactor = sfactorT3 *.10 sgd(src, len2, sfactor) => ema(src, len2) * (1 + sfactor) - ema(ema(src, len2), len2) * sfactor st3(src, len2, sfactor) => sgd(sgd(gd(src, len2, sfactor), len2, sfactor), len2, sfactor) stilT3 = st3(src, len2, sfactor) avg2 = atype2 == 1 ? sma(src,len2) : atype2 == 2 ? ema(src,len2) : atype2 == 3 ? wma(src,len2) : atype2 == 4 ? hullma2 : atype2 == 5 ? vwma(src, len2) : atype2 == 6 ? rma(src,len2) : atype2 == 7 ? 3 * (ema1 - ema2) + ema3 : stilT3 out = avg out_two = avg2 out1 = security(syminfo.tickerid, res_MHMA, out) out2 = security(syminfo.tickerid, res_MHMA, out_two) //Formula for Price Crossing Moving Average #1 cr_up = open < out1 and close > out1 cr_Down = open > out1 and close < out1 //Formula for Price Crossing Moving Average #2 cr_up2 = open < out2 and close > out2 cr_Down2 = open > out2 and close < out2 ma_up = out1 >= out1[smoothe] ma_down = out1 < out1[smoothe] col = cc ? ma_up ? color.lime : ma_down ? color.red : color.aqua : color.aqua col2 = cc2 ? ma_up ? color.lime : ma_down ? color.red : color.aqua : color.white circleYPosition = out2 plot(out1, title="Multi-Timeframe Moving Avg", style=plot.style_line, linewidth=2, color = col) plot(doma2 and out2 ? out2 : na, title="2nd Multi-TimeFrame Moving Average", style=plot.style_circles, linewidth=2, color=col2) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////// YGS Scalper///////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ShowPAC = input(true, title="Show wave") ShowTrendIndi = input(true, title="Show Trend Indicator") PACLen = input(50,minval=2,title="EMA ") src_YGS = input(close,title="Source for Wave centre EMA") // --- CONSTANTS --- DodgerBlue = #1E90FF // === /INPUTS === // Constants colours that include fully non-transparent option. lime100 = #00FF00FF blue100 = #0000FFFF aqua100 = #00FFFFFF darkred100 = #8B0000FF // === SERIES SETUP === // Price action channel (Wave) pacLo = ema(low, PACLen) pacHi = ema(high, PACLen) // === /SERIES === // === PLOTTING === // // If selected, Plot the Wave Channel based on EMA high,low and close L1=plot(ShowPAC ?pacLo:na, color=color.black, linewidth=1, title="up",transp=20) H1=plot(ShowPAC ?pacHi:na, color=color.black, linewidth=1, title="down",transp=20) fill(L1,H1, color=color.gray,transp=92,title="Fill Channel") // Show trend direction indication on the bottom wcolor = high>pacHi and low>pacHi? color.lime : low<pacLo and high<pacLo ? color.red : color.gray plotshape(ShowTrendIndi?src_YGS:na, color=wcolor,location=location.bottom,style=shape.square,size=size.normal,transp=20,title="Trend Direction") ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////Trend Strength////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Trend Strength t = input(13 , "Length") p = input(233 , "Plotting Length") d = input(false, "On Balance Volume Momentum Acceleration (on daily)") f_speedy(_d, _t) => v = sma(change(_d, _t) / _t, 3) a = change(v, _t) / _t v - a source = close pvr = d and nz(volume) and timeframe.isdaily ? sma(source, t) / sma(volume, t) : na psgval = f_speedy(source, t) plotarrow(psgval, title="Momentum Acceleration Of Price", colorup=color.aqua, colordown=color.orange, transp=80, show_last = p) plot(nz(volume) * pvr * .041, color=open > close ? color.red : color.green, style=plot.style_columns, title="Volume Histogram", transp=35, show_last = p) plot(f_speedy(obv,t) * pvr * .34, color=color.aqua, title="Momentum Acceleration of OBV", show_last = p) // -Alerts ══════════════════════════════════════════════════════════════════════════════════════ // bothAlertCondition = cross(psgval, 0) alertcondition(bothAlertCondition , "Early Warning" , "SpeedyGonzales : Probable Trade Opportunity\n{{exchange}}:{{ticker}}->\nPrice = {{close}},\nTime = {{time}}") alertcondition(bothAlertCondition[1] , "Trading Opportunity" , "SpeedyGonzales : Probable Trade Opportunity\n{{exchange}}:{{ticker}}->\nPrice = {{close}},\nTime = {{time}}") longAlertCondition = crossover(psgval, 0) alertcondition(longAlertCondition , "Long : Early Warning" , "SpeedyGonzales - Not Confirmed Probable Long Trade Opportunity\n{{exchange}}:{{ticker}}->\nPrice = {{close}},\nTime = {{time}}") alertcondition(longAlertCondition[1] , "Long : Trading Opportunity" , "SpeedyGonzales - Probable Long Trade Opportunity\n{{exchange}}:{{ticker}}->\nPrice = {{close}},\nTime = {{time}}") shortAlertCondition = crossunder(psgval, 0) alertcondition(shortAlertCondition , "Short : Early Warning" , "SpeedyGonzales - Not Confirmed Probable Short Trade Opportunity\n{{exchange}}:{{ticker}}->\nPrice = {{close}},\nTime = {{time}}") alertcondition(shortAlertCondition[1], "Short : Trading Opportunity", "SpeedyGonzales - Probable Short Trade Opportunity\n{{exchange}}:{{ticker}}->\nPrice = {{close}},\nTime = {{time}}") // ══════════════════════════════════════════════════════════════════════════════════════════════════ // //# * ══════════════════════════════════════════════════════════════════════════════════════════════ //# * //# * Purpose : Ability to optimize a study and observe trade simulation statistics accordingly //# * ══════════════════════════════════════════════════════════════════════════════════════════════ // ══════════════════════════════════════════════════════════════════════════════════════════════════ // // -Inputs ══════════════════════════════════════════════════════════════════════════════════════════ // isBackTest = input(false, "Backtest On/Off" , group = "Backtest Framework") dasCapital = input(1000., "Initial Capital" , inline = "BT1" , group = "Backtest Framework") lenBckTst = input(1, "Period (Year)", minval=0, step = .1 , inline = "BT1" , group = "Backtest Framework") isStopLoss = input(false, "Apply Stop Loss, with Stop Loss Set To %" , inline = "BT2" , group = "Backtest Framework") stopLoss = input(1., "", step=.1, minval = 0 , inline = "BT2" , group = "Backtest Framework") / 100 isBull = input(false, "Long : Candle Direction as Confirmation : Short" , inline = "BT3" , group = "Backtest Framework") isBear = input(false, "" , inline = "BT3" , group = "Backtest Framework") isSudden = input(true, "Avoid Sudden Price Changes" , group = "Backtest Framework") isTest = input(false, "❗❗❗ Simulate Trade on Next Bar : Only For Test Purpose (REPAINTS)", group = "Backtest Framework") lblInOutSL = input(true, "Trade Entry/Exit Labels  Trade Statistics Label" , inline = "BT4" , group = "Backtest Framework") lblTrdStat = input(true, "" , inline = "BT4" , group = "Backtest Framework") // -Calculations ════════════════════════════════════════════════════════════════════════════════════ // startBckTst = time > timenow - lenBckTst * 31556952000 var inTrade = false var entryPrice = 0. var exitPrice = 0. if isBackTest var capital = dasCapital var trades = 0 var win = 0 var loss = 0 bullCandle = close > open bearCandle = close < open stopLossTrigger = crossunder(close, entryPrice * (1 - stopLoss)) longCondition = isTest ? isBull ? isSudden ? longAlertCondition [1] and not shortAlertCondition and bullCandle : longAlertCondition [1] and bullCandle : isSudden ? longAlertCondition [1] and not shortAlertCondition : longAlertCondition [1] : isBull ? isSudden ? longAlertCondition [2] and not shortAlertCondition[1] and bullCandle[1] : longAlertCondition [2] and bullCandle[1] : isSudden ? longAlertCondition [2] and not shortAlertCondition[1] : longAlertCondition [1] shortCondition = isTest ? isBear ? isSudden ? shortAlertCondition[1] and not longAlertCondition and bearCandle : shortAlertCondition[1] and bearCandle : isSudden ? shortAlertCondition[1] and not longAlertCondition : shortAlertCondition[1] : isBear ? isSudden ? shortAlertCondition[2] and not longAlertCondition [1] and bearCandle[1] : shortAlertCondition[2] and bearCandle[1] : isSudden ? shortAlertCondition[2] and not longAlertCondition [1] : shortAlertCondition[1] stopLossCondition = isStopLoss ? inTrade and not shortCondition ? stopLossTrigger : 0 : 0 if startBckTst and longCondition and not inTrade entryPrice := open inTrade := true trades := trades + 1 if lblInOutSL label longLabel = label.new(bar_index, low, text="L" ,tooltip="entry price : " + tostring(entryPrice) + "\nentry value : " + tostring(capital, "#.##") ,color=color.green, style=label.style_label_up, textcolor=color.white, textalign=text.align_center, size=size.tiny) alert("long : probable trading opportunity, price " + tostring(close), alert.freq_once_per_bar) if (shortCondition or stopLossCondition) and inTrade exitPrice := stopLossCondition ? close : open inTrade := false capital := capital * (exitPrice / entryPrice) if exitPrice > entryPrice win := win + 1 else loss := loss + 1 if lblInOutSL text = stopLossCondition ? "SL" : "TP" label shortLabel = label.new(bar_index, high, text = text ,tooltip="change .......... : " + tostring((exitPrice / entryPrice - 1) * 100, "#.##") + "%\nentry/exit price : " + tostring(entryPrice) + " / " + tostring(exitPrice) + "\nnew capital ..... : " + tostring(capital, "#.##") ,color=color.red, style=label.style_label_down, textcolor=color.white, textalign=text.align_center, size=size.tiny) alert("short : probable trading opportunity, price " + tostring(close), alert.freq_once_per_bar) var label wLabel = na if not inTrade and longAlertCondition[1] and not shortAlertCondition wLabel := label.new(bar_index, low, text="⚠️" ,tooltip="probable long trading opportunity \nawaiting confirmation (next candle)\nif confirmed, backtest tool will execute trade with open price of the canlde" ,color=color.green, style=label.style_none, textcolor=color.white, textalign=text.align_center, size=size.huge) label.delete(wLabel[1]) alert("long : early warning : probable trading opportunity, awaiting confirmation (next candle), price " + tostring(close), alert.freq_once_per_bar) if inTrade and shortAlertCondition[1] and not longAlertCondition wLabel := label.new(bar_index, high, text="⚠️" ,tooltip="probable short/take profit trading opportunity \nawaiting confirmation (next candle)\nif confirmed, backtest tool will execute trade with open price of the canlde" ,color=color.green, style=label.style_none, textcolor=color.white, textalign=text.align_center, size=size.huge) label.delete(wLabel[1]) alert("short : early warning : probable trading opportunity, awaiting confirmation (next candle), price " + tostring(close), alert.freq_once_per_bar) if change(time) label.delete(wLabel[1]) if stopLossCondition alert("stop loss condition, price " + tostring(close), alert.freq_once_per_bar) if lblTrdStat var years = (timenow - time) / 31556952000 var yearsTxt = "" var remarks = "" if years < lenBckTst lenBckTst := years yearsTxt := tostring(lenBckTst, "#.##") + " Years***" remarks := "\n\n*longs only\n**final value, if trade active displays estimated final value\n***max available data for selected timeframe : # of bars - " + tostring(bar_index) else yearsTxt := tostring(lenBckTst, "#.##") + " Year(s)" remarks := "\n\n*longs only\n**final value - if in trade, displays estimated final value" inTradeTxt = inTrade ? "inTrade" : "not inTrade" estimated = inTrade ? capital * (close / entryPrice) : capital entryTxt = inTrade ? tostring(entryPrice) : "not inTrade" lastTrdTxt = inTrade ? ", Gain/Loss " + tostring((estimated/capital - 1) * 100, "#.##") + "%, Stop Loss " + tostring(isStopLoss ? entryPrice * (1 - stopLoss) : na) : "" stopLossTxt = isStopLoss ? "if last value falls by " + tostring(stopLoss * 100) + "% of entry price" : "not applied" tooltipTxt = "entires/exit caclulations\n" + "-long entry , on next bar when arrows below bar pointing up\n" + "-take profit, on next bar when arrows above bar pointing down\n" + "-stop loss " + stopLossTxt + remarks label indiLabel = label.new(time, close ,text="☼☾ Trade Statistics*, Trade Period - " + yearsTxt + "\n═════════════════════════════════════" + "\nSuccess Ratio ...... : " + tostring((win/trades)*100, "#") + "%" + ", # of Trades - " + tostring(trades) + ", Win/Loss - " + tostring(win) + "/" + tostring(loss) + "\nGain/Loss % ........ : " + tostring((estimated/dasCapital - 1) * 100, "#") + "%" + ", Initial/Final Value** - " + tostring(dasCapital) + " / " + tostring(estimated, "#") + "\n\nCurrent TradeStatus - " + inTradeTxt + lastTrdTxt + "\n═════════════════════════════════════" + "\nEntry Price/Value . : " + entryTxt + " / " + tostring(capital, "#.##") + " " + inTradeTxt + "\nLast Price/Value ... : " + tostring(close) + " / " + tostring(estimated , "#.##") + " " + inTradeTxt ,tooltip=tooltipTxt ,color=inTrade ? estimated/dasCapital > 1 ? color.teal : color.maroon : color.gray, xloc=xloc.bar_time, style=label.style_label_left, textcolor=color.white, textalign=text.align_left) label.set_x(indiLabel, label.get_x(indiLabel) + round(change(time) * 5)) label.delete(indiLabel[1]) // -Plotting ════════════════════════════════════════════════════════════════════════════════════ // bgcolor(isBackTest and startBckTst and startBckTst != startBckTst[1] ? color.blue : na) plot(inTrade ? entryPrice : exitPrice > 0 ? exitPrice : na, title="Entry/Exit Price Line", color=inTrade ? color.green : color.red, style = plot.style_circles)
RSI Trend Line
https://www.tradingview.com/script/6pr1kBeS-RSI-Trend-Line/
chrism665
https://www.tradingview.com/u/chrism665/
381
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © chrism665 //@version=5 indicator('RSI Trend Line', overlay=true) // Tooltips { string tt_input_lensrc = 'Select a length and input source to use for your RSI calculation' string tt_input_levels = 'If using bands, select a level for Overbought and Oversold. These are typically the upper and lower lines you see on a RSI chart' string tt_input_factor = 'This is effectively the responsiveness of the RSI and bands overlaid on price. 1.0 is the minimum and 5.0 is the maximum (most aggressive)' string tt_input_smooth = 'How much smoothing to apply to the trend line and bands. Use a value of \'1\' if no smoothing is desired' string tt_input_trendcol = 'Color of the RSI Trend line' string tt_input_bandscol = 'Check the box to display upper and lower bands.\nOB/OS is the color of the band lines and the Fill is the color of the background to fill the bands' string tt_input_benchmark = 'Check the box to enable plotting a Comparative RSI Strength.\nEnter a symbol to use as a benchmark' string tt_input_benchcol = 'Color of the Comparative RSI Strength line' // } // Functions { f_scale(x, z) => (x - 50) / (5 * z) // } // Inputs { len = input.int(defval=14, minval=1, maxval=999, title='Length', group='RSI', inline='RSI') src = input.source(defval=close, title='', group='RSI', inline='RSI', tooltip=tt_input_lensrc) ob = input.int(defval=70, minval=2, maxval=100, title='Overbought', group='RSI', inline='Levels') os = input.int(defval=30, minval=1, maxval=99, title='Oversold', group='RSI', inline='Levels', tooltip=tt_input_levels) factor = input.float(defval=2.0, minval=1.0, maxval=5.0, step=0.1, title='Responsiveness', group='Inputs', tooltip=tt_input_factor) smooth = input.int(defval=3, minval=1, maxval=999, title='Smoothing', group='Inputs', tooltip=tt_input_smooth) use_bench = input.bool(defval=false, title='Use Benchmark', group='Comparative Strength', inline='Bench') bench_sym = input.symbol(defval='SPY', title='', group='Comparative Strength', inline='Bench', tooltip=tt_input_benchmark) trend_col = input.color(defval=color.rgb(255, 152, 0, 0), title='Trend', group='Outputs', tooltip=tt_input_trendcol) use_bands = input.bool(defval=true, title='Use Bands', group='Outputs', inline='Bands') extremes_col = input.color(defval=color.rgb(41, 98, 255, 0), title='OB/OS', group='Outputs', inline='Bands') fill_col = input.color(defval=color.rgb(33, 150, 243, 95), title='Fill', group='Outputs', inline='Bands', tooltip=tt_input_bandscol) bench_col = input.color(defval=color.rgb(244, 67, 54, 0), title='Benchmark', group='Outputs', tooltip=tt_input_benchcol) // } // Variables & Declarations { float atr = ta.atr(len) float rsi = ta.rsi(src, len) float bench = request.security(bench_sym,timeframe.period,rsi) float diff = f_scale(rsi, factor) - f_scale(bench, factor) float trend = ta.ema(src - f_scale(rsi, factor) * atr, smooth) float upper = ta.ema(trend + f_scale(ob, factor) * atr, smooth) float lower = ta.ema(trend + f_scale(os, factor) * atr, smooth) float compare = ta.ema(trend - diff * atr, smooth) // } // Plot Series { plot(trend, color=trend_col, linewidth=1, title='RSI Trend Line') u = plot(use_bands ? upper : na, color=extremes_col, title='Upper') l = plot(use_bands ? lower : na, color=extremes_col, title='Lower') fill(u, l, color=fill_col, title='Background') plot(use_bench ? compare : na, color=bench_col, linewidth=1, title="Comparative RSI Strength") // }
QFL base scanner
https://www.tradingview.com/script/PIFGdVsZ-QFL-base-scanner/
rex_wolfe
https://www.tradingview.com/u/rex_wolfe/
423
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © rex_wolfe // Quickfingers Luc (QFL) base scanner - Zaphod // Version 1.6 (Zaphod) //@version=5 indicator(title = "Quickfingers Luc base scanner - Zaphod", shorttitle = "QFL Zaphod", overlay = true ) // Get user input basePeriods = input.int(title = "Base periods", tooltip = "Number of periods to look for a low that may form a new base.", defval = 36, minval = 4) pumpPeriods = input.int(title = "Pump periods", tooltip = "Number of periods pump is above the low to confirm a new base.", defval = 8, minval = 2) pump = input.float(title = "Pump from base (%)", tooltip = "Deal start condition.", defval = 3, step = 0.1, minval = 0) / 100 baseCrack = input.float(title = "Size of base crack (%)", tooltip = "Deal start condition.", defval = 3, step = 0.1, minval = 0.1) / 100 // Show hidden calculations showHighest = input.bool(title = "Show highest highs", tooltip = "Shows hidden calculations that are used to find the pump from the base.", defval = false) showLowest = input.bool(title = "Show simple lowest lows", tooltip = "Shows hidden calculations that are used to find new bases.", defval = false) // Check pumpPeriods is not greater than basePeriods and correct if required pumpPeriods := pumpPeriods >= basePeriods ? basePeriods - 1 : pumpPeriods // Declare variables var base = float(na) var buyLimit = float(na) var highestHigh = float(na) // Find the lowest low lowestLow = ta.lowest(low, basePeriods) // Test if new base newBase = lowestLow[pumpPeriods + 1] > lowestLow[pumpPeriods] and lowestLow[pumpPeriods] == lowestLow // Find the highest high between the base and current offsetHigh = ta.highest(high, pumpPeriods) highestHigh := newBase or high > highestHigh ? offsetHigh : highestHigh[1] // Work out current base base := newBase ? lowestLow : base[1] // Test if buy criteria are met and, if so, set a buy limit buyLimit := (highestHigh - base) / base > pump and (base - low) / base > baseCrack ? base * (1 - baseCrack) : na // Option to turn on plot of simple lows and highs plot(showLowest ? lowestLow : na, title = "Simple lowest low", color = color.purple) plot(showHighest ? highestHigh : na, title = "Simple highest high", color = color.purple) // Plot base plot(base, color = newBase ? color.new(color.white, 100) : color.new(color.blue, 0), style = plot.style_line, offset = 1 - pumpPeriods) // Plot buy signal plotshape(buyLimit, title="Buy flag", text="B", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.blue, textcolor=color.white) // Send an alert if buyLimit alert("QFL buy " + syminfo.tickerid + " at $" + str.tostring(buyLimit) + ".", freq = alert.freq_once_per_bar) // Roger, Candy, Elwood, Blacky, Bill. Not yet, Captain Chaos, not yet.
MACD EMA (by WJ)
https://www.tradingview.com/script/570by7lX-MACD-EMA-by-WJ/
Tutorial05
https://www.tradingview.com/u/Tutorial05/
49
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © sehweijun // EMA MACD CODE TAKEN FROM DEFAULT INDICATOR // I HAVE ONLY MADE SOME ADJUSTMENTS FOR VISUAL AID // I MADE THIS FOR MY OWN USE BUT HAVE DECIDED TO PUBLISH AND SHARE IN CASE ANYBODY WANTS TO USE IT //@version=4 study(title="MACD EMA (by WJ)", shorttitle="MACD EMA", overlay=true) // MACD macd_fast_length = input(title="Fast Length", group="MACD", type=input.integer, defval=12) macd_slow_length = input(title="Slow Length", group="MACD", type=input.integer, defval=26) macd_signal_length = input(title="Signal Smoothing", group="MACD", type=input.integer, minval = 1, maxval = 50, defval = 9) macd_sma_source = input(title="Oscillator MA Type", group="MACD", type=input.string, defval="EMA", options=["SMA", "EMA"]) macd_sma_signal = input(title="Signal Line MA Type", group="MACD", type=input.string, defval="EMA", options=["SMA", "EMA"]) macd_fast_ma = macd_sma_source == "SMA" ? sma(close, macd_fast_length) : ema(close, macd_fast_length) macd_slow_ma = macd_sma_source == "SMA" ? sma(close, macd_slow_length) : ema(close, macd_slow_length) macd = macd_fast_ma - macd_slow_ma macd_signal = macd_sma_signal == "SMA" ? sma(macd, macd_signal_length) : ema(macd, macd_signal_length) macd_hist = macd - macd_signal // EMA emaLength1 = input(200, title="EMA", group="EMA", minval=1) ema1 = ema(close, emaLength1) plot(ema1, title="EMA", color=#2962ff, transp=0, linewidth=2, style=plot.style_circles) // Signal Candle barColourToggle = input(title="Bar Colour [ON/OFF]", group="Signal Candle", type=input.bool, defval=true) backgroundColourToggle = input(title="Background Colour [ON/OFF]", group="Signal Candle", type=input.bool, defval=true) buySignal = close[0] > ema1 and macd < 0 and crossover(macd, macd_signal) sellSignal = close[0] < ema1 and macd > 0 and crossunder(macd, macd_signal) barcolor( color=buySignal and barColourToggle ? #00ff0a : sellSignal and barColourToggle ? #FF0000 : na, title="Signal Candle Bar Colour" ) bgcolor( color=buySignal and backgroundColourToggle ? #00ff0a : sellSignal and backgroundColourToggle ? #FF0000 : na, transp=85, title="Signal Candle Background Colour" ) alertcondition( buySignal or sellSignal, title="MACD Signal", message="MACD Signal!") alertcondition( buySignal, title="MACD Signal Buy", message="MACD Signal Buy!") alertcondition( sellSignal, title="MACD Signal Sell", message="MACD Signal Sell!")
Indicator : Financial Table
https://www.tradingview.com/script/dG4kGpDN-Indicator-Financial-Table/
morzor61
https://www.tradingview.com/u/morzor61/
105
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © morzor61 // Section // 1. Income Statement tb01 // 2. Balance Sheet tb02 // 3. Cash Flow tb03 // 4. Valuation tb04 // 1) Get Financial Data // 2) Decare array // 3) Store the array if conditions are met. // 4) Generate table //@version=4 study("Indicator : Financial Table", format=format.volume) period = input("FQ", "Report Type", options=["FQ", "FY"]) plotdata = input("EPS", "Data to Plot", options=["Revenue", "Net Profit", "EPS"]) int datasize = input(8, "Data size", minval=2)+1 opt_textsize = input(size.small, "Text Size", options=[ size.auto, size.tiny, size.small, size.normal, size.large, size.huge], group="table") is_opt_pos = input(position.middle_left, "Table \nPosition\n #1", options=[ position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right], group="table") bs_opt_pos = input(position.middle_center, "Table \nPosition\n #2", options=[ position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right], group="table") cf_opt_pos = input(position.middle_right, "Table \nPosition\n #3", options=[ position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right], group="table") // Function to detect the report data // var ticker = "ESD_FACTSET:" + syminfo.prefix + ";" + syminfo.ticker + ";EARNINGS" // report_date = security(earning_ticker, "D", time, gaps = true, lookahead=true) //earning report date // Function to Get Financial Data get_Fin_data(_finID, _period) => financial( symbol = syminfo.tickerid, financial_id = _finID, period = _period, gaps = barmerge.gaps_on) eps = get_Fin_data("EARNINGS_PER_SHARE", period) revenue = get_Fin_data("TOTAL_REVENUE", period) np = get_Fin_data("NET_INCOME", period) datatoplot = plotdata == "EPS" ? eps : plotdata == "Revenue" ? revenue : np // ■ Income Statement var date = array.new_int(datasize) // Date var is01 = array.new_float(datasize) // Revenue var is02 = array.new_float(datasize) // Net Profit var is03 = array.new_float(datasize) // EPS if not na(datatoplot) label.new(bar_index, datatoplot, text=tostring( plotdata == "EPS" ? datatoplot : plotdata == "Revenue" ? datatoplot/100000 : datatoplot/100000, plotdata == "EPS" ? "#,##0.000" : plotdata == "Revenue" ? "#,##0"+" M" : "#,##0"+" M")) array.push(is03, eps) array.shift(is03) array.push(date, time) array.shift(date) array.push(is01, revenue) array.shift(is01) array.push(is02, np) array.shift(is02) // ■ Balance Sheet // asset // 1. current curasst = get_Fin_data("TOTAL_CURRENT_ASSETS", period) // bs01 // - cash // - receivable // - inventory // 2. non current ttasst = get_Fin_data("TOTAL_ASSETS", period) // bs02 // liability // 1. current curlbt = get_Fin_data("TOTAL_CURRENT_LIABILITIES", period) // bs03 // - debt short // - accounts payable // - total // 2. non-current noncurlbt = get_Fin_data("TOTAL_NON_CURRENT_LIABILITIES", period) // bs04 // - debt lobg // - total non // shd equity shdeqt = get_Fin_data("SHRHLDRS_EQUITY", period) // bs05 // // var bs01 = array.new_float(datasize) // Current Asset var bs02 = array.new_float(datasize) // Non-current Asset var bs03 = array.new_float(datasize) // Current Liabilities var bs04 = array.new_float(datasize) // Non-current Liabilites var bs05 = array.new_float(datasize) // Share Holder's Equity if not na(datatoplot) array.push(bs01, curasst) array.push(bs02, ttasst) array.push(bs03, curlbt) array.push(bs04, noncurlbt) array.push(bs05, shdeqt) array.shift(bs01) array.shift(bs02) array.shift(bs03) array.shift(bs04) array.shift(bs05) var tbbs = table.new(bs_opt_pos, 7, datasize, frame_color=color.black,frame_width=1, border_width=1, border_color=color.black) if barstate.islast table.cell(tbbs, 0,0, "", text_size = opt_textsize) table.cell(tbbs, 1,0, "Date", text_size = opt_textsize) table.cell(tbbs, 2,0, "Current \nAsset", text_size = opt_textsize) table.cell(tbbs, 3,0, "Total \nAsset", text_size = opt_textsize) table.cell(tbbs, 4,0, "Current \nLiabilities", text_size = opt_textsize) table.cell(tbbs, 5,0, "Non-current \nLiabilities", text_size = opt_textsize) table.cell(tbbs, 6,0, "Shd \n Eqity", text_size = opt_textsize) for i = 1 to datasize-1 if barstate.islast table.cell(tbbs, 0, i, tostring(i), text_size = opt_textsize) table.cell(tbbs, 1, i, str.format("{0, date, Y-MMM}", array.get(date, i)), text_size = opt_textsize) table.cell(tbbs, 2, i, tostring(array.get(bs01, i)/1000000, "#,##0"+"M"), text_size = opt_textsize, bgcolor = array.get(bs01 ,i) <= array.get(bs01 , i-1) ? #FF6961 : #39FF14) table.cell(tbbs, 3, i, tostring(array.get(bs02, i)/1000000, "#,##0"+"M"), text_size = opt_textsize, bgcolor = array.get(bs02 ,i) <= array.get(bs02 , i-1) ? #FF6961 : #39FF14) table.cell(tbbs, 4, i, tostring(array.get(bs03, i)/1000000, "#,##0"+"M"), text_size = opt_textsize, bgcolor = array.get(bs03 ,i) <= array.get(bs03 , i-1) ? #FF6961 : #39FF14) table.cell(tbbs, 5, i, tostring(array.get(bs04, i)/1000000, "#,##0"+"M"), text_size = opt_textsize, bgcolor = array.get(bs04 ,i) <= array.get(bs04 , i-1) ? #FF6961 : #39FF14) table.cell(tbbs, 6, i, tostring(array.get(bs05, i)/1000000, "#,##0"+"M"), text_size = opt_textsize, bgcolor = array.get(bs05 ,i) <= array.get(bs05 , i-1) ? #FF6961 : #39FF14) plot(datatoplot , style=plot.style_circles, linewidth=5, join=true) var tbis = table.new(is_opt_pos, 5, datasize, frame_color=color.black,frame_width=1, border_width=1, border_color=color.black) if barstate.islast table.cell(tbis, 0,0, "", text_size = opt_textsize) table.cell(tbis, 1,0, "Date", text_size = opt_textsize) table.cell(tbis, 2,0, "Revenue", text_size = opt_textsize) table.cell(tbis, 3,0, "Net Profit", text_size = opt_textsize) table.cell(tbis, 4,0, "EPS", text_size = opt_textsize) for i = 1 to datasize-1 if barstate.islast table.cell(tbis, 0, i, tostring(i), text_size = opt_textsize) table.cell(tbis, 1, i, str.format("{0, date, Y-MMM}", array.get(date, i)), text_size = opt_textsize) table.cell(tbis, 2, i, tostring(array.get(is01, i)/1000000, "#,##0"+"M"), text_size = opt_textsize, bgcolor = array.get(is01 ,i) <= array.get(is01 , i-1) ? #FF6961 : #39FF14) table.cell(tbis, 3, i, tostring(array.get(is02, i)/1000000, "#,##0"+"M"), text_size = opt_textsize, bgcolor = array.get(is02 ,i) <= array.get(is02 , i-1) ? #FF6961 : #39FF14) table.cell(tbis, 4, i, tostring(array.get(is03, i), "#,##0.000"), text_size = opt_textsize, bgcolor = array.get(is03 ,i) <= array.get(is03 , i-1) ? #FF6961 : #39FF14) // Cash Flow // 1. Operation (cfo) cfo = get_Fin_data("CASH_F_OPERATING_ACTIVITIES", period) // 2. Investment (cfi) cfi = get_Fin_data("CASH_F_INVESTING_ACTIVITIES", period) // 3. Financial (cff) cff = get_Fin_data("CASH_F_FINANCING_ACTIVITIES", period) // 4. Capital Expenditure (capex) capex = get_Fin_data("CAPITAL_EXPENDITURES", period) // 5. Free Cash Flow (fcf) fcf = get_Fin_data("FREE_CASH_FLOW", period) var cf01 = array.new_float(datasize) // cfo var cf02 = array.new_float(datasize) // cfi var cf03 = array.new_float(datasize) // cff var cf04 = array.new_float(datasize) // capex var cf05 = array.new_float(datasize) // fcf if not na(datatoplot) array.push(cf01, cfo) array.push(cf02, cfi) array.push(cf03, cff) array.push(cf04, capex) array.push(cf05, fcf) array.shift(cf01) array.shift(cf02) array.shift(cf03) array.shift(cf04) array.shift(cf05) var tbcf = table.new(cf_opt_pos, 7, datasize, frame_color=color.black,frame_width=1, border_width=1, border_color=color.black) if barstate.islast table.cell(tbcf, 0,0, "", text_size = opt_textsize) table.cell(tbcf, 1,0, "Date", text_size = opt_textsize) table.cell(tbcf, 2,0, "CF \nOperation", text_size = opt_textsize) table.cell(tbcf, 3,0, "CF \nInvestment", text_size = opt_textsize) table.cell(tbcf, 4,0, "CF \nFinancing", text_size = opt_textsize) table.cell(tbcf, 5,0, "Capital \nExpenditure", text_size = opt_textsize) table.cell(tbcf, 6,0, "Free \nCash Flow", text_size = opt_textsize) for i = 1 to datasize-1 if barstate.islast table.cell(tbcf, 0, i, tostring(i), text_size = opt_textsize) table.cell(tbcf, 1, i, str.format("{0, date, Y-MMM}", array.get(date, i)), text_size = opt_textsize) table.cell(tbcf, 2, i, tostring(array.get(cf01, i)/1000000, "#,##0"+"M"), text_size = opt_textsize, bgcolor = array.get(cf01,i) <= array.get(cf01, i-1) ? #FF6961 : #39FF14) table.cell(tbcf, 3, i, tostring(array.get(cf02, i)/1000000, "#,##0"+"M"), text_size = opt_textsize, bgcolor = array.get(cf02,i) <= array.get(cf02, i-1) ? #FF6961 : #39FF14) table.cell(tbcf, 4, i, tostring(array.get(cf03, i)/1000000, "#,##0"+"M"), text_size = opt_textsize, bgcolor = array.get(cf03,i) <= array.get(cf03, i-1) ? #FF6961 : #39FF14) table.cell(tbcf, 5, i, tostring(array.get(cf04, i)/1000000, "#,##0"+"M"), text_size = opt_textsize, bgcolor = array.get(cf04,i) <= array.get(cf04, i-1) ? #FF6961 : #39FF14) table.cell(tbcf, 6, i, tostring(array.get(cf05, i)/1000000, "#,##0"+"M"), text_size = opt_textsize, bgcolor = array.get(cf05,i) <= array.get(cf05, i-1) ? #FF6961 : #39FF14)
Weekly Put Sale
https://www.tradingview.com/script/tbohcQpY-Weekly-Put-Sale/
Dustin_D_RLT
https://www.tradingview.com/u/Dustin_D_RLT/
143
study
4
MPL-2.0
//This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=4 //Author = https://www.tradingview.com/u/Dustin_D_RLT/ //Weekly Put Sale study(title="Weekly Put Sale", shorttitle="WPS", overlay=true, resolution="") //Set for 1 Week for weekly options or 1 Month for monthly higherTF = input(title="Higher Timeframe Resolution",defval="W", type=input.resolution) atrLength = input(title="ATR length", defval=14, minval=1) smoothing = input(title="Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"]) //Multiple of ATR for the distance from high of week strikeMultiplier1 = input(title="ATR Strike Multiplier1", defval=1.5, minval=1, step=.25) strikeMultiplier2 = input(title="ATR Strike Multiplier2", defval=2, minval=1, step=.25) strikeMultiplier3 = input(title="ATR Strike Multiplier3", defval=2.5, minval=1, step=.25) //Used in signal for XX% of Weekly ATR From Weekly High largeBearCandle = input(title="Large Bear Candle Percent", defval=75, minval=1) // Set the market session to use (0000-0000 is all time from monday through friday) sessSpec = input(title="To use Market time session",defval="0000-0000", type=input.session) // A function to check if the current bar is the first bar on the higher timeframe is_newbar(res, sess) => t = time(res, sess) na(t[1]) and not na(t) or t[1] < t newbar = is_newbar(higherTF, sessSpec) // Weekly ATR ma_function(source, length) => if smoothing == "RMA" rma(source, length) else if smoothing == "SMA" sma(source, length) else if smoothing == "EMA" ema(source, length) else wma(source, length) // determine the high of the week or month fullWeekHigh = security(syminfo.tickerid, higherTF, high, barmerge.gaps_off, barmerge.lookahead_off) // Only check the high if the high is not the first candle starting a higher time frame candle var float newHigh = na if newbar newHigh := high else newHigh := max(high, newHigh, high[1]) // For testing plot newHigh // plot(newHigh, title = "High of the Full week", style=plot.style_stepline, color=color.blue) // Calculate the ATR of the fullWeekHigh (make sure barmerge.lookahead_) has the same value as fullWeekHigh atrValue = security(syminfo.tickerid, higherTF, ma_function(tr(true), atrLength), barmerge.gaps_off, barmerge.lookahead_off) // Calculate the strike levels strike1 = newHigh - (strikeMultiplier1 * atrValue) strike2 = newHigh - (strikeMultiplier2 * atrValue) strike3 = newHigh - (strikeMultiplier3 * atrValue) // Plot the different strike price levels plot(strike1, title = "Strike Level 1", style=plot.style_stepline, color=color.orange) plot(strike2, title = "Strike Level 2", style=plot.style_stepline, color=color.blue) plot(strike3, title = "Strike Level 3", style=plot.style_stepline, color=color.navy) //Signal for XX% of Weekly ATR From Weekly High putSaleSignal = (close < open and (newHigh - close) > (atrValue * largeBearCandle * .01)) plotchar(putSaleSignal, char='$', location=location.abovebar, color=color.green, size=size.tiny) //Alerts alertcondition(putSaleSignal, title="WPS Alert", message="Weekly Put Sale Alert Signal")
ADR Percent
https://www.tradingview.com/script/kWvPJkmG-ADR-Percent/
vtrader321
https://www.tradingview.com/u/vtrader321/
133
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © vtrader321 //@version=5 indicator('ADR Percent', overlay=true) LIGHTTRANSP = 90 AVGTRANSP = 80 HEAVYTRANSP = 70 var string _gp = 'Display' string i_tableYpos = input.string('top', 'Panel position', inline='11', options=['top', 'middle', 'bottom'], group=_gp) string i_tableXpos = input.string('center', '', inline='11', options=['left', 'center', 'right'], group=_gp) var string _gp1 = 'Lookback Time Range(Days)' string i_time_interval = input.string('5', '', inline='11', options=['5', '10', '15', '20'], group=_gp1) _open = request.security(syminfo.tickerid, 'D', open) dayrange = high - low _r1 = request.security(syminfo.tickerid, 'D', dayrange[1]) _r2 = request.security(syminfo.tickerid, 'D', dayrange[2]) _r3 = request.security(syminfo.tickerid, 'D', dayrange[3]) _r4 = request.security(syminfo.tickerid, 'D', dayrange[4]) _r5 = request.security(syminfo.tickerid, 'D', dayrange[5]) _r6 = request.security(syminfo.tickerid, 'D', dayrange[6]) _r7 = request.security(syminfo.tickerid, 'D', dayrange[7]) _r8 = request.security(syminfo.tickerid, 'D', dayrange[8]) _r9 = request.security(syminfo.tickerid, 'D', dayrange[9]) _r10 = request.security(syminfo.tickerid, 'D', dayrange[10]) _r11 = request.security(syminfo.tickerid, 'D', dayrange[11]) _r12 = request.security(syminfo.tickerid, 'D', dayrange[12]) _r13 = request.security(syminfo.tickerid, 'D', dayrange[13]) _r14 = request.security(syminfo.tickerid, 'D', dayrange[14]) _r15 = request.security(syminfo.tickerid, 'D', dayrange[15]) _r16 = request.security(syminfo.tickerid, 'D', dayrange[16]) _r17 = request.security(syminfo.tickerid, 'D', dayrange[17]) _r18 = request.security(syminfo.tickerid, 'D', dayrange[18]) _r19 = request.security(syminfo.tickerid, 'D', dayrange[19]) _r20 = request.security(syminfo.tickerid, 'D', dayrange[20]) _adr = 0.0 if i_time_interval == '5' _adr_5 = (_r1 + _r2 + _r3 + _r4 + _r5) / 5 _adr := _adr_5 / _open * 100 _adr else if i_time_interval == '10' _adr_10 = (_r1 + _r2 + _r3 + _r4 + _r5 + _r6 + _r7 + _r8 + _r9 + _r10) / 10 _adr := _adr_10 / _open * 100 _adr else if i_time_interval == '15' _adr_15 = (_r1 + _r2 + _r3 + _r4 + _r5 + _r6 + _r7 + _r8 + _r9 + _r10 + _r11 + _r12 + _r13 + _r14 + _r15) / 15 _adr := _adr_15 / _open * 100 _adr else if i_time_interval == '20' _adr_20 = (_r1 + _r2 + _r3 + _r4 + _r5 + _r6 + _r7 + _r8 + _r9 + _r10 + _r11 + _r12 + _r13 + _r14 + _r15 + _r16 + _r17 + _r18 + _r19 + _r20) / 20 _adr := _adr_20 / _open * 100 _adr var table _table = table.new(i_tableYpos + '_' + i_tableXpos, 1, 1, border_width=3) _c_color = color.rgb(38, 166, 154) _transp = math.abs(_adr) > 2 ? HEAVYTRANSP : math.abs(_adr) > 1 ? AVGTRANSP : LIGHTTRANSP _cellText = 'ADR' + '\n' + str.tostring(_adr, '0.00') + ' %' table.cell(_table, 0, 0, _cellText, bgcolor=color.new(_c_color, _transp), text_color=_c_color, text_size=size.normal)
Dynamic Moving Averages
https://www.tradingview.com/script/YdiAqvBg-Dynamic-Moving-Averages/
Decam9
https://www.tradingview.com/u/Decam9/
63
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Decam9 //@version=5 indicator("Dynamic Moving Averages", overlay = true) //Moving Average Inputs len0 = input(title="MA Length", defval = 50, group ="Long Term Trend MA", inline = "line 1", tooltip = "This Trend MA defines the trend. The source of a Dynamic MA will be \"low\" when trading above trend MA and \"high\" when below the Trend MA.") len1 = input(title="MA Length", defval = 5, group = "Moving Average 1", inline = "line 1") len2 = input(title="MA Length", defval = 10, group ="Moving Average 2", inline = "line 1") len3 = input(title="MA Length", defval = 20, group ="Moving Average 3", inline = "line 1") len4 = input(title="MA Length", defval = 100, group ="Moving Average 4", inline = "line 1") len5 = input(title="MA Length", defval = 200, group ="Moving Average 5", inline = "line 1") len6 = input(title="MA Length", defval = 350, group ="Moving Average 6", inline = "line 1") src0 = input(close, title="MA 1 Source", group = "Long Term Trend MA", inline = "line 1") src1 = input(close, title="MA 1 Source", group = "Moving Average 1", inline = "line 1") src2 = input(close, title="MA 1 Source", group = "Moving Average 2", inline = "line 1") src3 = input(close, title="MA 1 Source", group = "Moving Average 3", inline = "line 1") src4 = input(close, title="MA 1 Source", group = "Moving Average 4", inline = "line 1") src5 = input(close, title="MA 1 Source", group = "Moving Average 5", inline = "line 1") src6 = input(close, title="MA 1 Source", group = "Moving Average 6", inline = "line 1") isDynamic1 = input(title = "Dynamic M.A.?", defval = true, group = "Moving Average 1", inline = "line 2", tooltip = "Changes the source to high or low based on the trend") isDynamic2 = input(title = "Dynamic M.A.?", defval = true, group = "Moving Average 2", inline = "line 2", tooltip = "Changes the source to high or low based on the trend") isDynamic3 = input(title = "Dynamic M.A.?", defval = true, group = "Moving Average 3", inline = "line 2", tooltip = "Changes the source to high or low based on the trend") isDynamic4 = input(title = "Dynamic M.A.?", defval = true, group = "Moving Average 4", inline = "line 2", tooltip = "Changes the source to high or low based on the trend") isDynamic5 = input(title = "Dynamic M.A.?", defval = true, group = "Moving Average 5", inline = "line 2", tooltip = "Changes the source to high or low based on the trend") isDynamic6 = input(title = "Dynamic M.A.?", defval = true, group = "Moving Average 6", inline = "line 2", tooltip = "Changes the source to high or low based on the trend") //Create Options for Type of Moving Average maType0 = input.string(defval = "sma", options = ["sma", "ema"], title = "MA Type", group = "Long Term Trend MA", inline = "inline 2") maType1 = input.string(defval = "sma", options = ["sma", "ema"], title = "MA Type", group = "Moving Average 1", inline = "inline 2") maType2 = input.string(defval = "sma", options = ["sma", "ema"], title = "MA Type", group = "Moving Average 2", inline = "inline 2") maType3 = input.string(defval = "sma", options = ["sma", "ema"], title = "MA Type", group = "Moving Average 3", inline = "inline 2") maType4 = input.string(defval = "sma", options = ["sma", "ema"], title = "MA Type", group = "Moving Average 4", inline = "inline 2") maType5 = input.string(defval = "sma", options = ["sma", "ema"], title = "MA Type", group = "Moving Average 5", inline = "inline 2") maType6 = input.string(defval = "sma", options = ["sma", "ema"], title = "MA Type", group = "Moving Average 6", inline = "inline 2") //Create MAs based on Dynamics and Type of EMA ma0 = maType0 == "sma" ? ta.sma(src0,len0) : ta.ema(src0,len0) ma1 = maType1 == "sma" ? ta.sma(isDynamic1 ? (close > ma0 ? low : high) : src1,len1) : ta.ema(isDynamic1 ? (close > ma0 ? low : high) : src1,len1) ma2 = maType2 == "sma" ? ta.sma(isDynamic2 ? (close > ma0 ? low : high) : src2,len2) : ta.ema(isDynamic2 ? (close > ma0 ? low : high) : src2,len2) ma3 = maType3 == "sma" ? ta.sma(isDynamic3 ? (close > ma0 ? low : high) : src3,len3) : ta.ema(isDynamic3 ? (close > ma0 ? low : high) : src3,len3) ma4 = maType4 == "sma" ? ta.sma(isDynamic4 ? (close > ma0 ? low : high) : src4,len4) : ta.ema(isDynamic4 ? (close > ma0 ? low : high) : src4,len4) ma5 = maType5 == "sma" ? ta.sma(isDynamic5 ? (close > ma0 ? low : high) : src5,len5) : ta.ema(isDynamic5 ? (close > ma0 ? low : high) : src5,len5) ma6 = maType6 == "sma" ? ta.sma(isDynamic6 ? (close > ma0 ? low : high) : src6,len6) : ta.ema(isDynamic6 ? (close > ma0 ? low : high) : src6,len6) //Plot the Moving Averages plotma0 = plot(ma0, title = "ma0", color = color.red) plotma1 = plot(ma1, title = "ma1", color = color.orange) plotma2 = plot(ma2, title = "ma2", color = color.yellow) plotma3 = plot(ma3, title = "ma3", color = color.green) plotma4 = plot(ma4, title = "ma4", color = color.blue) plotma5 = plot(ma5, title = "ma5", color = color.navy) plotma6 = plot(ma6, title = "ma6", color = color.purple)
Directional Volatility and Volume
https://www.tradingview.com/script/8f2nEtBb-Directional-Volatility-and-Volume/
PuguForex
https://www.tradingview.com/u/PuguForex/
226
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © PuguForex 2021 //@version=5 indicator('Directional Volatility and Volume') inpVolatilityPeriod = input.int(title ='Volatility period' , minval=1 , defval=5) inpVolatilityMethod = input.string(title="Volatility smoothing", defval="SMA", options = ["RMA", "SMA", "EMA", "WMA"]) inpVolumePeriod = input.int(title ='Volume period' , minval=1 , defval=14) inpVolumeMethod = input.string(title="Volume smoothing" , defval="SMA", options = ["RMA", "SMA", "EMA", "WMA"]) inpZonePeriod = input.int(title ='Zone period' , minval=1 , defval=14) inpZoneMethod = input.string(title="Zone smoothing" , defval="SMA", options = ["RMA", "SMA", "EMA", "WMA"]) maFunction(source, length, methodInput) => switch methodInput "RMA" => ta.rma(source, length) "WMA" => ta.wma(source, length) "EMA" => ta.ema(source, length) => ta.sma(source, length) zeroLine = maFunction(hl2 , inpZonePeriod , inpZoneMethod) val = maFunction(close, inpVolatilityPeriod, inpVolatilityMethod) - zeroLine znUp = maFunction(high , inpZonePeriod , inpZoneMethod) - zeroLine znDn = maFunction(low , inpZonePeriod , inpZoneMethod) - zeroLine vol = close > open ? volume : -volume volSm = maFunction(vol, inpVolumePeriod, inpVolumeMethod) upBr = ta.crossover(val,znUp) dnBr = ta.crossunder(val,znDn) if upBr alert("Volatility broke upper zone",alert.freq_once_per_bar_close) if dnBr alert("Volatility broke lower zone",alert.freq_once_per_bar_close) valColor = val > znUp ? color.green : color.red volColor = volSm > 0 ? color.blue : volSm < 0 ? color.orange : color.silver plot(val, title='Volatility', style=plot.style_columns, color=valColor) plot(znUp, title='Volume Up', style=plot.style_columns, color=volColor) plot(znDn, title='Volume Dn', style=plot.style_columns, color=volColor)
TSLA $4 Red Candle
https://www.tradingview.com/script/685tYHmy-TSLA-4-Red-Candle/
Magic-Charts
https://www.tradingview.com/u/Magic-Charts/
71
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Magic-Charts //@version=4 study("TSLA $4 Red Candle", overlay=true, max_labels_count=100) diff = open - close if(diff < 4.99 and diff > 3.99) label.new(bar_index, high, text="$" + tostring(diff) + " Candle" + "--\n" + tostring(open) + " --\n" + tostring(close), color=color.red)
MMRI
https://www.tradingview.com/script/4lcH0XQ4-MMRI/
CraftyChaos
https://www.tradingview.com/u/CraftyChaos/
50
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © CraftyChaos //@version=4 study("MMRI", overlay=false) mmri = security("TVC:DXY*TVC:US10Y/1.61", timeframe.period, close) mmri_risk_level = mmri < 100 ? "Low Risk" : mmri < 200 ? "Mild Risk" : "High Risk" mmri_risk_color = mmri < 100 ? color.green : mmri < 200 ? color.orange : color.red riskon_state = mmri < 100 ? "Risk ON" : "Risk OFF" riskon_color = mmri < 100 ? color.green : color.red var table info = table.new(position=position.top_right, columns=2, rows=1, border_width=3) table.cell(info, 0, 0, mmri_risk_level, bgcolor=mmri_risk_color) table.cell(info, 1, 0, riskon_state, bgcolor=riskon_color) plot(mmri)
Pi Cycle Bitcoin High/Low
https://www.tradingview.com/script/NHl13w4l-Pi-Cycle-Bitcoin-High-Low/
NoCreditsLeft
https://www.tradingview.com/u/NoCreditsLeft/
1,338
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © @NoCreditsLeft //@version=4 study("Pi Cycle Bitcoin High/Low", shorttitle="Pi Cycle Bitcoin High/Low", overlay=true) //Create Inputs for the 4 MAs, and Visual lowma_long = input(471, minval=1, title="BTC Low - Long SMA") is_show_lowma1 = input(true, type=input.bool, title="Show Low Long SMA?") lowema_short = input(150, minval=1, title="BTC Low - Short EMA") is_show_lowma2 = input(true, type=input.bool, title="Show Low Short EMA?") hima_long = input(350, minval=1, title="BTC High - Long SMA") is_show_hima1 = input(true, type=input.bool, title="Show High Long SMA?") hima_short = input(111, minval=1, title="BTC High - Short SMA") is_show_hima2 = input(true, type=input.bool, title="Show High Short SMA?") //Set resolution to the Daily Chart resolution = input('D', type=input.string, title="Time interval") //Run the math for the 4 MAs ma_long_low = security(syminfo.tickerid, resolution, sma(close, lowma_long)*745)/1000 ema_short_low = security(syminfo.tickerid, resolution, ema(close, lowema_short)) ma_long_hi = security(syminfo.tickerid, resolution, sma(close, hima_long)*2) ma_short_hi = security(syminfo.tickerid, resolution, sma(close, hima_short)) //Set SRC src = security(syminfo.tickerid, resolution, close) //Plot the 4 MAs plot(is_show_lowma1?ma_long_low:na, color=color.red, linewidth=2, title="Low Long MA") var lowma_long_label = label.new(x = bar_index, y = lowma_long, color = color.rgb(0, 0, 0, 100), style = label.style_label_left, textcolor = color.red, text = "BTC Low - Long SMA") label.set_xy(lowma_long_label, x = bar_index, y = ma_long_low) plot(is_show_lowma2?ema_short_low:na, color=color.green, linewidth=2, title="Low Short EMA") var lowema_short_label = label.new(x = bar_index, y = lowema_short, color = color.rgb(0, 0, 0, 100), style = label.style_label_left, textcolor = color.green, text = "BTC Low - Short EMA") label.set_xy(lowema_short_label, x = bar_index, y = ema_short_low) plot(is_show_hima1?ma_long_hi:na, color=color.white, linewidth=2, title="High Long MA") var hima_long_label = label.new(x = bar_index, y = hima_long, color = color.rgb(0, 0, 0, 100), style = label.style_label_left, textcolor = color.white, text = "BTC High - Long MA") label.set_xy(hima_long_label, x = bar_index, y = ma_long_hi) plot(is_show_hima2?ma_short_hi:na, color=color.yellow, linewidth=2, title="High Short MA") var hima_short_label = label.new(x = bar_index, y = hima_short, color = color.rgb(0, 0, 0, 100), style = label.style_label_left, textcolor = color.yellow, text = "BTC High - Short MA") label.set_xy(hima_short_label, x = bar_index, y = ma_short_hi) //Find where the MAs cross each other PiCycleLow = crossunder(ema_short_low, ma_long_low) ? src + (src/100 * 10) : na PiCycleHi = crossunder(ma_long_hi, ma_short_hi) ? src + (src/100 * 10) : na //Create Labels plotshape(PiCycleLow, text="Pi Cycle Low", color=color.navy, textcolor=color.white, style=shape.labelup,size=size.normal, location=location.belowbar, title="Cycle Low") plotshape(PiCycleHi, text="Pi Cycle High", color=color.teal, textcolor=color.white, style=shape.labeldown,size=size.normal, location=location.abovebar, title="Cycle High") //Generate vertical lines at the BTC Halving Dates isDate(y, m, d) => val = timestamp(y,m,d) if val <= time and val > time[1] true else false // First Halving if isDate(2012, 11, 28) line.new(bar_index, low, bar_index, high, xloc.bar_index, extend.both, style=line.style_dashed, color=color.yellow) label.new(bar_index, low, text="1st Halving - Nov 28, 2012", style=label.style_label_upper_left, textcolor=color.yellow, color=color.black, textalign=text.align_right, yloc=yloc.belowbar) // Second Halving if isDate(2016, 7, 9) line.new(bar_index, low, bar_index, high, xloc.bar_index, extend.both, style=line.style_dashed, color=color.yellow) label.new(bar_index, low, text="2nd Halving - Jul 9, 2016", style=label.style_label_upper_left, textcolor=color.yellow, color=color.black, textalign=text.align_right, yloc=yloc.belowbar) // Third Halving if isDate(2020, 5, 11) line.new(bar_index, low, bar_index, high, xloc.bar_index, extend.both, style=line.style_dashed, color=color.yellow) label.new(bar_index, low, text="3rd Halving - May 11, 2020", style=label.style_label_upper_left, textcolor=color.yellow, color=color.black, textalign=text.align_right, yloc=yloc.belowbar) // Fourth Halving //if isDate(2024, 3, 26) // line.new(bar_index, low, bar_index, high, xloc.bar_index, extend.both, style=line.style_dashed, color=color.yellow) // label.new(bar_index, low, text="4th Halving - March 26, 2024", style=label.style_label_upper_left, textcolor=color.yellow, color=color.black, textalign=text.align_right, yloc=yloc.belowbar)
20% up with all continuously green candle: Lovevanshi
https://www.tradingview.com/script/pYxbk2iO-20-up-with-all-continuously-green-candle-Lovevanshi/
Lovevanshi
https://www.tradingview.com/u/Lovevanshi/
77
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Lovevanshi //@version=4 study("20% up with all continuously green candle: Lovevanshi ",shorttitle="20%Up_G_L", overlay=true) int a=0 gain=0.0 max=0.0 u=0 min=1000000.0 d=0 signal=array.new_bool(1000,false) greenCandle = (close > open) or (close==open and open>low[1]) //if statement to check continuous candle are green if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] and greenCandle[a+6] and greenCandle[a+7] and greenCandle[a+8] and greenCandle[a+9] and greenCandle[a+10] and greenCandle[a+11] and greenCandle[a+12] and greenCandle[a+13] and greenCandle[a+14] and greenCandle[a+15] and greenCandle[a+16] and greenCandle[a+17] and greenCandle[a+18] and greenCandle[a+19] i=for i=a to a+19 if max<high[i] max:=high[i] // to get maximum of high among continuously green candles u:=i // to get bar_index of maximum of high among continuously green candles j=for j=a to a+19 if min>low[j] min:=low[j] // to get minimum of low among green candles d:=j // to get bar_index of minimum of low among continuously green candle gain:=(high[u]-low[d])/low[d] //ratio of difference between maximum high and minimum low with respect to minimum low among continuously green candles if gain>0.2 array.insert(signal, a, true) //enter "true" after checking if gain is more than 20% amonng continuously green candles else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] and greenCandle[a+6] and greenCandle[a+7] and greenCandle[a+8] and greenCandle[a+9] and greenCandle[a+10] and greenCandle[a+11] and greenCandle[a+12] and greenCandle[a+13] and greenCandle[a+14] and greenCandle[a+15] and greenCandle[a+16] and greenCandle[a+17] and greenCandle[a+18] i=for i=a to a+18 if max<high[i] max:=high[i] // to get maximum of high among continuously green candles u:=i // to get bar_index of maximum of high among continuously green candles j=for j=a to a+18 if min>low[j] min:=low[j] // to get minimum of low among green candles d:=j // to get bar_index of minimum of low among continuously green candle gain:=(high[u]-low[d])/low[d] //ratio of difference between maximum high and minimum low with respect to minimum low among continuously green candles if gain>0.2 array.insert(signal, a, true) //enter "true" after checking if gain is more than 20% amonng continuously green candles else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] and greenCandle[a+6] and greenCandle[a+7] and greenCandle[a+8] and greenCandle[a+9] and greenCandle[a+10] and greenCandle[a+11] and greenCandle[a+12] and greenCandle[a+13] and greenCandle[a+14] and greenCandle[a+15] and greenCandle[a+16] and greenCandle[a+17] i=for i=a to a+17 if max<high[i] max:=high[i] // to get maximum of high among continuously green candles u:=i // to get bar_index of maximum of high among continuously green candles j=for j=a to a+17 if min>low[j] min:=low[j] // to get minimum of low among green candles d:=j // to get bar_index of minimum of low among continuously green candle gain:=(high[u]-low[d])/low[d] //ratio of difference between maximum high and minimum low with respect to minimum low among continuously green candles if gain>0.2 array.insert(signal, a, true) //enter "true" after checking if gain is more than 20% amonng continuously green candles else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] and greenCandle[a+6] and greenCandle[a+7] and greenCandle[a+8] and greenCandle[a+9] and greenCandle[a+10] and greenCandle[a+11] and greenCandle[a+12] and greenCandle[a+13] and greenCandle[a+14] and greenCandle[a+15] and greenCandle[a+16] i=for i=a to a+16 if max<high[i] max:=high[i] // to get maximum of high among continuously green candles u:=i // to get bar_index of maximum of high among continuously green candles j=for j=a to a+16 if min>low[j] min:=low[j] // to get minimum of low among green candles d:=j // to get bar_index of minimum of low among continuously green candle gain:=(high[u]-low[d])/low[d] //ratio of difference between maximum high and minimum low with respect to minimum low among continuously green candles if gain>0.2 array.insert(signal, a, true) //enter "true" after checking if gain is more than 20% amonng continuously green candles else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] and greenCandle[a+6] and greenCandle[a+7] and greenCandle[a+8] and greenCandle[a+9] and greenCandle[a+10] and greenCandle[a+11] and greenCandle[a+12] and greenCandle[a+13] and greenCandle[a+14] and greenCandle[a+15] i=for i=a to a+15 if max<high[i] max:=high[i] // to get maximum of high among continuously green candles u:=i // to get bar_index of maximum of high among continuously green candles j=for j=a to a+15 if min>low[j] min:=low[j] // to get minimum of low among green candles d:=j // to get bar_index of minimum of low among continuously green candle gain:=(high[u]-low[d])/low[d] //ratio of difference between maximum high and minimum low with respect to minimum low among continuously green candles if gain>0.2 array.insert(signal, a, true) //enter "true" after checking if gain is more than 20% amonng continuously green candles else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] and greenCandle[a+6] and greenCandle[a+7] and greenCandle[a+8] and greenCandle[a+9] and greenCandle[a+10] and greenCandle[a+11] and greenCandle[a+12] and greenCandle[a+13] and greenCandle[a+14] i=for i=a to a+14 if max<high[i] max:=high[i] // to get maximum of high among continuously green candles u:=i // to get bar_index of maximum of high among continuously green candles j=for j=a to a+14 if min>low[j] min:=low[j] // to get minimum of low among green candles d:=j // to get bar_index of minimum of low among continuously green candle gain:=(high[u]-low[d])/low[d] //ratio of difference between maximum high and minimum low with respect to minimum low among continuously green candles if gain>0.2 array.insert(signal, a, true) //enter "true" after checking if gain is more than 20% amonng continuously green candles else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] and greenCandle[a+6] and greenCandle[a+7] and greenCandle[a+8] and greenCandle[a+9] and greenCandle[a+10] and greenCandle[a+11] and greenCandle[a+12] and greenCandle[a+13] i=for i=a to a+13 if max<high[i] max:=high[i] // to get maximum of high among continuously green candles u:=i // to get bar_index of maximum of high among continuously green candles j=for j=a to a+13 if min>low[j] min:=low[j] // to get minimum of low among green candles d:=j // to get bar_index of minimum of low among continuously green candle gain:=(high[u]-low[d])/low[d] //ratio of difference between maximum high and minimum low with respect to minimum low among continuously green candles if gain>0.2 array.insert(signal, a, true) //enter "true" after checking if gain is more than 20% amonng continuously green candles else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] and greenCandle[a+6] and greenCandle[a+7] and greenCandle[a+8] and greenCandle[a+9] and greenCandle[a+10] and greenCandle[a+11] and greenCandle[a+12] i=for i=a to a+12 if max<high[i] max:=high[i] // to get maximum of high among continuously green candles u:=i // to get bar_index of maximum of high among continuously green candles j=for j=a to a+12 if min>low[j] min:=low[j] // to get minimum of low among green candles d:=j // to get bar_index of minimum of low among continuously green candle gain:=(high[u]-low[d])/low[d] //ratio of difference between maximum high and minimum low with respect to minimum low among continuously green candles if gain>0.2 array.insert(signal, a, true) //enter "true" after checking if gain is more than 20% amonng continuously green candles else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] and greenCandle[a+6] and greenCandle[a+7] and greenCandle[a+8] and greenCandle[a+9] and greenCandle[a+10] and greenCandle[a+11] i=for i=a to a+11 if max<high[i] max:=high[i] // to get maximum of high among continuously green candles u:=i // to get bar_index of maximum of high among continuously green candles j=for j=a to a+11 if min>low[j] min:=low[j] // to get minimum of low among green candles d:=j // to get bar_index of minimum of low among continuously green candle gain:=(high[u]-low[d])/low[d] //ratio of difference between maximum high and minimum low with respect to minimum low among continuously green candles if gain>0.2 array.insert(signal, a, true) //enter "true" after checking if gain is more than 20% amonng continuously green candles else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] and greenCandle[a+6] and greenCandle[a+7] and greenCandle[a+8] and greenCandle[a+9] and greenCandle[a+10] i=for i=a to a+10 if max<high[i] max:=high[i] // to get maximum of high among continuously green candles u:=i // to get bar_index of maximum of high among continuously green candles j=for j=a to a+10 if min>low[j] min:=low[j] // to get minimum of low among green candles d:=j // to get bar_index of minimum of low among continuously green candle gain:=(high[u]-low[d])/low[d] //ratio of difference between maximum high and minimum low with respect to minimum low among continuously green candles if gain>0.2 array.insert(signal, a, true) //enter "true" after checking if gain is more than 20% amonng continuously green candles else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] and greenCandle[a+6] and greenCandle[a+7] and greenCandle[a+8] and greenCandle[a+9] i=for i=a to a+9 if max<high[i] max:=high[i] u:=i j=for j=a to a+9 if min>low[j] min:=low[j] d:=j gain:=(high[u]-low[d])/low[d] if gain>0.2 array.insert(signal, a, true) else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] and greenCandle[a+6] and greenCandle[a+7] and greenCandle[a+8] i=for i=a to a+8 if max<high[i] max:=high[i] u:=i j=for j=a to a+8 if min>low[j] min:=low[j] d:=j gain:=(high[u]-low[d])/low[d] if gain>0.2 array.insert(signal, a, true) else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] and greenCandle[a+6] and greenCandle[a+7] i=for i=a to a+7 if max<high[i] max:=high[i] u:=i j=for j=a to a+7 if min>low[j] min:=low[j] d:=j gain:=(high[u]-low[d])/low[d] if gain>0.2 array.insert(signal, a, true) else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] and greenCandle[a+6] i=for i=a to a+6 if max<high[i] max:=high[i] u:=i j=for j=a to a+6 if min>low[j] min:=low[j] d:=j gain:=(high[u]-low[d])/low[d] if gain>0.2 array.insert(signal, a, true) else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] and greenCandle[a+5] i=for i=a to a+5 if max<high[i] max:=high[i] u:=i j=for j=a to a+5 if min>low[j] min:=low[j] d:=j gain:=(high[u]-low[d])/low[d] if gain>0.2 array.insert(signal, a, true) else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] and greenCandle[a+4] i=for i=a to a+4 if max<high[i] max:=high[i] u:=i j=for j=a to a+4 if min>low[j] min:=low[j] d:=j gain:=(high[u]-low[d])/low[d] if gain>0.2 array.insert(signal, a, true) else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] and greenCandle[a+3] i=for i=a to a+3 if max<high[i] max:=high[i] u:=i j=for j=a to a+3 if min>low[j] min:=low[j] d:=j gain:=(high[u]-low[d])/low[d] if gain>0.2 array.insert(signal, a, true) else if greenCandle[a]==true and greenCandle[a+1]==true and greenCandle[a+2] i=for i=a to a+2 if max<high[i] max:=high[i] u:=i j=for j=a to a+2 if min>low[j] min:=low[j] d:=j gain:=(high[u]-low[d])/low[d] if gain>0.2 array.insert(signal, a, true) else if greenCandle[a]==true and greenCandle[a+1]==true i=for i=a to a+1 if max<high[i] max:=high[i] u:=i j=for j=a to a+1 if min>low[j] min:=low[j] d:=j gain:=(high[u]-low[d])/low[d] if gain>0.2 array.insert(signal, a, true) else if greenCandle[a]==true gain:=(high[a]-low[a])/low[a] if gain>0.2 array.insert(signal, a, true) plotshape(array.get(signal,a), style=shape.triangleup, location=location.abovebar, color=color.green,size=size.small) // to plot triangle at the top of a bar if signal is "true"
CHAMELEON TRAIL
https://www.tradingview.com/script/8wzK9tG2-CHAMELEON-TRAIL/
ChartChameleon
https://www.tradingview.com/u/ChartChameleon/
19
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © SeekFind //@version=4 study("CHAMELEON TRAIL", overlay=false) // SET THE LENGTH by doing a Cycle Analysis prior to using // Supertrend indicator is best to used as a filter with other indicators. // Useful as a filter when back testing CHAMELEON TRADE IDEAS generation. // However, this indicator is not appropriate for all the situations. It works better when the market is trending (green or red background). // Supertrend uses only the two parameters of ATR and multiplier which are not sufficient under certain conditions to predict the accurate direction of the market. ma(source, length, type) => type == "SMA" ? sma(source, length) : type == "EMA" ? ema(source, length) : type == "SMMA (RMA)" ? rma(source, length) : type == "WMA" ? wma(source, length) : type == "VWMA" ? vwma(source, length) : na show_ma1 = input(true , "ma1", inline="MA #1") ma1_length = input(8 , "" , inline="MA #1", minval=1) ma1 = ma(close, ma1_length, "SMA") plot(show_ma1 ? ma1 : na, color = color.yellow, title="MA №1", linewidth=3) show_ma2 = input(true , "ma2", inline="MA #2") ma2_length = input(21 , "" , inline="MA #2", minval=1) ma2 = ma(close, ma2_length, "SMA") plot(show_ma2 ? ma2 : na, color = color.blue, title="MA №2", linewidth=3) atrPeriod = input (15, "Length") factor = input (3, "Factor") [supertrend, direction] = supertrend(factor, atrPeriod) bodyMiddle = plot((open+close)/2, display=display.none) upm = false downm = true upt = true downt = false Lizardcolor = color.black if direction < 0 upt := true downt := false else if direction > 0 upt := false downt := true if ma2 > ma1 downm := true upm := false else upm := true downm := true if ( downm == true and downt == true ) Lizardcolor := color.red if ( upm == true and upt == true ) Lizardcolor := color.green if ( not ( downm == true and downt == true ) and not ( upm == true and upt == true )) Lizardcolor := color.orange plot(upt ? supertrend : na, "Up trend", color = color.green, style = plot.style_linebr, linewidth=3) plot(downt ? supertrend : na, "Up trend", color = color.red, style = plot.style_linebr, linewidth=3) bgcolor(Lizardcolor, 40) alertcondition(condition= ( downm == true and downt == true ), title="CHAMELEON TRAIL DOWN", message="CHAMELEON TRAIL DOWN - Conditions may favour SHORTS") alertcondition(condition= ( upm == true and upt == true ) , title="CHAMELEON TRAIL UP", message="CHAMELEON TRAIL UP - Conditions may favour LONGS") alertcondition(condition= ( not ( downm == true and downt == true ) and not ( upm == true and upt == true )) , title="CHAMELEON TRAIL HIDDEN", message="CHAMELEON TRAIL MIXED SIGNAL - Conditions may favour SHORTS or LONGS or NONE!")
Matrix Functions test script - JD
https://www.tradingview.com/script/dMLrt4Mc-Matrix-Functions-test-script-JD/
Duyck
https://www.tradingview.com/u/Duyck/
43
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © jorisduyck //@version=5 indicator("Matrix Functions test script - JD") //@description This library converts 1D Pine arrays into 2D matrices and provides matrix manupulation and calculation functions. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// // The arrays provided in Pinescript are linear 1D strucures that can be seen either as a large vertical stack or // a horizontal row containing a list of values, colors, bools,.. // // With the FUNCTIONS in this script the 1D ARRAY LIST can be CONVERTED INTO A 2D MATRIX form // // /////////////////////////////////////////// /// BASIC INFO ON THE MATRIX STRUCTURE: /// /////////////////////////////////////////// // // The matrix is set up as an 2D structure and is devided in ROWS and COLUMNS. // following the standard mathematical notation: // // a 3 x 4 matrix = 4 columns // 0 1 2 3 column index // 0 [a b c d] // 3 rows 1 [e f g h] // 2 [i j k l] // row // index // // With the use of some purpose-built functions, values can be placed or retrieved in a specific column of a certain row // this can be done by intuitively using row_nr and column_nr coördinates, // without having to worry on what exact index of the Pine array this value is located (the functions do these conversions for you) // // // the syntax I propose for the 2D Matrix array has the following structure: // // - the array starts with 2 VALUES describing the DIMENSION INFORMATION, (rows, columns) // these are ignored in the actual calculations and serve as a metadata header (similar to the "location, time,... etc." data that is stored in photo files) // so the array always carries it's own info about the nr. of rows and columns and doesn't need is seperate "info" file! // // To stay consistent with the standard Pinescript (array and [lookback]) indexing: // - indexes for sheets and columns start from 0 (first) and run up to the (total nr of sheets or columns) - 1 // - indexes for rows also start from 0 (most recent, cfr.[lookback]) and run up to the (total nr of rows) - 1 // // - this 2 value metadata header is followed by the actual df data // the actual data array can consist of (100,000 - 2) usable items, // // In a theoretical example, you can have a matrix with almost 20,000 rows with each 5 columns of data (eg. open, high, low, close, volume) in it!!! // /////////////////////////////////// /// SCHEMATIC OF THE STRUCTURE: /// /////////////////////////////////// // ////// (metadata header with dimensions info) // // (0) (1) (array index) // [nr_of_rows/records, nr_of_columns, // // ////// (actual matrix array data) // // 0 1 2 3 column_index // // (2) (3) (4) (5) (array index) // 0 record0_val0, record0_val1, record0_val2, record0_val3, ..., // // (6) (7) (8) (9) (array index) // 1 record1_val0, record1_val1, record1_val2, record1_val3, ..., // // (10) (11) (12) (13) (array index) // 2 record2_val0, record2_val1, record2_val2, record2_val3, ..., // // 3 ... // // row_index // //////////////////////////////////// /// DATA MANIPULATION FUNCTIONS: /// //////////////////////////////////// // // A set of functions are implemented to write info to and retrieve info from the dataframe. // Of course the possibilities are not limited to the functions here, these were written because they were needed for the script! // A whole list of other functions can be easily written for other manipulation purposes. // The ones written in the script are 2D versions of most of the functions that are provided for normal 1D arrays. // // Feel free to use the functions library below in your scripts! A little shoutout would be nice, of course!! // // /////////////////////////////////////////////////////////////////////// /// LIST OF FUNCTIONS contained in this script: /// /// (many other can of course be written, using the same structure) /// /////////////////////////////////////////////////////////////////////// // // - INFO functions // * get the number of COLUMNS // * get the number of ROWS // * get the total SIZE (number of columns, number of rows) // // - INITIALISATION and SET functions (commands to build the 2D matrix) // * MATRIX INITIALISATION function, builds 2D matrix with dimensional metadata/size in first 2 values // // a new matrix array is built (cfr. the conventions I propose above) containing a certain nr of rows and columns // * function to SET a single value in a certain row/lookback period and column // // - GET functions (to retrieve info from the 2D matrix) // * function to GET/retrieve a single VALUE from a certain row/lookback period and column // * function to cut of the metadata header and return the array body (as an array) // * function to GET/retrieve the values from a ROW/RECORD from a certain row/lookback period, the values are returned as an array // // - 1D - 2D COORDINATE CONVERSION FUNCTIONS (handy with for loop indexes) /// // * function to get the ROW INDEX in a 2D matrix from the 1D array index // * function to get the COLUMN INDEX in a 2D matrix from the 1D array index // * function to get (row, column) coordinates in a 2D matrix from the 1D array index // * function to get the 1D array index from (row, column) coordinates in a 2D matrix // // - Matrix MANIPULATION functions // * function to ADD a ROW/RECORD on the TOP of the array, shift the whole list one down and REMOVE the OLDEST row/record // (2D version of "unshift" + "pop" but with a whole row at once) // * function to REMOVE one or more ROWS/RECORDS from a 2D matrix // (if from_row == to_row, only this row is removed) // * function to REMOVE one or more COLUMNS from a 2D matrix // (if from_column == to_column, only this column is removed) // * function to INSERT an ARRAY of ROWS/RECORDS at a certain row number in a 2D matrix // * function to INSERT an ARRAY of COLUMNS at a certain column number in a 2D matrix // * function to APPEND/ADD an ARRAY of ROWS/RECORDS to the BOTTOM of a 2D matrix // * function to APPEND/ADD an ARRAY of COLUMNS to the SIDE of a 2D matrix // * function to POP/REMOVE and return the last ROW/RECORD from the BOTTOM of a 2D matrix // * function to POP/REMOVE and return the last column from the SIDE of a 2D matrix // // - function to matrix.print a matrix // This function is mainly used for debugging purposes and displays the array as a 2D matrix notation // // // Enjoy! // JD. // // #NotTradingAdvice #DYOR // // Disclaimer. // I AM NOT A FINANCIAL ADVISOR. // THESE IDEAS ARE NOT ADVICE AND ARE FOR EDUCATION PURPOSES ONLY. // ALWAYS DO YOUR OWN RESEARCH! //} // Function declarations // //{ ///////////////////////////////////////////////////////////////////////////////// /// Import Matrix Functions /// ///////////////////////////////////////////////////////////////////////////////// //{ import Duyck/Matrix_Functions_Lib_JD/1 as matrix ///////////////////////////////////////////////////////////////////////////////// /// test section /// // set test matrices //{ a = matrix.from_list(3, 4, array.from( 11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34)) b = array.copy(a) [_rows, _columns] = matrix.get_size(a) if barstate.isfirst var matrix_layout = table.new("bottom_left", _columns + 4, _rows + 2, bgcolor = color.teal, frame_color = color.gray) table.cell(matrix_layout, 0, 0, " ") table.cell(matrix_layout, _columns + 3, 1, " ") for i = 1 to _rows table.cell(matrix_layout, 1, i, "[") table.cell(matrix_layout, _columns + 2, i, "]") if i > 0 and i < _rows + 1 for j = 0 to _columns - 1 table.cell(matrix_layout, j + 2, i, str.tostring(matrix.get(a, i - 1, j))) table.cell_set_text_color(matrix_layout, j + 1, i + 1, color.black) // array to test add row functions insert_row = matrix.from_list( 1, 4, array.from( 10, 20, 30, 40)) // array to test insert/append row functions insert_row_array = matrix.from_list(2, 4, array.from( 10, 20 ,30, 40, 50, 60, 70, 80)) // array to test add column functions insert_column = matrix.from_list(3, 1, array.from( 10, 20, 30, 40)) // array to test insert/append column functions insert_column_array = matrix.from_list(3, 2, array.from( 10, 20, 30, 40, 50, 60)) // array to test element wise multiplication function elem_multiplication_array = matrix.from_list(3, 4, array.from( 10, 20 ,30, 40, 20, 30, 40, 50, 30, 40, 50, 60)) // array to test multiplication function multiplication_array = matrix.from_list(4, 2, array.from( 2, 3, 2, 3, 2, 3, 2, 3)) // array to test determinant function determinant_array = matrix.from_list(4, 4, array.from( 4, 3, 2, 2, 0, 1,-3, 3, 0,-1, 3, 3, 0, 3, 1, 1)) //} // parameters to check behavior of functions //{ x = input.int(0, title="from") y = input.int(0, title="to (to chose only 1 row or column, set the same value for 'from' and 'to')") c_type = input.string("none", title = "result matrix", options = ["none", "add rows to top and shift list", "get row/record from list", "remove array of rows", "remove array of columns", "insert array of rows", "insert array of columns", "append array of rows", "append array of columns", "pop last row" , "pop last column", "element multiplication", "matrix multiplication", "matrix transposition", "matrix determinant"]) //} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// test function calls /// // /////////////////////////// // // // almost all functions can be called with or without a return array // // // for example, both notations below can be used: // // // // c = append_array_of_rows(a, append_array) -> returns the appended matrix as array "c" // // // // append_array_of_rows(a, append_array) -> just runs the function without creating a new array "c" // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// manipulation_array = c_type == "add rows to top and shift list" ? insert_row : c_type == "remove array of rows" ? insert_row_array : c_type == "remove array of columns" ? insert_column_array : c_type == "insert array of rows" ? insert_row_array : c_type == "insert array of columns" ? insert_column_array : c_type == "append array of rows" ? insert_row_array : c_type == "append array of columns" ? insert_column_array : c_type == "element multiplication" ? elem_multiplication_array : c_type == "matrix multiplication" ? multiplication_array : insert_row c = c_type == "add rows to top and shift list" ? matrix.add_row(a, manipulation_array) : c_type == "remove array of rows" ? matrix.remove_rows(a, x, y) : c_type == "remove array of columns" ? matrix.remove_columns(a, x, y) : c_type == "insert array of rows" ? matrix.insert_array_of_rows(a, manipulation_array, x) : c_type == "insert array of columns" ? matrix.insert_array_of_columns(a, manipulation_array, x) : c_type == "append array of rows" ? matrix.append_array_of_rows(a, manipulation_array) : c_type == "append array of columns" ? matrix.append_array_of_columns(a, manipulation_array) : c_type == "element multiplication" ? matrix.multiply_elem(a, manipulation_array) : c_type == "matrix multiplication" ? matrix.multiply(a, manipulation_array): c_type == "matrix transposition" ? matrix.transpose(a) : array.copy(a) e = c_type == "get row/record from list" ? matrix.get_record(a, x) : c_type == "pop last row" ? matrix.pop_row(a) : c_type == "pop last column" ? matrix.pop_column(a) : array.copy(a) // plot matrices //{ // copy of original matrix before "manipulation" if c_type != "matrix determinant" if barstate.isfirst matrix.print(b, pos = "middle_left", title = "original") // "manipulation" matrix if c_type != "remove array of rows" and c_type != "remove array of columns" and c_type != "get row/record from list" and c_type != "pop last row" and c_type != "pop last column" and c_type != "matrix transposition" and c_type != "matrix determinant" or c_type == "add rows to top and shift list" if barstate.isfirst matrix.print(manipulation_array, pos = "top_center", title = "work array") // original matrix if c_type != "matrix multiplication" and c_type != "element multiplication" and c_type != "matrix determinant" and c_type != "matrix transposition" if barstate.isfirst matrix.print(a, pos = "bottom_left", title = "modified original") // function title from = " (from = " + str.tostring(x) from_to = from + " -> to = " + str.tostring(y) + " )" title_txt = c_type + (c_type == "remove array of rows" or c_type == "remove array of columns" ? from_to : c_type == "insert array of rows" or c_type == "insert array of columns" or c_type == "get row/record from list" ? from + " )" : c_type == "matrix determinant" ? " det = " + str.tostring(matrix.determinant_4x4(determinant_array)) : "") if barstate.isfirst title_tab = table.new("bottom_center", 1, 1, bgcolor = color.orange) table.cell(title_tab, 0, 0, text = title_txt, text_color = color.black, text_size = size.large) // copy of resulting matrix if c_type != "get row/record from list" and c_type != "pop last row" and c_type != "pop last column" or c_type == "add rows to top and shift list" if barstate.isfirst matrix.print(c, pos = "middle_center", title = c_type == "matrix determinant" ? "original" : "result array") // copy of resulting matrix if c_type == "get row/record from list" or c_type == "pop last row" or c_type == "pop last column" and c_type != "matrix determinant" if barstate.isfirst result = array.copy(e) array.unshift(result, c_type == "pop last row" or c_type == "get row/record from list"? array.size(e) : 1) array.unshift(result, c_type == "pop last row" or c_type == "get row/record from list"? 1 : array.size(e)) matrix.print(result, pos = "middle_center", title = "result array") //}
Bitcoin - CME Futures Friday Close
https://www.tradingview.com/script/wf7E7MWQ-Bitcoin-CME-Futures-Friday-Close/
UniqueCharts
https://www.tradingview.com/u/UniqueCharts/
161
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © LeanWave //@version=5 indicator('Bitcoin - CME Futures Friday Close', overlay=true) mode = input.string( defval="1 - Close from current symbol", title="Mode", options=["1 - Close from current symbol", "2 - CME original close crice", "3 - CME settlement price"], tooltip="In Mode 1 the closing price is determined in the current symbol but with the tradinghours from the CME futures contract. Mode 2 and 3 obtain the price directly from the CME futures contract and paint it in the chart of the current symbol. But note, that modes 2 and 3 may not give you the expected result, due to price differences in futures and spot prices.") cme = request.security("CME:BTC1!", "60", close) cmeSettlement = request.security("CME:BTC1!", "D", close, lookahead=barmerge.lookahead_on) //Function to get friday closing price according to CME trading hours getCloseCME() => cmeClose = 0.0 cmeClosePrev = nz(cmeClose[1], cmeClose) showLine = 0 showLine := nz(showLine[1], showLine) if mode == "1 - Close from current symbol" cmeClose := dayofweek == 6 and time == timestamp('GMT-5', year, month, dayofmonth, 16, 0, 0) ? close[1] : cmeClosePrev else if mode == "2 - CME original close crice" cmeClose := dayofweek == 6 and time == timestamp('GMT-5', year, month, dayofmonth, 16, 0, 0) ? cme : cmeClosePrev else if mode == "3 - CME settlement price" cmeClose := dayofweek == 6 and time == timestamp('GMT-5', year, month, dayofmonth, 16, 0, 0) ? cmeSettlement : cmeClosePrev showLine := showLine == 0 and time >= timestamp('GMT-5', year, month, dayofmonth, 16, 0, 0) and dayofweek >= 6 ? 1 : showLine == 1 and dayofweek <= 1 and time >= timestamp('GMT-5', year, month, dayofmonth, 17, 0, 0) ? 0 : showLine [cmeClose, showLine] [cmeClose, showLine] = getCloseCME() //Plotting plot1 = plot(showLine == 1 ? cmeClose : na, 'CME Friday Close', style=plot.style_linebr, linewidth=2, color=color.new(color.blue, 0)) plot2 = plot(close, 'Dummy plot for background', color=na) fill(plot1, plot2, title='Background', color=close > cmeClose ? color.new(color.green, 80) : close < cmeClose ? color.new(color.red, 80) : na)
Classic Candlestick on Range Chart
https://www.tradingview.com/script/dJHRNxOU-Classic-Candlestick-on-Range-Chart/
GM_Trades
https://www.tradingview.com/u/GM_Trades/
195
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © GM_Trades //@version=5 indicator(title = "Classic Candlestick on Range Chart", shorttitle = "Candlestick Overlay", overlay = true) useHa = input.bool(defval = false, title = "Use Heikin-Ashi Candlesticks") f_HeikinAshi() => float _closeRSI = close float _openRSI = open float _highRSI_raw = high float _lowRSI_raw = low float _highRSI = math.max( _highRSI_raw, _lowRSI_raw ) float _lowRSI = math.min( _highRSI_raw, _lowRSI_raw ) float _close = ( _openRSI + _highRSI + _lowRSI + _closeRSI ) / 4 var float _open = na _open := na( _open[ 1 ] ) ? ( _openRSI + _closeRSI ) / 2 : ( ( _open[1] * 1 ) + _close[1] ) / ( 1 + 1 ) float _high = math.max( _highRSI, math.max( _open, _close ) ) float _low = math.min( _lowRSI, math.min( _open, _close ) ) [ _open, _high, _low, _close ] [ _open, _high, _low, _close ] = f_HeikinAshi() open_value = useHa ? _open : open close_value = useHa ? _close : close high_value = useHa ? _high : high low_value = useHa ? _low : low isBull = close_value > open_value plotcandle(isBull ? open_value : na, isBull ? high_value : na, isBull ? low_value : na, isBull ? close_value : na, title='Bull Candle', color = color.new(#26a69a,0), wickcolor=color.new(#26a69a,0), bordercolor = color.new(#26a69a,30)) plotcandle(isBull ? na : open_value, isBull ? na : high_value, isBull ? na : low_value, isBull ? na : close_value, title='Bear Candle', color = color.new(#d32f2f,0), wickcolor=color.new(#d32f2f,0), bordercolor = color.new(#d32f2f,30))
PowerLine by Dhruv
https://www.tradingview.com/script/fIySerAO-PowerLine-by-Dhruv/
odhruvji
https://www.tradingview.com/u/odhruvji/
91
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © odhruvji //@version=5 indicator("PowerLine by Dhruv", overlay = true, format=format.price, precision=2) PowerLineP=input.int(42, "PowerLineP", minval=5, maxval=100, step=1) PowerMax= ta.highest(high[1], PowerLineP) PowerMin= ta.lowest(low[1], PowerLineP) PowerMean=(PowerMax+PowerMin)/2 plot(PowerMax, title="PowerMax", color=color.green, transp=0) plot(PowerMin, title="PowerMin", color=color.red, transp=0) plot(PowerMean, title="PowerMean", color=color.black, transp=0) colorcode=(close>PowerMean)?(close>close[1]?color.rgb(0, 150, 0, 10):color.rgb(0, 150, 0, 70)):(close>close[1]?color.rgb(255, 0, 0, 70):color.rgb(255, 0, 0, 10)) barcolor(color=colorcode)
Silen's Financials P/E & P/S[x10] Rates
https://www.tradingview.com/script/FAywAPUM-Silen-s-Financials-P-E-P-S-x10-Rates/
The_Silen
https://www.tradingview.com/u/The_Silen/
158
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © The_Silen //@version=4 study("Silen's Financials P/E & P/S[x10] Rates", overlay=true, scale = scale.left) string str= (syminfo.prefix+":"+syminfo.ticker) float pe_rate_pos = 0 float pe_rate_neg = 0 int pe_rate_max = 100 transp_pe_pos = color.new(color.green,50) transp_pe_neg = color.new(color.red,50) eps_rate = financial (str, "EARNINGS_PER_SHARE", "TTM") pe_rate = close/eps_rate pe_rate_fwd_fq = financial (str, "PRICE_EARNINGS_FORWARD", "FQ") pe_rate_fwd_fy = financial (str, "PRICE_EARNINGS_FORWARD", "FY") tso = financial (str, "TOTAL_SHARES_OUTSTANDING", "FQ") rev_total = financial (str, "TOTAL_REVENUE", "TTM") market_cap = tso * close ps_rate = market_cap / rev_total ps_rate_fwd_fq = financial (str, "PRICE_SALES_FORWARD", "FQ") ps_rate_fwd_fy = financial (str, "PRICE_SALES_FORWARD", "FY") //targeta = close / (((ps_rate / 3) / 2) + ((pe_rate / 17.5) / 2)) if (pe_rate > 0) pe_rate_pos := pe_rate if (pe_rate < 0) pe_rate_neg := pe_rate *(-1) if (pe_rate_pos > pe_rate_max) pe_rate_pos := pe_rate_max if (pe_rate_neg > pe_rate_max) pe_rate_neg := pe_rate_max if (pe_rate_pos == 0) transp_pe_pos := color.new(color.green,100) if (pe_rate_neg == 0) transp_pe_neg := color.new(color.red,100) plot(pe_rate_pos, color = transp_pe_pos) plot(pe_rate_neg, color = transp_pe_neg) plot(ps_rate * 10, color = color.yellow, transp = 50 ) //plot(pe_rate_fwd_fq, color = color.white) //plot(pe_rate_fwd_fy, color = color.blue) //plot(targeta, color = color.purple)
tunnel trading beta
https://www.tradingview.com/script/s6lXtVqy/
zxcvbnm3260
https://www.tradingview.com/u/zxcvbnm3260/
89
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © zxcvbnm3260 //@version=5 indicator('vegas tunnel indicator', overlay=true) // calc_on_every_tick = true //版本更新记录: // v1.0 2021/08/25 周三 测试版上线。 // v1.1 2021/10/02 周六 短期趋势线变色;加入止盈和止损标记;允许自定义盈亏比。 // v1.2 2021/10/03 周日 上一版本脚本并不处理最近30根bar,而这一版本解决了这一问题。(The previous version script does not handle the last 30 bars, but this version solves this bug.) // v1.3 2021/10/03 周日 最后一根bar出现买入信号时,止损线和止盈线往前延伸。 // v1.4 2021/10/19 周二 使用ATR来校正过大的止盈和止损比例。(Use ATR to set excessive take-profit and stop-loss ranges.) // v2.0 2021/11/01 周一 将策略版改回指标版,以便获得进行中的bar的提醒。注释中包括了下单策略。(The order strategy is included in the comments) // 0.常量和初始化 N = input.float(title='请设置盈亏比', defval=1) trail_offset1 = 0.5 // 移动止盈开始位,是几倍止盈位? ratio_max_loss = 0.5 // 移动止盈开始后,最大浮盈损失多少比例就出场? DOWN_RATIO_FOR_ENTRY = -0.25 // 信号bar高点下降多少后可以入场?(1表示信号bar高点与低点之间的距离) var title='long1' // 1.基础变量 ema169 = ta.ema(close, 169) // ema144 = ta.ema(close, 144) ema12 = ta.ema(close, 12) ema576 = ta.ema(close, 576) ema676 = ta.ema(close, 676) plot(ema169, color=color.new(color.orange, 0), linewidth=2) // plot(ema144, color=color.orange) // plot(ema676, color=color.orange, linewidth=1) mtr = math.max(high - low, math.abs(close[1] - high), math.abs(close[1] - low)) atr = ta.ema(mtr, 30) is_0930 = hour(time, 'GMT-4') == 9 and minute(time, 'GMT-4') == 30 is_1500 = hour(time, 'GMT-4') == 15 and minute(time, 'GMT-4') == 00 is_1530 = hour(time, 'GMT-4') == 15 and minute(time, 'GMT-4') == 30 is_yangxian = close>open is_yinxian = close<open // 2.基本趋势标记 big_trend = ema12 >= ema169 ? 1 : 0 big_trend2 = ema12 <= ema169 ? 1 : 0 // 背景的变色处理: bgcolor(big_trend == 1 ? color.new(color.green, 90) : color.new(color.red, 90) ) big_trend1 = big_trend // 放宽EMA限制,让信号提早出现: if ema12<ema169 and math.abs(ema12-ema169)/ema169<0.001 big_trend1 := 1 if ema12>ema169 and math.abs(ema12-ema169)/ema169<0.001 big_trend2 := 1 // 上涨趋势开始: // up1 = ema12 >= ema169 and ema12[1] < ema169[1] up1 = big_trend1==1 and big_trend1[1]==0 bar_up1 = ta.valuewhen(up1, bar_index, 0) // if up1 // line1 = line.new(bar_index, low, bar_index, high, extend=extend.both, color=color.new(color.green, 50), width=5) // label.new(bar_index, high*1.1, '上涨趋势开始', style=label.style_label_down, textcolor=color.white, size=size.large) // 下降趋势开始: down1 = big_trend2==1 and big_trend2[1]==0 bar_down1 = ta.valuewhen(down1, bar_index, 0) // if down1 // line1 = line.new(bar_index, low, bar_index, high, extend=extend.both, color=color.new(color.red, 50), width=5) // label.new(bar_index, low*0.9, '下降趋势开始', style=label.style_label_up, textcolor=color.white, size=size.large) // 均线的变色处理: //上涨趋势中,短期均线上升时是绿色,下降时是酒红色。 // ema12>ema12[1]?color.green:color.purple //下降趋势中,短期均线上升时是绿色,下降时是鲜红色。 // ema12>ema12[1]?color.green:color.red plot(ema12, color=big_trend == 1 ? ema12 > ema12[1] ? color.green : color.purple : ema12 > ema12[1] ? color.green : color.red) plot(ema676, color=ema676 > ema676[1] ? color.green : color.black) is_entry0 = false if not is_1500 and not is_1530 and year>=2020 and month>=1 is_entry0 := true // 3.自定义函数 // 今日开盘至此bar时的最高点 slm_max_high_day()=> high1 = 0.0 for i = 0 to 20 if dayofmonth==dayofmonth[i] and time>=time[i] high1 := math.max(high1, high[i]) high1 // 今日开盘至此bar时的最低点 slm_min_low_day()=> low1 = 99999.9 for i = 0 to 20 if dayofmonth==dayofmonth[i] and time>=time[i] low1 := math.min(low1, low[i]) low1 // 标出各种点位 slm_lines(title, time2, stop_loss, price_in_max, stop_profit0, stop_profit)=> label.new(bar_index, low, title, style=label.style_label_up, textcolor=color.white, size=size.normal) line.new(time, stop_loss, time2, stop_loss, color=color.red, width=2, xloc = xloc.bar_time) // 止损位 line.new(time, price_in_max, time2, price_in_max, color=color.blue, xloc = xloc.bar_time) // 入场位 line.new(time, stop_profit0, time2, stop_profit0, color=color.green, xloc = xloc.bar_time) // 止盈位开始位 line.new(time, stop_profit, time2, stop_profit, color=color.green, width=2, xloc = xloc.bar_time) // 止盈位 // 做多类 slm_price_long()=> // stop_loss0 = is_0930 ? low : low[1] stop_loss0 = low[1] price_in_max = high - (high - low) * DOWN_RATIO_FOR_ENTRY length_stop_loss = math.min(price_in_max - stop_loss0, atr * 2) stop_loss = price_in_max - length_stop_loss stop_profit0 = price_in_max + length_stop_loss * trail_offset1 stop_profit = price_in_max + length_stop_loss * N trail_profit_max_loss = length_stop_loss * trail_offset1 * ratio_max_loss // 假设移动止盈开始后,浮盈立即损失最大比例(ratio_max_loss),则损失了多少利润? trail_offset2 = trail_profit_max_loss / stop_profit0 qty1 = int(10000/price_in_max) time2 = time+1000*3600*24 [stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2, qty1, time2] // slm_trades_long1(qty1, stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2)=> // strategy.entry("long1_open", strategy.long, qty1, limit = price_in_max, when = strategy.position_size==0) // strategy.exit("long1_close", qty = qty1, limit = stop_profit, trail_price = stop_profit0, trail_offset = trail_offset2, stop = stop_loss, oca_name = "exit") // slm_trades_long2(qty1, stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2)=> // strategy.entry("long2_open", strategy.long, qty1, limit = price_in_max, when = strategy.position_size==0) // strategy.exit("long2_close", qty = qty1, limit = stop_profit, trail_price = stop_profit0, trail_offset = trail_offset2, stop = stop_loss, oca_name = "exit") // 做空类 slm_price_short()=> // stop_loss0 = is_0930 ? high : high[1] stop_loss0 = high[1] price_in_max = low + (high - low) * DOWN_RATIO_FOR_ENTRY length_stop_loss = math.min(stop_loss0 - price_in_max, atr * 2) stop_loss = price_in_max + length_stop_loss stop_profit0 = price_in_max - length_stop_loss * trail_offset1 stop_profit = price_in_max - length_stop_loss * N trail_profit_max_loss = length_stop_loss * trail_offset1 * ratio_max_loss // 假设移动止盈开始后,浮盈立即损失最大比例(ratio_max_loss),则损失了多少利润? trail_offset2 = trail_profit_max_loss / stop_profit0 qty1 = int(10000/price_in_max) time2 = time+1000*3600*24 [stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2, qty1, time2] // slm_trades_short1(qty1, stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2)=> // strategy.entry("short1_open", strategy.short, qty1, limit = price_in_max, when = strategy.position_size==0) // strategy.exit("short1_close", qty = qty1, limit = stop_profit, trail_price = stop_profit0, trail_offset = trail_offset2, stop = stop_loss, oca_name = "exit") // slm_trades_short2(qty1, stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2)=> // strategy.entry("short2_open", strategy.short, qty1, limit = price_in_max, when = strategy.position_size==0) // strategy.exit("short2_close", qty = qty1, limit = stop_profit, trail_price = stop_profit0, trail_offset = trail_offset2, stop = stop_loss, oca_name = "exit") slm_msg(title)=> msg='{ "ticker":"' + syminfo.ticker + '", "k_time": "'+ timeframe.period + '", "type":"' + title + '", "timestamp": "' + str.tostring(time) + '", "atr": "' + str.tostring(atr, "#.000") + '", "close": "' + str.tostring(close, "#.000") + '", "high":"' + str.tostring(high, "#.000") + '", "low":"' + str.tostring(low, "#.000") + '", "high_1":"' + str.tostring(high[1],"#.000") + '", "low_1":"' + str.tostring(low[1], "#.000") + '" }' msg1 = slm_msg('long1') msg2 = slm_msg('long2') msg3 = slm_msg('short1') msg4 = slm_msg('short2') // 4.第一做多点(大趋势确立时的做多点) [stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2, qty1, time2] = slm_price_long() stop_loss_confirmed = stop_loss stop_profit0_confirmed = stop_profit0 interval_up1 = bar_index - bar_up1 chutou_up1 = close > open and close > high[1] // 是否“出头” var is_order_long1 = false if bar_index==bar_up1 is_order_long1 := false // long1的各个前提条件: // 1.大趋势变换次数<=3(排除震荡期) // 2.信号bar高点是当日最高点(上涨动能之前未消耗太多) // 3.连涨bar数<=4(上涨动能之前未消耗太多) is_trend_switch_freq = (bar_index - ta.valuewhen(up1, bar_index, 1))<19 is_highest_today = high==slm_max_high_day() is_5yang = is_yangxian and is_yangxian[1] and is_yangxian[2] and is_yangxian[3] and is_yangxian[4] // label.new(bar_index, low, str.tostring(is_trend_switch_freq), style=label.style_label_up, textcolor=color.white, size=size.normal) // label.new(bar_index, low, str.tostring(is_5yang), style=label.style_label_up, textcolor=color.white, size=size.normal) // if is_entry0 and chutou_up1 and not is_trend_switch_freq and is_highest_today and not is_5yang if is_entry0 and not is_trend_switch_freq and is_highest_today and not is_5yang title:='long1' if interval_up1 == 0 and big_trend1==1 is_order_long1 := true stop_loss_confirmed := stop_loss stop_profit0_confirmed := stop_profit0 slm_lines(title, time2, stop_loss, price_in_max, stop_profit0, stop_profit) // slm_trades_long1(qty1, stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2) alert(msg1, alert.freq_all) else if interval_up1 == 1 and not is_order_long1 and big_trend1*big_trend1[1]==1 is_order_long1 := true stop_loss_confirmed := stop_loss stop_profit0_confirmed := stop_profit0 slm_lines(title, time2, stop_loss, price_in_max, stop_profit0, stop_profit) // slm_trades_long1(qty1, stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2) alert(msg1, alert.freq_all) else if interval_up1 == 2 and not is_order_long1 and big_trend1*big_trend1[1]*big_trend1[2]==1 is_order_long1 := true stop_loss_confirmed := stop_loss stop_profit0_confirmed := stop_profit0 slm_lines(title, time2, stop_loss, price_in_max, stop_profit0, stop_profit) // slm_trades_long1(qty1, stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2) alert(msg1, alert.freq_all) else if interval_up1 == 3 and not is_order_long1 and big_trend1*big_trend1[1]*big_trend1[2]*big_trend1[3]==1 is_order_long1 := true stop_loss_confirmed := stop_loss stop_profit0_confirmed := stop_profit0 slm_lines(title, time2, stop_loss, price_in_max, stop_profit0, stop_profit) // slm_trades_long1(qty1, stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2) alert(msg1, alert.freq_all) // 5.回调结束时的做多点 up2 = big_trend1 == 1 and low <= ema169 and ema12 > ema169 and bar_index != bar_up1 // if up2 // label.new(bar_index, high, '拉回点', style=label.style_label_down, textcolor=color.white, size=size.normal) bar_up2 = ta.valuewhen(up2, bar_index, 0) interval_up2 = bar_index - bar_up2 chutou_up2 = chutou_up1 and ema12 > ema12[1] and big_trend1 == 1 var is_order_long2 = false if bar_index==bar_up2 is_order_long2 := false // long2的各个前提条件: // 1.大趋势变换次数<=3(排除震荡期) // 2.信号bar高点是当日最高点(上涨动能之前未消耗太多) // 3.连涨bar数<=4(上涨动能之前未消耗太多) // 4.最近10根bar内跌破EMA169的bar数<=2(证明EMA169有支撑作用) // 5.信号bar的高点距离EMA169必须 <= 4倍的ATR(上涨动能之前未消耗太多) is_under_ema169 = low<ema169 is_under_ema169_freq = (bar_index - ta.valuewhen(is_under_ema169, bar_index, 2))<=10 is_too_high = high-ema169 > atr*4 // plot(ema169+atr*4) // label.new(bar_index, low, str.tostring(ema169+atr*4), style=label.style_label_up, textcolor=color.white, size=size.normal) // if is_entry0 and chutou_up2 and not is_trend_switch_freq and is_highest_today and not is_5yang and not is_under_ema169_freq and not is_too_high if is_entry0 and not is_trend_switch_freq and is_highest_today and not is_5yang and not is_under_ema169_freq and not is_too_high title:='long2' if interval_up2 == 0 and big_trend1==1 is_order_long2 := true stop_loss_confirmed := stop_loss stop_profit0_confirmed := stop_profit0 slm_lines(title, time2, stop_loss, price_in_max, stop_profit0, stop_profit) // slm_trades_long2(qty1, stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2) alert(msg2, alert.freq_all) else if interval_up2 == 1 and not is_order_long2 and big_trend1*big_trend1[1]==1 is_order_long2 := true stop_loss_confirmed := stop_loss stop_profit0_confirmed := stop_profit0 slm_lines(title, time2, stop_loss, price_in_max, stop_profit0, stop_profit) // slm_trades_long2(qty1, stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2) alert(msg2, alert.freq_all) else if interval_up2 == 2 and not is_order_long2 and big_trend1*big_trend1[1]*big_trend1[2]==1 is_order_long2 := true stop_loss_confirmed := stop_loss stop_profit0_confirmed := stop_profit0 slm_lines(title, time2, stop_loss, price_in_max, stop_profit0, stop_profit) // slm_trades_long2(qty1, stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2) alert(msg2, alert.freq_all) else if interval_up2 == 3 and not is_order_long2 and big_trend1*big_trend1[1]*big_trend1[2]*big_trend1[3]==1 is_order_long2 := true stop_loss_confirmed := stop_loss stop_profit0_confirmed := stop_profit0 slm_lines(title, time2, stop_loss, price_in_max, stop_profit0, stop_profit) // slm_trades_long2(qty1, stop_loss, price_in_max, stop_profit0, stop_profit, trail_offset2) alert(msg2, alert.freq_all) // 6.第一做空点(大趋势确立时的做空点) [stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2, trail_offset2_2, qty1_2, time2_2] = slm_price_short() stop_loss_confirmed_2 = stop_loss_2 stop_profit0_confirmed_2 = stop_profit0_2 interval_down1 = bar_index - bar_down1 chutou_down1 = close < open and close < low[1] // 是否“落尾” var is_order_short1 = false if bar_index==bar_down1 is_order_short1 := false // label.new(bar_index, low, str.tostring(bar_index - ta.valuewhen(down1, bar_index, 1)), style=label.style_label_up, textcolor=color.white, size=size.normal) is_trend_switch_freq2 = (bar_index - ta.valuewhen(down1, bar_index, 1)) <19 is_lowest_today = low==slm_min_low_day() is_5yin = is_yinxian and is_yinxian[1] and is_yinxian[2] and is_yinxian[3] and is_yinxian[4] // if is_entry0 and chutou_down1 and not is_trend_switch_freq2 and is_lowest_today and not is_5yin if is_entry0 and not is_trend_switch_freq2 and is_lowest_today and not is_5yin title:='short1' if interval_down1 == 0 and big_trend2==1 is_order_short1 := true stop_loss_confirmed_2 := stop_loss_2 stop_profit0_confirmed_2 := stop_profit0_2 slm_lines(title, time2_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2) // slm_trades_short1(qty1_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2, trail_offset2_2) alert(msg3, alert.freq_all) else if interval_down1 == 1 and not is_order_short1 and big_trend2*big_trend2[1]==1 is_order_short1 := true stop_loss_confirmed_2 := stop_loss_2 stop_profit0_confirmed_2 := stop_profit0_2 slm_lines(title, time2_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2) // slm_trades_short1(qty1_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2, trail_offset2_2) alert(msg3, alert.freq_all) else if interval_down1 == 2 and not is_order_short1 and big_trend2*big_trend2[1]*big_trend2[2]==1 is_order_short1 := true stop_loss_confirmed_2 := stop_loss_2 stop_profit0_confirmed_2 := stop_profit0_2 slm_lines(title, time2_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2) // slm_trades_short1(qty1_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2, trail_offset2_2) alert(msg3, alert.freq_all) else if interval_down1 == 3 and not is_order_short1 and big_trend2*big_trend2[1]*big_trend2[2]*big_trend2[3]==1 is_order_short1 := true stop_loss_confirmed_2 := stop_loss_2 stop_profit0_confirmed_2 := stop_profit0_2 slm_lines(title, time2_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2) // slm_trades_short1(qty1_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2, trail_offset2_2) alert(msg3, alert.freq_all) // 7.反弹结束时的做空点 down2 = big_trend2 == 1 and high >= ema169 and ema12 < ema169 and bar_index != bar_down1 // if down2 // label.new(bar_index, high, '反弹点', style=label.style_label_down, textcolor=color.white, size=size.normal) bar_down2 = ta.valuewhen(down2, bar_index, 0) interval_down2 = bar_index - bar_down2 chutou_down2 = chutou_down1 and ema12 < ema12[1] and big_trend2 == 1 var is_order_short2 = false if bar_index==bar_down2 is_order_short2 := false is_over_ema169 = high>ema169 is_over_ema169_freq = (bar_index - ta.valuewhen(is_over_ema169, bar_index, 2)) <=10 is_too_low = ema169-low > atr*4 // plot(ema169-atr*4) // if is_entry0 and chutou_down2 and not is_trend_switch_freq2 and is_lowest_today and not is_5yin and not is_over_ema169_freq and not is_too_low if is_entry0 and not is_trend_switch_freq2 and is_lowest_today and not is_5yin and not is_over_ema169_freq and not is_too_low title:='short2' if interval_down2 == 0 and big_trend2==1 is_order_short2 := true stop_loss_confirmed_2 := stop_loss_2 stop_profit0_confirmed_2 := stop_profit0_2 slm_lines(title, time2_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2) // slm_trades_short2(qty1_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2, trail_offset2_2) alert(msg4, alert.freq_all) else if interval_down2 == 1 and not is_order_short2 and big_trend2*big_trend2[1]==1 is_order_short2 := true stop_loss_confirmed_2 := stop_loss_2 stop_profit0_confirmed_2 := stop_profit0_2 slm_lines(title, time2_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2) // slm_trades_short2(qty1_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2, trail_offset2_2) alert(msg4, alert.freq_all) else if interval_down2 == 2 and not is_order_short2 and big_trend2*big_trend2[1]*big_trend2[2]==1 is_order_short2 := true stop_loss_confirmed_2 := stop_loss_2 stop_profit0_confirmed_2 := stop_profit0_2 slm_lines(title, time2_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2) // slm_trades_short2(qty1_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2, trail_offset2_2) alert(msg4, alert.freq_all) else if interval_down2 == 3 and not is_order_short2 and big_trend2*big_trend2[1]*big_trend2[2]*big_trend2[3]==1 is_order_short2 := true stop_loss_confirmed_2 := stop_loss_2 stop_profit0_confirmed_2 := stop_profit0_2 slm_lines(title, time2_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2) // slm_trades_short2(qty1_2, stop_loss_2, price_in_max_2, stop_profit0_2, stop_profit_2, trail_offset2_2) alert(msg4, alert.freq_all) // // 尾盘平仓,且撤退场单 // strategy.close_all(when = strategy.position_size!=0 and is_1500) // // 各类撤单: // strategy.cancel(id = 'long1_open', when = strategy.position_size==0 and slm_max_high_day()>=stop_profit0_confirmed) // strategy.cancel(id = 'long2_open', when = strategy.position_size==0 and slm_max_high_day()>=stop_profit0_confirmed) // strategy.cancel(id = 'short1_open', when = strategy.position_size==0 and slm_min_low_day()<=stop_profit0_confirmed_2) // strategy.cancel(id = 'short2_open', when = strategy.position_size==0 and slm_min_low_day()<=stop_profit0_confirmed_2) // strategy.cancel(id = 'long1_close', when = strategy.position_size==0 and slm_max_high_day()>=stop_profit0_confirmed) // strategy.cancel(id = 'long2_close', when = strategy.position_size==0 and slm_max_high_day()>=stop_profit0_confirmed) // strategy.cancel(id = 'short1_close', when = strategy.position_size==0 and slm_min_low_day()<=stop_profit0_confirmed_2) // strategy.cancel(id = 'short2_close', when = strategy.position_size==0 and slm_min_low_day()<=stop_profit0_confirmed_2)
True Barcolor
https://www.tradingview.com/script/3jexQ7hE-True-Barcolor/
iitiantradingsage
https://www.tradingview.com/u/iitiantradingsage/
475
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © tradeswithashish //@version=5 indicator(title='SuperDuper Trend', overlay=true, shorttitle='SuperDuper trend') //variable declaration volMA = ta.sma(volume, 20) volcheck = volume > volMA atr = ta.atr(20) range1=math.max(open, close)-math.min(open, close) avgbarsize=ta.sma(range1, 100) cur_bar_len=range1>avgbarsize var Stoploss = high //finding true bull and bear bars bearcandle = close < open and volcheck and close < low[1] and volume > volume[1] and cur_bar_len and close<Stoploss bullcandle = close > open and volcheck and close > high[1] and volume > volume[1] and cur_bar_len and close>Stoploss //continuation criteria greenbar = ta.barssince(bullcandle) redbar = ta.barssince(bearcandle) //finding reversal candle exitbar= (greenbar<redbar and volume>volMA and volume>volume[1] and close<low[1]) or (greenbar>redbar and volume>volMA and volume>volume[1] and close>high[1]) //setting up bar color based whther they are color based reversal candle barcolor(greenbar==0?color.green:redbar==0?color.red:exitbar?color.blue:color.silver, title='Bar color') var trade=0 //setting up the stoplosses if bullcandle and (trade==0 or trade==-1) Stoploss:= low-atr trade:=1 if bearcandle and (trade==1 or trade==0) Stoploss:=high+atr trade:=-1 if bullcandle and trade==1 Stoploss:= math.max(Stoploss, low-atr) if bearcandle and trade==-1 Stoploss:= math.min(Stoploss, high+atr) //plotting trailing stoploss plot(Stoploss, title="stoploss line", style=plot.style_stepline_diamond, color=(greenbar > redbar ? color.green : color.red), linewidth=2) //Labelling of the potential entry points text1=bullcandle?"B":bearcandle?"S":na ourlabel=label.new(x=bar_index, y=na, text=text1,yloc=bearcandle? yloc.abovebar:yloc.belowbar, color=bullcandle?color.green:bearcandle?color.red:na, textcolor=color.white, style=bearcandle?label.style_label_down:bullcandle?label.style_label_up:label.style_none , size=size.tiny)
Auto AB=CD 1 to 1 Ratio Experimental
https://www.tradingview.com/script/QFlgcIPp-Auto-AB-CD-1-to-1-Ratio-Experimental/
RozaniGhani-RG
https://www.tradingview.com/u/RozaniGhani-RG/
367
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © RozaniGhani-RG //@version=5 indicator('Auto AB=CD 1 to 1 Ratio Experimental', overlay=true, max_bars_back=500, max_lines_count=500, max_labels_count=500, precision=2) // 0. Inputs // 1. Variables // 2. zig zag core (Credits to LonesomeTheBlue) // 3. Ternary conditional operator // 4. Custom functions // 5. Construct // 0. Inputs G1 = 'AB=CD Line & Label' G2 = 'AB=CD Table' I1 = '1' I2 = '2' I3 = '3' // group = G1 i_prd = input.int( 8, 'Period   ', inline = I1, group = G1, minval = 2) c_up = input.color(color.lime, '', inline = I1, group = G1) c_dn = input.color( color.red, '', inline = I1, group = G1) i_table = input.bool( true, 'Table', inline = I2, group = G2) // group = G2 i_font = input.string('normal', '', inline = I2, group = G2, options=['tiny', 'small', 'normal', 'large', 'huge']) i_Y = input.string('bottom', '', inline = I2, group = G2, options=['top', 'middle', 'bottom']) i_X = input.string( 'right', '', inline = I2, group = G2, options=['left', 'center', 'right']) i_currency = input.bool( true, 'Currency', inline = I3, group = G2) // 1. Variables // Common colors cnb = color.new(color.blue, 100) ck = color.black cb = color.blue cr = color.red // Common variables var max_array_size = 10 var zigzag = array.new_float(0) var float ratio_AB = 0 var float ratio_CD = 0 var abcd_table = table.new(i_Y + '_' + i_X, 4, 6, bgcolor = cnb, border_color = cnb, border_width = 1) // Show currency into cell // Dependency : i_currency ter_currency = switch i_currency true => syminfo.currency + ' ' // 2. zig zag core (Credits to LonesomeTheBlue) get_ph_pl_dir(len) => float ph = ta.highestbars(high, len) == 0 ? high : na float pl = ta.lowestbars( low, len) == 0 ? low : na var dir = 0 iff = pl and na(ph) ? -1 : dir dir := ph and na(pl) ? 1 : iff [ph, pl, dir] [ph, pl, dir] = get_ph_pl_dir(i_prd) add_to_zigzag(value, bindex) => array.unshift(zigzag, bindex) array.unshift(zigzag, value) if array.size(zigzag) > max_array_size array.pop(zigzag) array.pop(zigzag) update_zigzag(value, bindex) => if array.size(zigzag) == 0 add_to_zigzag(value, bindex) else if dir == 1 and value > array.get(zigzag, 0) or dir == -1 and value < array.get(zigzag, 0) array.set(zigzag, 0, value) array.set(zigzag, 1, bindex) 0. dir_changed = ta.change(dir) if ph or pl if dir_changed add_to_zigzag(dir == 1 ? ph : pl, time) else update_zigzag(dir == 1 ? ph : pl, time) // 3. Switch // Dependency : dir [pos, style1, style2] = switch dir 1 => [ 1, label.style_label_down, label.style_label_up ] => [-1, label.style_label_up, label.style_label_down] // 4. Custom functions // ABC custom functions f_line_solid_array(_value) => var line id = na, line.delete(id) // Dependency : zigzag id := line.new( x1 = math.round(array.get(zigzag, _value + 3)), y1 = array.get(zigzag, _value + 2), x2 = math.round(array.get(zigzag, _value + 1)), y2 = array.get(zigzag, _value), xloc = xloc.bar_time) id f_line_dot_get(_id1, _id2) => var line id = na, line.delete(id) id := line.new( x1 = line.get_x1(_id1), y1 = line.get_y1(_id1), x2 = line.get_x2(_id2), y2 = line.get_y2(_id2), xloc = xloc.bar_time, style = line.style_dotted) id f_label1(_id, _text, _style) => var label id = na label.delete(id) id := label.new(x=line.get_x1(_id), y=line.get_y1(_id), xloc=xloc.bar_time, text=_text, color=cnb, style=_style) id f_label2(_id, _text, _style) => var label id = na label.delete(id) id := label.new(x=line.get_x2(_id), y=line.get_y2(_id), xloc=xloc.bar_time, text=_text, color=cnb, style=_style) id // Shared custom functions f_dif(_id) => var int dx = 0, dx := int(math.abs(line.get_x1(_id) - line.get_x2(_id))) var float dy = 0, dy := math.abs(line.get_y1(_id) - line.get_y2(_id)) var int avg_x = 0, avg_x := int(math.avg(line.get_x1(_id), line.get_x2(_id))) var float avg_y = 0, avg_y := math.avg(line.get_y1(_id), line.get_y2(_id)) [dx, dy, avg_x, avg_y] f_label_avg(_x, _y, _text) => var label id = na label.delete(id) id := label.new(x=_x, y=_y, xloc=xloc.bar_time, text=str.tostring(_text, '0.000'), textcolor=ck, style=label.style_label_center) id // BCD custom function f_line_solid_future(_id1, _id2, _x, _y) => var line id = na line.delete(id) id := line.new(x1=label.get_x(_id1), y1=label.get_y(_id1), x2=label.get_x(_id2) + _x, y2=label.get_y(_id2) + _y, xloc=xloc.bar_time) id f_line_dot_future(_id1, _id2, _x, _y) => var line id = na line.delete(id) id := line.new(x1=label.get_x(_id1), y1=label.get_y(_id1), x2=label.get_x(_id2) + _x, y2=label.get_y(_id2) + _y, xloc=xloc.bar_time, style=line.style_dotted) id // Cell custom function f_cell(_column, _row, _text, _color) => table.cell(abcd_table, _column, _row, _text, bgcolor=_color, text_color=ck, text_size=i_font) // Ternary conditional operator custom functions f_cond1(_id1, _id2, _id3) => label.get_y(_id1) < label.get_y(_id2) and label.get_y(_id2) < label.get_y(_id3) f_cond2(_id1, _id2, _id3) => label.get_y(_id1) > label.get_y(_id2) and label.get_y(_id2) > label.get_y(_id3) // 5. Construct if barstate.islast and array.size(zigzag) > 6 // ABC lines line_BC = f_line_solid_array(0) line_AB = f_line_solid_array(2) // Dependencies : line_AB, line_BC line_AC = f_line_dot_get(line_AB, line_BC) // ABC labels recall from ABC lines // Dependency : line_AB label_A = f_label1(line_AB, 'A', style1) // Dependency : line_BC label_B = f_label1(line_BC, 'B', style2) label_C = f_label2(line_BC, 'C', style1) // Tuple values recall from ABC lines // Dependencies : line_AB, line_BC, line_AC [dx_AB, dy_AB, avg_x_AB, avg_y_AB] = f_dif(line_AB) [dx_BC, dy_BC, avg_x_BC, avg_y_BC] = f_dif(line_BC) [dx_AC, dy_AC, avg_x_AC, avg_y_AC] = f_dif(line_AC) // Retracement value // Dependencies : dy_BC, dy_AB ratio_AB := math.abs(dy_BC / dy_AB) // Conditional Retracement // Dependency : dir, ratio_AB txt_dir = dir == 1 and ratio_AB < 1 ? 'Bullish' : dir == -1 and ratio_AB < 1 ? 'Bearish' : dir == 1 and ratio_AB > 1 ? 'Bullish' : dir == -1 and ratio_AB > 1 ? 'Bearish' : '' txt_type = ratio_AB > 1 ? 'Reciprocal AB=CD' : ratio_AB < 1 ? 'AB=CD' : '' combo = dir == 1 and ratio_AB < 1 ? -1 : dir == -1 and ratio_AB < 1 ? -1 : dir == 1 and ratio_AB > 1 ? 1 : dir == -1 and ratio_AB > 1 ? 1 : 0 col = dir == 1 and ratio_AB < 1 ? c_up : dir == -1 and ratio_AB < 1 ? c_dn : dir == 1 and ratio_AB > 1 ? c_up : dir == -1 and ratio_AB > 1 ? c_dn : cb // BCD future line and label line_CD = f_line_solid_future(label_C, label_B, dx_AC, dy_AC * pos * combo) line_BD = f_line_dot_future(label_B, label_B, dx_AC, dy_AC * pos * combo) label_D = f_label2(line_CD, 'D', style2) // Tuple values recall from BCD lines // Dependencies : line_CD, line_BD [dx_CD, dy_CD, avg_x_CD, avg_y_CD] = f_dif(line_CD) [dx_BD, dy_BD, avg_x_BD, avg_y_BD] = f_dif(line_BD) // Projection value // Dependencies : dy_CD, dy_BC ratio_CD := math.abs(dy_CD / dy_BC) // Label Position for AB=CD value // Dependencies : avg_x_AC, avg_y_AC, ratio_AB label_AC = f_label_avg(avg_x_AC, avg_y_AC, ratio_AB) // Dependencies : avg_x_BD, avg_y_BD, ratio_CD label_BD = f_label_avg(avg_x_BD, avg_y_BD, ratio_CD) // Set color label.set_textcolor(label_A, col) label.set_textcolor(label_B, col) label.set_textcolor(label_C, col) label.set_textcolor(label_D, col) label.set_color(label_AC, col) label.set_color(label_BD, col) line.set_color(line_AB, col) line.set_color(line_BC, col) line.set_color(line_CD, col) line.set_color(line_AC, col) line.set_color(line_BD, col) // Show Table if i_table f_cell(0, 0, txt_dir, col) f_cell(1, 0, '', col) f_cell(2, 0, txt_type, col) f_cell(0, 1, 'Retracement', cr) f_cell(1, 1, 'A', cr) f_cell(2, 1, str.tostring(label.get_y(label_A), ter_currency + '#.#'), cr) f_cell(0, 2, str.tostring(ratio_AB, '0.000'), cr) f_cell(1, 2, 'B', cr) f_cell(2, 2, str.tostring(label.get_y(label_B), ter_currency + '#.#'), cr) f_cell(0, 3, 'Projection', cb) f_cell(1, 3, 'C', cb) f_cell(2, 3, str.tostring(label.get_y(label_C), ter_currency + '#.#'), cb) f_cell(0, 4, str.tostring(ratio_CD, '0.000'), cb) f_cell(1, 4, 'D', cb) f_cell(2, 4, str.tostring(label.get_y(label_D), ter_currency + '#.#'), cb)
RSI Overbought Divergence Indicator with Alerts
https://www.tradingview.com/script/YAGTVbO5-RSI-Overbought-Divergence-Indicator-with-Alerts/
imal_max
https://www.tradingview.com/u/imal_max/
216
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // made by Imal_Max // thanks to The1IamNeo's and brandons idea // // thanks to JayTradingCharts RSI Divergence /w Alerts indicator for the base code. //@version=5 // // 🔥 uncomment the line below to enable the alerts and disable the backtester indicator(title="Ultimate Bullish Divergence for RSI MFI RVSI OBV TRIXRSI w/ Buy Alerts", shorttitle="Ultimate Bull Divergence", format=format.price)//, timeframe="") // 🔥 comment the line below to disable the backtester + uncomment the lines slightly below and at the bottom of the script //strategy(title="Ultimate Bullish Divergence for RSI MFI RVSI OBV TRIXRSI w/ Buy Signals", shorttitle="Ultimate Bull Divergence Backtester", overlay=false, pyramiding=1, process_orders_on_close=true, calc_on_every_tick=true, initial_capital=1000, currency = currency.USD, default_qty_value=100, default_qty_type=strategy.percent_of_equity, commission_type=strategy.commission.percent, commission_value=0.05, slippage=2) selectOsc = input.string("RSI", title="Select Oscillator", group='═════════ Oscillator settings ══════════', options=["RSI","OBV","RVSI","MFI","TRIX RSI"], tooltip="RSI = Relative Strengh Index; OBV = On Balance Volume; RVSI = Relative Volume Strengh Index; MFI Money Flow Index; TRIX RSI = Tripple Exponetial Relative Strength") src = input.source(title='Oscillator Source', defval=low, group='═════════ Oscillator settings ══════════', tooltip="RSI, RVSI, OBV and TRIX RSI default Source: Close; MFI default Source: hlc3") len = input.int(title='Oscillator Length', minval=1, defval=14, group='═════════ Oscillator settings ══════════', tooltip="RSI/MFI default Period = 14; RVSI = 10; TRIX RSI = 9; OBV has no period.") seclen = input.int(9, minval=1, title="Oscillator secondary length", group="═════════ Oscillator settings ══════════", tooltip="affects only RVSI and Trix RSI. For the TRIX RSI this defines the length of the TRIX. default value = 9 and for the RVSI it defines the Volume moving average length, default value = 5") emalen = input(9, 'Oscillator Moving Average Length', group='═════════ Oscillator settings ══════════', tooltip="defines the length of the of the Oscillator moving average") rangeLower = input.int(title='Min Lookback Range', defval=0, group='═════ Oscillator Divergence Settings ══════', inline='Input 0') rangeUpper = input.int(title='Max Lookback', defval=200, group='═════ Oscillator Divergence Settings ══════', inline='Input 0', tooltip="reduces the Lookback range that you define with Pivot Lookback Left 1-30 ") enableonlyOneLB = input.bool(title='Only use the first look back period', defval=false, group='═════ Oscillator Divergence Settings ══════') lbL1 = input.int(title='Pivot Lookback Left-1', defval=2, group='═════ Oscillator Divergence Settings ══════', inline='Input 1', tooltip="Amount of bars to look back to find pivot lows on the Oscillator and Price") lbL2 = input.int(title='Lookback Left-2', defval=3, group='═════ Oscillator Divergence Settings ══════', inline='Input 1') lbL3 = input.int(title='Pivot Lookback Left-3', defval=4, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL4 = input.int(title='Lookback Left-4', defval=5, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL5 = input.int(title='Pivot Lookback Left-5', defval=6, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL6 = input.int(title='Lookback Left-6', defval=7, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL7 = input.int(title='Pivot Lookback Left-7', defval=9, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL8 = input.int(title='Lookback Left-8', defval=10, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL9 = input.int(title='Pivot Lookback Left-9', defval=11, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL10 = input.int(title='Lookback Left-10', defval=12, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL11 = input.int(title='Pivot Lookback Left-11', defval=13, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL12 = input.int(title='Lookback Left-12', defval=14, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL13 = input.int(title='Pivot Lookback Left-13', defval=15, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL14 = input.int(title='Lookback Left-14', defval=16, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL15 = input.int(title='Pivot Lookback Left-15', defval=17, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL16 = input.int(title='Lookback Left-16', defval=18, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL17 = input.int(title='Pivot Lookback Left-17', defval=19, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL18 = input.int(title='Lookback Left-18', defval=20, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL19 = input.int(title='Pivot Lookback Left-19', defval=22, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL20 = input.int(title='Lookback Left-20', defval=25, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL21 = input.int(title='Pivot Lookback Left-21', defval=28, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL22 = input.int(title='Lookback Left-22', defval=31, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL23 = input.int(title='Pivot Lookback Left-23', defval=34, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL24 = input.int(title='Lookback Left-24', defval=37, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL25 = input.int(title='Pivot Lookback Left-25', defval=39, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL26 = input.int(title='Lookback Left-26', defval=42, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL27 = input.int(title='Pivot Lookback Left-27', defval=45, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL28 = input.int(title='Lookback Left-28', defval=48, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL29 = input.int(title='Pivot Lookback Left-29', defval=51, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') lbL30 = input.int(title='Lookback Left-30', defval=54, group='═════ Oscillator Divergence Settings ══════', inline='Input 2') plotBull = input.bool(title='Plot Bullish', defval=true, group='═════ Oscillator Divergence Settings ══════', inline='Input 4', tooltip="Price makes a lower low while the Oscillator is making a higher low") plotHiddenBull = input.bool(title='Plot Hidden Bullish', defval=false, group='═════ Oscillator Divergence Settings ══════', inline='Input 4', tooltip="Price makes a higher low while Oscillator is making a lower low") ///////////// Delay inputs // Price bounce delay enablepriceBounceNeeded = input.bool(title='enable $ bounce delay', defval=false, group='═══════════ Signal Delays ═══════════') priceBounceNeeded = input.int(title='min $ bounce needed to flash buy', defval=35, group='═══════════ Signal Delays ═══════════') priceBounceNeededLbL = input.int(title='Amount of Candles until giving up', defval=3, minval=0, maxval=10, group='═══════════ Signal Delays ═══════════') // bars delay lbR = input.int(title='Confirmation Time (bars) needed', minval=0, defval=0, group='Time Delay', tooltip='0 means the first candle - no candle close needed to flash a signal. Wait for a candle close to be sure (for alerts on the first cadle close set it to 0 and set the to "once per bar close")') // EMA break delay enableWaitForEmaBreak = input.bool(title='enable wait for moving average break', defval=false, group='EMA break Delay', tooltip="waits for a break of the moving average to flash a signal") WaitForEmaBreakLen = input(5, 'EMA Length', group='EMA break Delay', tooltip="defines the length of the moving average which it needs to break before a signal flashes") // wait Oscillator and Oscillator EMA cross enableOscCross = input.bool(title='enable wait for Oscillator and Oscillator EMA Cross', defval=false, group='Oscillator EMA Cross Delay', tooltip="") oscCrosslookback = input.int(title='Amount of Candles until giving up', defval=3, minval=0, maxval=10, group='Oscillator EMA Cross Delay') // ranges and filter // only long on rising EMA inputs enableOnlyLongUptrend = input.bool(title='only long on in an uptrend (rising moving average)', defval=false, group='═══════════ Ranges & Filter ═══════════', tooltip="") OnlyLongUptrendEmaLen = input(200, 'EMA Length to determine an uptrend', group='═══════════ Ranges & Filter ═══════════', tooltip="defines the length of the of the moving average") EmaUptrend = ta.ema(src, OnlyLongUptrendEmaLen) isInEMAUptrend = ta.change(EmaUptrend) > 0 or not enableOnlyLongUptrend // ob/os divergence settings enableRsiLimit = input.bool(title='enable Oversold limits', defval=false, group='divergence below OverSold', tooltip="only works with RSI, MFI and RVSI") osvalue = input.int(title='only show Signals if the Oscillator was below', defval=30, group='divergence below OverSold', inline='Input 1') oslookback = input.int(title='within the last (x candles)', defval=2, group='divergence below OverSold', inline='Input 1') maxBullRSI = input.int(title='only show signals if the Oscillator is', defval=35, group='divergence below OverSold') // manual ranges for divergence enableManualbull1 = input.bool(title='enable manual Bullish Range-1', defval=false, group='══════ manual Range for divergence signal') manualbullHigh1 = input.int(title='Range 1 - Bullish high', defval=10000000, group='══════ manual Range for divergence signal', inline='Input 0') manualbullLow1 = input.int(title='Range 1 - Bullish low', defval=0, group='══════ manual Range for divergence signal', inline='Input 0') enableManualbull2 = input.bool(title='enable manual Bullish Range-2', defval=false, group='══════ manual Range for divergence signal') manualbullHigh2 = input.int(title='Range 2 - Bullish high', defval=10000000, group='══════ manual Range for divergence signal', inline='Input 1') manualbullLow2 = input.int(title='Range 2 - Bullish low', defval=0, group='══════ manual Range for divergence signal', inline='Input 1') enableManualbull3 = input.bool(title='enable manual Bullish Range-1', defval=false, group='══════ manual Range for divergence signal') manualbullHigh3 = input.int(title='Range 3 - Bullish high', defval=10000000, group='══════ manual Range for divergence signal', inline='Input 2') manualbullLow3 = input.int(title='Range 3 - Bullish low', defval=0, group='══════ manual Range for divergence signal', inline='Input 2') enableManualbull4 = input.bool(title='enable manual Bullish Range-2', defval=false, group='══════ manual Range for divergence signal') manualbullHigh4 = input.int(title='Range 4 - Bullish high', defval=10000000, group='══════ manual Range for divergence signal', inline='Input 3') manualbullLow4 = input.int(title='Range 4 - Bullish low', defval=0, group='══════ manual Range for divergence signal', inline='Input 3') // check if divergence happend within manual levels isWithinLongRange1 = (close < manualbullHigh1 and close > manualbullLow1) isWithinLongRange2 = (close < manualbullHigh2 and close > manualbullLow2) isWithinLongRange3 = (close < manualbullHigh3 and close > manualbullLow3) isWithinLongRange4 = (close < manualbullHigh4 and close > manualbullLow4) isWithinLongRange = true if enableManualbull1 or enableManualbull2 or enableManualbull3 or enableManualbull4 isWithinLongRange := (isWithinLongRange1 and enableManualbull1) or (isWithinLongRange2 and enableManualbull2) or (isWithinLongRange3 and enableManualbull3) or (isWithinLongRange4 and enableManualbull4) /////////////////////////// Get ranges to look for divergences from indicators // EMA // EMA Bull range high enableEmaBullHigh = input.bool(title='enable EMA as High of the Long Range', defval=false, group='══════ EMA Range for divergence signal') emaBullHighLen = input.int(9, minval=1, title='Length', group='══════ EMA Range for divergence signal', inline='Input 4') emaBullHighSrc = input(close, title='Source', group='══════ EMA Range for divergence signal', inline='Input 4') emaBullHighDevi = input.int(title='deviation', defval=0, minval=-500, maxval=500, group='══════ EMA Range for divergence signal', inline='Input 4') emaBullHighOut = ta.sma(emaBullHighSrc, emaBullHighLen) isBelowEmaBullHigh = close < emaBullHighOut or not enableEmaBullHigh // EMA Bull range low enableEmaBullLow = input.bool(title='enable EMA as Low of the Long Range', defval=false, group='══════ EMA Range for divergence signal') emaBullLowLen = input.int(55, minval=1, title='Length', group='══════ EMA Range for divergence signal', inline='Input 5') emaBullLowSrc = input(close, title='Source', group='══════ EMA Range for divergence signal', inline='Input 5') emaBullLowOffset = input.int(title='deviation', defval=0, minval=-500, maxval=500, group='══════ EMA Range for divergence signal', inline='Input 5') emaBullLowOut = ta.sma(emaBullLowSrc, emaBullLowLen) isBelowEmaBullLow = close > emaBullLowOut or not enableEmaBullLow iswithinEmaRange = isBelowEmaBullHigh and isBelowEmaBullLow // EMA END // VWAP enableVwapBullHigh = input.bool(title='enable VWAP as High of the Long Range', defval=false, group='════ VWAP Range for divergence signal') enableVwapBullLow = input.bool(title='enable VWAP as Low of the Long Range', defval=false, group='════ VWAP Range for divergence signal') enableVwapDiviBullHigh = input.bool(title='enable VWAP Upper Diviation as High of the Long Range', defval=false, group='════ VWAP Range for divergence signal') enableVwapDiviBullLow = input.bool(title='enable VWAP Lower Diviation as Low of the Long Range', defval=false, group='════ VWAP Range for divergence signal') computeVWAP(src, isNewPeriod, stDevMultiplier) => var float sumSrcVol = na var float sumVol = na var float sumSrcSrcVol = na sumSrcVol := isNewPeriod ? src * volume : src * volume + sumSrcVol[1] sumVol := isNewPeriod ? volume : volume + sumVol[1] // sumSrcSrcVol calculates the dividend of the equation that is later used to calculate the standard deviation sumSrcSrcVol := isNewPeriod ? volume * math.pow(src, 2) : volume * math.pow(src, 2) + sumSrcSrcVol[1] _vwap = sumSrcVol / sumVol variance = sumSrcSrcVol / sumVol - math.pow(_vwap, 2) variance := variance < 0 ? 0 : variance stDev = math.sqrt(variance) lowerBand = _vwap - stDev * stDevMultiplier upperBand = _vwap + stDev * stDevMultiplier [_vwap, lowerBand, upperBand] hideonDWM = false var anchor = input.string(defval='Session', title='Anchor Period', options=['Session', 'Week', 'Month', 'Quarter', 'Year', 'Decade', 'Century', 'Earnings', 'Dividends', 'Splits'], group='VWAP Settings') vsrc = input.source(title='Source', defval=hlc3, group='VWAP Settings') offset = input.int(0, title='Offset', group='VWAP Settings') stdevMult = input.float(1.0, title='Bands Standard Diviation Multiplier', group='VWAP Settings') timeChange(period) => ta.change(time(period)) new_earnings = request.earnings(syminfo.tickerid, earnings.actual, barmerge.gaps_on, barmerge.lookahead_on) new_dividends = request.dividends(syminfo.tickerid, dividends.gross, barmerge.gaps_on, barmerge.lookahead_on) new_split = request.splits(syminfo.tickerid, splits.denominator, barmerge.gaps_on, barmerge.lookahead_on) isNewPeriod = anchor == 'Earnings' ? new_earnings : anchor == 'Dividends' ? new_dividends : anchor == 'Splits' ? new_split : na(vsrc[1]) ? true : anchor == 'Session' ? timeChange('D') : anchor == 'Week' ? timeChange('W') : anchor == 'Month' ? timeChange('M') : anchor == 'Quarter' ? timeChange('3M') : anchor == 'Year' ? timeChange('12M') : anchor == 'Decade' ? timeChange('12M') and year % 10 == 0 : anchor == 'Century' ? timeChange('12M') and year % 100 == 0 : false float vwapValue = na float std = na float upperBandValue = na float lowerBandValue = na showBands = true if not(hideonDWM and timeframe.isdwm) [_vwap, bottom, top] = computeVWAP(vsrc, isNewPeriod, stdevMult) vwapValue := _vwap upperBandValue := showBands ? top : na lowerBandValue := showBands ? bottom : na // check if inside VWAP Range isBelowVwap = vwapValue < close or not enableVwapBullHigh isAboveVwap = vwapValue > close or not enableVwapBullLow isAboveVwapLowerDivi = lowerBandValue < close or not enableVwapDiviBullLow isBelowVwapUpperDivi = upperBandValue > close or not enableVwapDiviBullHigh isWithinVwapRange = isBelowVwap and isAboveVwap and isAboveVwapLowerDivi and isBelowVwapUpperDivi // VWAP END // auto fib ranges // fib fibbull range high enablefibbullHigh = input.bool(title='enable Auto fib as High of the Long Range', defval=false, group='════ auto fib range for divergence signal', inline='Input 0') selectfibbullHigh = input.float(0.5, 'fib Level', options=[0, 0.236, 0.382, 0.5, 0.618, 0.702, 0.71, 0.786, 0.83, 0.886, 1], group='══ auto fib range for divergence signal') fibbullHighLookback = input.int(title='Auto Fib Lookback', minval=1, defval=200, group='════ auto fib range for divergence signal', inline='Input 1') //fibbullHighDivi = input.int(title='diviation in %', defval=5, group='══ auto fib range for divergence signal', inline='Input 1') // fib fibbull range low enablefibbullLow = input.bool(title='enable Auto fib as Low of the Long Range', defval=false, group='════ auto fib range for divergence signal', inline='Input 2') selectfibbullLow = input.float(0.886, 'fib Level', options=[0, 0.236, 0.382, 0.5, 0.618, 0.702, 0.71, 0.786, 0.83, 0.886, 1], group='════ auto fib range for divergence signal') fibbullLowhLookback = input.int(title='Auto Fib Lookback', minval=1, defval=200, group='════ auto fib range for divergence signal', inline='Input 3') //fibbullLowhDivi = input.int(title='diviation in %', defval=5, group='══ auto fib range for divergence signal', inline='Input 3') isBelowfibbullHigh = true isBelowfibbullLow = true fibLowPrice = 0.1 fibHighPrice = 0.1 fibHighLow = 0.1 fibHighHigh = 0.1 fibLowHigh = 0.1 fibLowLow = 0.1 if enablefibbullHigh fibHighHigh := ta.highest(high, fibbullHighLookback) fibHighLow := ta.lowest(low, fibbullHighLookback) fibHighPrice := (fibHighHigh - fibHighLow) * (1 - selectfibbullHigh) + fibHighLow //+ fibbullHighDivi isBelowfibbullHigh := fibHighPrice > ta.lowest(low, 2) or not enablefibbullHigh if enablefibbullLow fibLowHigh := ta.highest(high, fibbullLowhLookback) fibLowLow := ta.lowest(low, fibbullLowhLookback) fibLowPrice := (fibLowHigh - fibLowLow) * (1 - selectfibbullLow) + fibLowLow// + fibbullLowhDivi isBelowfibbullLow := fibLowPrice < ta.highest(low, 2) or not enablefibbullLow //plot(fibHighHigh) //plot(fibHighLow) //plot(fibHighPrice, color=color.orange) //plot(fibLowPrice, color=color.orange) isWithinFibRange = isBelowfibbullHigh and isBelowfibbullLow /////// auto fib END /// Ranges checks isWithinLongRanges = isWithinLongRange and iswithinEmaRange and isWithinVwapRange and isWithinFibRange and isInEMAUptrend // divergence label colors bullColor = color.purple bullColor1 = color.aqua bullColor2 = color.black bullColor3 = color.blue bullColor4 = color.fuchsia bullColor5 = color.gray bullColor6 = color.green bullColor7 = color.lime bullColor8 = color.maroon bullColor9 = color.navy bullColor10 = color.olive bullColor11 = color.orange bullColor12 = color.purple bullColor13 = color.red bullColor14 = color.silver bullColor15 = color.teal bullColor16 = color.blue bullColor17 = color.navy bullColor18 = color.purple bullColor19 = color.purple bullColor20 = color.red bullColor21 = color.orange bullColor22 = color.purple bullColor23 = color.red bullColor24 = color.silver bullColor25 = color.teal bullColor26 = color.lime bullColor27 = color.fuchsia bullColor28 = color.lime bullColor29 = color.purple bullColor30 = color.red bullColor31 = color.aqua bullColor32 = color.black bullColor33 = color.blue bullColor34 = color.fuchsia bullColor35 = color.gray hiddenBullColor = color.new(color.purple, 80) textColor = color.white noneColor = color.new(color.white, 100) //// Oscillators // set the var to RSI to make it work osc = ta.rsi(src, len) // calculate RSI if selectOsc == "RSI" osc := ta.rsi(src, len) // calculate RVSI if selectOsc == "RVSI" nv = ta.cum(ta.change(src) * volume) av = ta.ema(nv, seclen) RVSI = ta.rsi(av, len) osc := RVSI // getting OBV if selectOsc == "OBV" osc := ta.obv // calculate MFI if selectOsc == "MFI" upper = math.sum(volume * (ta.change(src) <= 0 ? 0 : src), len) lower = math.sum(volume * (ta.change(src) >= 0 ? 0 : src), len) osc := 100.0 - 100.0 / (1.0 + upper / lower) if selectOsc == "TRIX RSI" trix = 10000 * ta.change(ta.ema(ta.ema(ta.ema(math.log(src), seclen), seclen), seclen)) osc := ta.rsi(trix, len) oscema = ta.ema(osc, emalen) //// Oscillators //////////////// Oscillator Conditions // check if RSI was OS or OB recently osLowestRsi = ta.lowest(osc, oslookback) RSIwasBelowOS = osLowestRsi < osvalue or not enableRsiLimit // check if RSI is below maxBullRSI and above minBearRSI isBelowRsiBull = osc < maxBullRSI or not enableRsiLimit /////////////////// plot ob os levels osLevel = hline(osvalue, title='Oversold', linestyle=hline.style_dotted) maxRSIline = hline(maxBullRSI, title='max RSI for Bull divergence', linestyle=hline.style_dotted) //fill(osLevel, maxRSIline, title='Bull Zone Background', color=color.new(#4caf50, 90)) //RSI0line = hline(0, title='RSI 0 Line', linestyle=hline.style_dotted) //RSI100line = hline(100, title='RSI 100 Line', linestyle=hline.style_dotted) //fill(osLevel, RSI0line, title='Oversold Zone Background', color=color.new(#4caf50, 75)) ////////////////////// plot Oscillator, histogram and Oscillator ema plot(osc, title='Oscillator', linewidth=2, color=color.new(#00bcd4, 0)) plot(oscema, color=color.purple, title='Oscillator EMA', style=plot.style_circles) //hist = osc - oscema //plot(hist, title='Oscillator Histogram', style=plot.style_columns, color=hist >= 0 ? hist[1] < hist ? color.lime : color.purple : hist[1] < hist ? color.orange : color.red) //////////////////// plot Oscillator, histogram and Oscillator ema END //////////////// divergence stuff start ////// divergence Lookback period #1 // get pivots plFound1 = na(ta.pivotlow(osc, lbL1, lbR)) ? false : true _inRange1(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL1 = osc[lbR] > ta.valuewhen(plFound1, osc[lbR], 1) and _inRange1(plFound1[1]) // Price: Lower Low priceLL1 = low[lbR] < ta.valuewhen(plFound1, low[lbR], 1) bullCond1 = plotBull and priceLL1 and oscHL1 and plFound1 and RSIwasBelowOS and isWithinLongRanges //plot(plFound1 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond1 ? bullColor : noneColor) plotshape(bullCond1 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 1 Label', text=' B1 ', style=shape.labelup, location=location.absolute, color=bullColor1, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL1 = osc[lbR] < ta.valuewhen(plFound1, osc[lbR], 1) and _inRange1(plFound1[1]) // Price: Higher Low priceHL1 = low[lbR] > ta.valuewhen(plFound1, low[lbR], 1) hiddenBullCond1 = plotHiddenBull and priceHL1 and oscLL1 and plFound1 and RSIwasBelowOS and isWithinLongRanges //plot(plFound1 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond1 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond1 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 1 Label', text=' H B1 ', style=shape.labelup, location=location.absolute, color=bullColor1, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #1 END ////// divergence Lookback period #2 // get pivots plFound2 = na(ta.pivotlow(osc, lbL2, lbR)) ? false : true _inRange2(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL2 = osc[lbR] > ta.valuewhen(plFound2, osc[lbR], 1) and _inRange2(plFound2[1]) // Price: Lower Low priceLL2 = low[lbR] < ta.valuewhen(plFound2, low[lbR], 1) bullCond2 = plotBull and priceLL2 and oscHL2 and plFound2 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound2 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond2 ? bullColor : noneColor) plotshape(bullCond2 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 2 Label', text=' B2 ', style=shape.labelup, location=location.absolute, color=bullColor2, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL2 = osc[lbR] < ta.valuewhen(plFound2, osc[lbR], 1) and _inRange2(plFound2[1]) // Price: Higher Low priceHL2 = low[lbR] > ta.valuewhen(plFound2, low[lbR], 1) hiddenBullCond2 = plotHiddenBull and priceHL2 and oscLL2 and plFound2 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound2 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond2 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond2 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 2 Label', text=' H B2 ', style=shape.labelup, location=location.absolute, color=bullColor2, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #3 // get pivots plFound3 = na(ta.pivotlow(osc, lbL3, lbR)) ? false : true _inRange3(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL3 = osc[lbR] > ta.valuewhen(plFound3, osc[lbR], 1) and _inRange3(plFound3[1]) // Price: Lower Low priceLL3 = low[lbR] < ta.valuewhen(plFound3, low[lbR], 1) bullCond3 = plotBull and priceLL3 and oscHL3 and plFound3 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound3 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond3 ? bullColor : noneColor) plotshape(bullCond3 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 3 Label', text=' B3 ', style=shape.labelup, location=location.absolute, color=bullColor3, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL3 = osc[lbR] < ta.valuewhen(plFound3, osc[lbR], 1) and _inRange3(plFound3[1]) // Price: Higher Low priceHL3 = low[lbR] > ta.valuewhen(plFound3, low[lbR], 1) hiddenBullCond3 = plotHiddenBull and priceHL3 and oscLL3 and plFound3 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound3 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond3 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond3 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 3 Label', text=' H B3 ', style=shape.labelup, location=location.absolute, color=bullColor3, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #3 END ////// divergence Lookback period #4 // get pivots plFound4 = na(ta.pivotlow(osc, lbL4, lbR)) ? false : true _inRange4(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL4 = osc[lbR] > ta.valuewhen(plFound4, osc[lbR], 1) and _inRange4(plFound4[1]) // Price: Lower Low priceLL4 = low[lbR] < ta.valuewhen(plFound4, low[lbR], 1) bullCond4 = plotBull and priceLL4 and oscHL4 and plFound4 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound4 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond4 ? bullColor : noneColor) plotshape(bullCond4 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 4 Label', text=' B4 ', style=shape.labelup, location=location.absolute, color=bullColor4, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL4 = osc[lbR] < ta.valuewhen(plFound4, osc[lbR], 1) and _inRange4(plFound4[1]) // Price: Higher Low priceHL4 = low[lbR] > ta.valuewhen(plFound4, low[lbR], 1) hiddenBullCond4 = plotHiddenBull and priceHL4 and oscLL4 and plFound4 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound4 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond4 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond4 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 4 Label', text=' H B4 ', style=shape.labelup, location=location.absolute, color=bullColor4, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #4 END ////// divergence Lookback period #5 // get pivots plFound5 = na(ta.pivotlow(osc, lbL5, lbR)) ? false : true _inRange5(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL5 = osc[lbR] > ta.valuewhen(plFound5, osc[lbR], 1) and _inRange5(plFound5[1]) // Price: Lower Low priceLL5 = low[lbR] < ta.valuewhen(plFound5, low[lbR], 1) bullCond5 = plotBull and priceLL5 and oscHL5 and plFound5 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound5 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond5 ? bullColor : noneColor) plotshape(bullCond5 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 5 Label', text=' B5 ', style=shape.labelup, location=location.absolute, color=bullColor5, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL5 = osc[lbR] < ta.valuewhen(plFound5, osc[lbR], 1) and _inRange5(plFound5[1]) // Price: Higher Low priceHL5 = low[lbR] > ta.valuewhen(plFound5, low[lbR], 1) hiddenBullCond5 = plotHiddenBull and priceHL5 and oscLL5 and plFound5 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound5 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond5 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond5 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 5 Label', text=' H B5 ', style=shape.labelup, location=location.absolute, color=bullColor5, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #5 END ////// divergence Lookback period #6 // get pivots plFound6 = na(ta.pivotlow(osc, lbL6, lbR)) ? false : true _inRange6(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL6 = osc[lbR] > ta.valuewhen(plFound6, osc[lbR], 1) and _inRange6(plFound6[1]) // Price: Lower Low priceLL6 = low[lbR] < ta.valuewhen(plFound6, low[lbR], 1) bullCond6 = plotBull and priceLL6 and oscHL6 and plFound6 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound6 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond6 ? bullColor : noneColor) plotshape(bullCond6 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 6 Label', text=' B6 ', style=shape.labelup, location=location.absolute, color=bullColor6, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL6 = osc[lbR] < ta.valuewhen(plFound6, osc[lbR], 1) and _inRange6(plFound6[1]) // Price: Higher Low priceHL6 = low[lbR] > ta.valuewhen(plFound6, low[lbR], 1) hiddenBullCond6 = plotHiddenBull and priceHL6 and oscLL6 and plFound6 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound6 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond6 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond6 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 6 Label', text=' H B6 ', style=shape.labelup, location=location.absolute, color=bullColor6, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #6 END ////// divergence Lookback period #7 // get pivots plFound7 = na(ta.pivotlow(osc, lbL7, lbR)) ? false : true _inRange7(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL7 = osc[lbR] > ta.valuewhen(plFound7, osc[lbR], 1) and _inRange7(plFound7[1]) // Price: Lower Low priceLL7 = low[lbR] < ta.valuewhen(plFound7, low[lbR], 1) bullCond7 = plotBull and priceLL7 and oscHL7 and plFound7 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound7 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond7 ? bullColor : noneColor) plotshape(bullCond7 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 7 Label', text=' B7 ', style=shape.labelup, location=location.absolute, color=bullColor7, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL7 = osc[lbR] < ta.valuewhen(plFound7, osc[lbR], 1) and _inRange7(plFound7[1]) // Price: Higher Low priceHL7 = low[lbR] > ta.valuewhen(plFound7, low[lbR], 1) hiddenBullCond7 = plotHiddenBull and priceHL7 and oscLL7 and plFound7 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound7 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond7 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond7 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 7 Label', text=' H B7 ', style=shape.labelup, location=location.absolute, color=bullColor7, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #7 END ////// divergence Lookback period #8 // get pivots plFound8 = na(ta.pivotlow(osc, lbL8, lbR)) ? false : true _inRange8(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL8 = osc[lbR] > ta.valuewhen(plFound8, osc[lbR], 1) and _inRange8(plFound8[1]) // Price: Lower Low priceLL8 = low[lbR] < ta.valuewhen(plFound8, low[lbR], 1) bullCond8 = plotBull and priceLL8 and oscHL8 and plFound8 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound8 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond8 ? bullColor : noneColor) plotshape(bullCond8 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 8 Label', text=' B8 ', style=shape.labelup, location=location.absolute, color=bullColor8, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL8 = osc[lbR] < ta.valuewhen(plFound8, osc[lbR], 1) and _inRange8(plFound8[1]) // Price: Higher Low priceHL8 = low[lbR] > ta.valuewhen(plFound8, low[lbR], 1) hiddenBullCond8 = plotHiddenBull and priceHL8 and oscLL8 and plFound8 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound8 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond8 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond8 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 8 Label', text=' H B8 ', style=shape.labelup, location=location.absolute, color=bullColor8, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #8 END ////// divergence Lookback period #9 // get pivots plFound9 = na(ta.pivotlow(osc, lbL9, lbR)) ? false : true _inRange9(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL9 = osc[lbR] > ta.valuewhen(plFound9, osc[lbR], 1) and _inRange9(plFound9[1]) // Price: Lower Low priceLL9 = low[lbR] < ta.valuewhen(plFound9, low[lbR], 1) bullCond9 = plotBull and priceLL9 and oscHL9 and plFound9 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound9 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond9 ? bullColor : noneColor) plotshape(bullCond9 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 9 Label', text=' B9 ', style=shape.labelup, location=location.absolute, color=bullColor9, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL9 = osc[lbR] < ta.valuewhen(plFound9, osc[lbR], 1) and _inRange9(plFound9[1]) // Price: Higher Low priceHL9 = low[lbR] > ta.valuewhen(plFound9, low[lbR], 1) hiddenBullCond9 = plotHiddenBull and priceHL9 and oscLL9 and plFound9 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound9 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond9 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond9 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 9 Label', text=' H B9 ', style=shape.labelup, location=location.absolute, color=bullColor9, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #9 END ////// divergence Lookback period #10 // get pivots plFound10 = na(ta.pivotlow(osc, lbL10, lbR)) ? false : true _inRange10(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL10 = osc[lbR] > ta.valuewhen(plFound10, osc[lbR], 1) and _inRange10(plFound10[1]) // Price: Lower Low priceLL10 = low[lbR] < ta.valuewhen(plFound10, low[lbR], 1) bullCond10 = plotBull and priceLL10 and oscHL10 and plFound10 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound10 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond10 ? bullColor : noneColor) plotshape(bullCond10 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 10 Label', text=' B10 ', style=shape.labelup, location=location.absolute, color=bullColor10, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL10 = osc[lbR] < ta.valuewhen(plFound10, osc[lbR], 1) and _inRange10(plFound10[1]) // Price: Higher Low priceHL10 = low[lbR] > ta.valuewhen(plFound10, low[lbR], 1) hiddenBullCond10 = plotHiddenBull and priceHL10 and oscLL10 and plFound10 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound10 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond10 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond10 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 10 Label', text=' H B10 ', style=shape.labelup, location=location.absolute, color=bullColor10, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #10 END ////// divergence Lookback period #11 // get pivots plFound11 = na(ta.pivotlow(osc, lbL11, lbR)) ? false : true _inRange11(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL11 = osc[lbR] > ta.valuewhen(plFound11, osc[lbR], 1) and _inRange11(plFound11[1]) // Price: Lower Low priceLL11 = low[lbR] < ta.valuewhen(plFound11, low[lbR], 1) bullCond11 = plotBull and priceLL11 and oscHL11 and plFound11 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound11 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond11 ? bullColor : noneColor) plotshape(bullCond11 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 11 Label', text=' B11 ', style=shape.labelup, location=location.absolute, color=bullColor11, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL11 = osc[lbR] < ta.valuewhen(plFound11, osc[lbR], 1) and _inRange11(plFound11[1]) // Price: Higher Low priceHL11 = low[lbR] > ta.valuewhen(plFound11, low[lbR], 1) hiddenBullCond11 = plotHiddenBull and priceHL11 and oscLL11 and plFound11 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound11 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond11 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond11 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 11 Label', text=' H B11 ', style=shape.labelup, location=location.absolute, color=bullColor11, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #11 END ////// divergence Lookback period #12 // get pivots plFound12 = na(ta.pivotlow(osc, lbL12, lbR)) ? false : true _inRange12(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL12 = osc[lbR] > ta.valuewhen(plFound12, osc[lbR], 1) and _inRange12(plFound12[1]) // Price: Lower Low priceLL12 = low[lbR] < ta.valuewhen(plFound12, low[lbR], 1) bullCond12 = plotBull and priceLL12 and oscHL12 and plFound12 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound12 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond12 ? bullColor : noneColor) plotshape(bullCond12 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 12 Label', text=' B12 ', style=shape.labelup, location=location.absolute, color=bullColor12, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL12 = osc[lbR] < ta.valuewhen(plFound12, osc[lbR], 1) and _inRange12(plFound12[1]) // Price: Higher Low priceHL12 = low[lbR] > ta.valuewhen(plFound12, low[lbR], 1) hiddenBullCond12 = plotHiddenBull and priceHL12 and oscLL12 and plFound12 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound12 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond12 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond12 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 12 Label', text=' H B12 ', style=shape.labelup, location=location.absolute, color=bullColor12, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #12 END ////// divergence Lookback period #13 // get pivots plFound13 = na(ta.pivotlow(osc, lbL13, lbR)) ? false : true _inRange13(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL13 = osc[lbR] > ta.valuewhen(plFound13, osc[lbR], 1) and _inRange13(plFound13[1]) // Price: Lower Low priceLL13 = low[lbR] < ta.valuewhen(plFound13, low[lbR], 1) bullCond13 = plotBull and priceLL13 and oscHL13 and plFound13 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound13 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond13 ? bullColor : noneColor) plotshape(bullCond13 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 13 Label', text=' B13 ', style=shape.labelup, location=location.absolute, color=bullColor13, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL13 = osc[lbR] < ta.valuewhen(plFound13, osc[lbR], 1) and _inRange13(plFound13[1]) // Price: Higher Low priceHL13 = low[lbR] > ta.valuewhen(plFound13, low[lbR], 1) hiddenBullCond13 = plotHiddenBull and priceHL13 and oscLL13 and plFound13 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound13 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond13 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond13 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 13 Label', text=' H B13 ', style=shape.labelup, location=location.absolute, color=bullColor13, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #13 END ////// divergence Lookback period #14 // get pivots plFound14 = na(ta.pivotlow(osc, lbL14, lbR)) ? false : true _inRange14(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL14 = osc[lbR] > ta.valuewhen(plFound14, osc[lbR], 1) and _inRange14(plFound14[1]) // Price: Lower Low priceLL14 = low[lbR] < ta.valuewhen(plFound14, low[lbR], 1) bullCond14 = plotBull and priceLL14 and oscHL14 and plFound14 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound14 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond14 ? bullColor : noneColor) plotshape(bullCond14 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 14 Label', text=' B14 ', style=shape.labelup, location=location.absolute, color=bullColor14, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL14 = osc[lbR] < ta.valuewhen(plFound14, osc[lbR], 1) and _inRange14(plFound14[1]) // Price: Higher Low priceHL14 = low[lbR] > ta.valuewhen(plFound14, low[lbR], 1) hiddenBullCond14 = plotHiddenBull and priceHL14 and oscLL14 and plFound14 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound14 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond14 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond14 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 14 Label', text=' H B14 ', style=shape.labelup, location=location.absolute, color=bullColor14, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #14 END ////// divergence Lookback period #15 // get pivots plFound15 = na(ta.pivotlow(osc, lbL15, lbR)) ? false : true _inRange15(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL15 = osc[lbR] > ta.valuewhen(plFound15, osc[lbR], 1) and _inRange15(plFound15[1]) // Price: Lower Low priceLL15 = low[lbR] < ta.valuewhen(plFound15, low[lbR], 1) bullCond15 = plotBull and priceLL15 and oscHL15 and plFound15 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound15 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond15 ? bullColor : noneColor) plotshape(bullCond15 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 15 Label', text=' B15 ', style=shape.labelup, location=location.absolute, color=bullColor15, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL15 = osc[lbR] < ta.valuewhen(plFound15, osc[lbR], 1) and _inRange15(plFound15[1]) // Price: Higher Low priceHL15 = low[lbR] > ta.valuewhen(plFound15, low[lbR], 1) hiddenBullCond15 = plotHiddenBull and priceHL15 and oscLL15 and plFound15 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound15 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond15 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond15 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 15 Label', text=' H B15 ', style=shape.labelup, location=location.absolute, color=bullColor15, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #15 END ////// divergence Lookback period #16 // get pivots plFound16 = na(ta.pivotlow(osc, lbL16, lbR)) ? false : true _inRange16(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL16 = osc[lbR] > ta.valuewhen(plFound16, osc[lbR], 1) and _inRange16(plFound16[1]) // Price: Lower Low priceLL16 = low[lbR] < ta.valuewhen(plFound16, low[lbR], 1) bullCond16 = plotBull and priceLL16 and oscHL16 and plFound16 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound16 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond16 ? bullColor : noneColor) plotshape(bullCond16 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 16 Label', text=' B16 ', style=shape.labelup, location=location.absolute, color=bullColor16, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL16 = osc[lbR] < ta.valuewhen(plFound16, osc[lbR], 1) and _inRange16(plFound16[1]) // Price: Higher Low priceHL16 = low[lbR] > ta.valuewhen(plFound16, low[lbR], 1) hiddenBullCond16 = plotHiddenBull and priceHL16 and oscLL16 and plFound16 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound16 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond16 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond16 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 16 Label', text=' H B16 ', style=shape.labelup, location=location.absolute, color=bullColor16, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #16 END ////// divergence Lookback period #17 // get pivots plFound17 = na(ta.pivotlow(osc, lbL17, lbR)) ? false : true _inRange17(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL17 = osc[lbR] > ta.valuewhen(plFound17, osc[lbR], 1) and _inRange17(plFound17[1]) // Price: Lower Low priceLL17 = low[lbR] < ta.valuewhen(plFound17, low[lbR], 1) bullCond17 = plotBull and priceLL17 and oscHL17 and plFound17 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound17 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond17 ? bullColor : noneColor) plotshape(bullCond17 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 17 Label', text=' B17 ', style=shape.labelup, location=location.absolute, color=bullColor17, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL17 = osc[lbR] < ta.valuewhen(plFound17, osc[lbR], 1) and _inRange17(plFound17[1]) // Price: Higher Low priceHL17 = low[lbR] > ta.valuewhen(plFound17, low[lbR], 1) hiddenBullCond17 = plotHiddenBull and priceHL17 and oscLL17 and plFound17 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound17 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond17 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond17 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 17 Label', text=' H B17 ', style=shape.labelup, location=location.absolute, color=bullColor17, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #17 END ////// divergence Lookback period #18 // get pivots plFound18 = na(ta.pivotlow(osc, lbL18, lbR)) ? false : true _inRange18(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL18 = osc[lbR] > ta.valuewhen(plFound18, osc[lbR], 1) and _inRange18(plFound18[1]) // Price: Lower Low priceLL18 = low[lbR] < ta.valuewhen(plFound18, low[lbR], 1) bullCond18 = plotBull and priceLL18 and oscHL18 and plFound18 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound18 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond18 ? bullColor : noneColor) plotshape(bullCond18 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 18 Label', text=' B18 ', style=shape.labelup, location=location.absolute, color=bullColor18, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL18 = osc[lbR] < ta.valuewhen(plFound18, osc[lbR], 1) and _inRange18(plFound18[1]) // Price: Higher Low priceHL18 = low[lbR] > ta.valuewhen(plFound18, low[lbR], 1) hiddenBullCond18 = plotHiddenBull and priceHL18 and oscLL18 and plFound18 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound18 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond18 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond18 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 18 Label', text=' H B18 ', style=shape.labelup, location=location.absolute, color=bullColor18, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #18 END ////// divergence Lookback period #19 // get pivots plFound19 = na(ta.pivotlow(osc, lbL19, lbR)) ? false : true _inRange19(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL19 = osc[lbR] > ta.valuewhen(plFound19, osc[lbR], 1) and _inRange19(plFound19[1]) // Price: Lower Low priceLL19 = low[lbR] < ta.valuewhen(plFound19, low[lbR], 1) bullCond19 = plotBull and priceLL19 and oscHL19 and plFound19 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound19 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond19 ? bullColor : noneColor) plotshape(bullCond19 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 19 Label', text=' B19 ', style=shape.labelup, location=location.absolute, color=bullColor19, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL19 = osc[lbR] < ta.valuewhen(plFound19, osc[lbR], 1) and _inRange19(plFound19[1]) // Price: Higher Low priceHL19 = low[lbR] > ta.valuewhen(plFound19, low[lbR], 1) hiddenBullCond19 = plotHiddenBull and priceHL19 and oscLL19 and plFound19 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound19 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond19 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond19 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 19 Label', text=' H B19 ', style=shape.labelup, location=location.absolute, color=bullColor19, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #19 END ////// divergence Lookback period #20 // get pivots plFound20 = na(ta.pivotlow(osc, lbL20, lbR)) ? false : true _inRange20(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL20 = osc[lbR] > ta.valuewhen(plFound20, osc[lbR], 1) and _inRange20(plFound20[1]) // Price: Lower Low priceLL20 = low[lbR] < ta.valuewhen(plFound20, low[lbR], 1) bullCond20 = plotBull and priceLL20 and oscHL20 and plFound20 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound20 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond20 ? bullColor : noneColor) plotshape(bullCond20 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 20 Label', text=' B20 ', style=shape.labelup, location=location.absolute, color=bullColor20, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL20 = osc[lbR] < ta.valuewhen(plFound20, osc[lbR], 1) and _inRange20(plFound20[1]) // Price: Higher Low priceHL20 = low[lbR] > ta.valuewhen(plFound20, low[lbR], 1) hiddenBullCond20 = plotHiddenBull and priceHL20 and oscLL20 and plFound20 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound20 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond20 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond20 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 20 Label', text=' H B20 ', style=shape.labelup, location=location.absolute, color=bullColor20, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #20 END ////// divergence Lookback period #21 // get pivots plFound21 = na(ta.pivotlow(osc, lbL21, lbR)) ? false : true _inRange21(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL21 = osc[lbR] > ta.valuewhen(plFound21, osc[lbR], 1) and _inRange21(plFound21[1]) // Price: Lower Low priceLL21 = low[lbR] < ta.valuewhen(plFound21, low[lbR], 1) bullCond21 = plotBull and priceLL21 and oscHL21 and plFound21 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound21 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond21 ? bullColor : noneColor) plotshape(bullCond21 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 21 Label', text=' B21 ', style=shape.labelup, location=location.absolute, color=bullColor21, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL21 = osc[lbR] < ta.valuewhen(plFound21, osc[lbR], 1) and _inRange21(plFound21[1]) // Price: Higher Low priceHL21 = low[lbR] > ta.valuewhen(plFound21, low[lbR], 1) hiddenBullCond21 = plotHiddenBull and priceHL21 and oscLL21 and plFound21 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound21 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond21 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond21 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 21 Label', text=' H B21 ', style=shape.labelup, location=location.absolute, color=bullColor21, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #21 END ////// divergence Lookback period #22 // get pivots plFound22 = na(ta.pivotlow(osc, lbL22, lbR)) ? false : true _inRange22(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL22 = osc[lbR] > ta.valuewhen(plFound22, osc[lbR], 1) and _inRange22(plFound22[1]) // Price: Lower Low priceLL22 = low[lbR] < ta.valuewhen(plFound22, low[lbR], 1) bullCond22 = plotBull and priceLL22 and oscHL22 and plFound22 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound22 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond22 ? bullColor : noneColor) plotshape(bullCond22 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 22 Label', text=' B22 ', style=shape.labelup, location=location.absolute, color=bullColor22, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL22 = osc[lbR] < ta.valuewhen(plFound22, osc[lbR], 1) and _inRange22(plFound22[1]) // Price: Higher Low priceHL22 = low[lbR] > ta.valuewhen(plFound22, low[lbR], 1) hiddenBullCond22 = plotHiddenBull and priceHL22 and oscLL22 and plFound22 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound22 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond22 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond22 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 22 Label', text=' H B22 ', style=shape.labelup, location=location.absolute, color=bullColor22, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #22 END ////// divergence Lookback period #23 // get pivots plFound23 = na(ta.pivotlow(osc, lbL23, lbR)) ? false : true _inRange23(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL23 = osc[lbR] > ta.valuewhen(plFound23, osc[lbR], 1) and _inRange23(plFound23[1]) // Price: Lower Low priceLL23 = low[lbR] < ta.valuewhen(plFound23, low[lbR], 1) bullCond23 = plotBull and priceLL23 and oscHL23 and plFound23 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound23 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond23 ? bullColor : noneColor) plotshape(bullCond23 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 23 Label', text=' B23 ', style=shape.labelup, location=location.absolute, color=bullColor23, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL23 = osc[lbR] < ta.valuewhen(plFound23, osc[lbR], 1) and _inRange23(plFound23[1]) // Price: Higher Low priceHL23 = low[lbR] > ta.valuewhen(plFound23, low[lbR], 1) hiddenBullCond23 = plotHiddenBull and priceHL23 and oscLL23 and plFound23 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound23 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond23 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond23 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 23 Label', text=' H B23 ', style=shape.labelup, location=location.absolute, color=bullColor23, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #23 END ////// divergence Lookback period #24 // get pivots plFound24 = na(ta.pivotlow(osc, lbL24, lbR)) ? false : true _inRange24(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL24 = osc[lbR] > ta.valuewhen(plFound24, osc[lbR], 1) and _inRange24(plFound24[1]) // Price: Lower Low priceLL24 = low[lbR] < ta.valuewhen(plFound24, low[lbR], 1) bullCond24 = plotBull and priceLL24 and oscHL24 and plFound24 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound24 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond24 ? bullColor : noneColor) plotshape(bullCond24 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 24 Label', text=' B24 ', style=shape.labelup, location=location.absolute, color=bullColor24, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL24 = osc[lbR] < ta.valuewhen(plFound24, osc[lbR], 1) and _inRange24(plFound24[1]) // Price: Higher Low priceHL24 = low[lbR] > ta.valuewhen(plFound24, low[lbR], 1) hiddenBullCond24 = plotHiddenBull and priceHL24 and oscLL24 and plFound24 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound24 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond24 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond24 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 24 Label', text=' H B24 ', style=shape.labelup, location=location.absolute, color=bullColor24, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #24 END ////// divergence Lookback period #25 // get pivots plFound25 = na(ta.pivotlow(osc, lbL25, lbR)) ? false : true _inRange25(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL25 = osc[lbR] > ta.valuewhen(plFound25, osc[lbR], 1) and _inRange25(plFound25[1]) // Price: Lower Low priceLL25 = low[lbR] < ta.valuewhen(plFound25, low[lbR], 1) bullCond25 = plotBull and priceLL25 and oscHL25 and plFound25 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound25 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond25 ? bullColor : noneColor) plotshape(bullCond25 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 25 Label', text=' B25 ', style=shape.labelup, location=location.absolute, color=bullColor25, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL25 = osc[lbR] < ta.valuewhen(plFound25, osc[lbR], 1) and _inRange25(plFound25[1]) // Price: Higher Low priceHL25 = low[lbR] > ta.valuewhen(plFound25, low[lbR], 1) hiddenBullCond25 = plotHiddenBull and priceHL25 and oscLL25 and plFound25 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound25 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond25 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond25 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 25 Label', text=' H B25 ', style=shape.labelup, location=location.absolute, color=bullColor25, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #25 END ////// divergence Lookback period #26 // get pivots plFound26 = na(ta.pivotlow(osc, lbL26, lbR)) ? false : true _inRange26(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL26 = osc[lbR] > ta.valuewhen(plFound26, osc[lbR], 1) and _inRange26(plFound26[1]) // Price: Lower Low priceLL26 = low[lbR] < ta.valuewhen(plFound26, low[lbR], 1) bullCond26 = plotBull and priceLL26 and oscHL26 and plFound26 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound26 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 26', linewidth=2, color=bullCond26 ? bullColor : noneColor) plotshape(bullCond26 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 26 Label', text=' B26 ', style=shape.labelup, location=location.absolute, color=bullColor26, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL26 = osc[lbR] < ta.valuewhen(plFound26, osc[lbR], 1) and _inRange26(plFound26[1]) // Price: Higher Low priceHL26 = low[lbR] > ta.valuewhen(plFound26, low[lbR], 1) hiddenBullCond26 = plotHiddenBull and priceHL26 and oscLL26 and plFound26 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound26 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 26', linewidth=2, color=hiddenBullCond26 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond26 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 26 Label', text=' H B26 ', style=shape.labelup, location=location.absolute, color=bullColor26, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #26 END ////// divergence Lookback period #27 // get pivots plFound27 = na(ta.pivotlow(osc, lbL27, lbR)) ? false : true _inRange27(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL27 = osc[lbR] > ta.valuewhen(plFound27, osc[lbR], 1) and _inRange27(plFound27[1]) // Price: Lower Low priceLL27 = low[lbR] < ta.valuewhen(plFound27, low[lbR], 1) bullCond27 = plotBull and priceLL27 and oscHL27 and plFound27 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound27 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 27', linewidth=2, color=bullCond27 ? bullColor : noneColor) plotshape(bullCond27 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 27 Label ', text=' B27 ', style=shape.labelup, location=location.absolute, color=bullColor27, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL27 = osc[lbR] < ta.valuewhen(plFound27, osc[lbR], 1) and _inRange27(plFound27[1]) // Price: Higher Low priceHL27 = low[lbR] > ta.valuewhen(plFound27, low[lbR], 1) hiddenBullCond27 = plotHiddenBull and priceHL27 and oscLL27 and plFound27 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound27 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 27', linewidth=2, color=hiddenBullCond27 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond27 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 27 Label', text=' H B27 ', style=shape.labelup, location=location.absolute, color=bullColor27, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #27 END ////// divergence Lookback period #28 // get pivots plFound28 = na(ta.pivotlow(osc, lbL28, lbR)) ? false : true _inRange28(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL28 = osc[lbR] > ta.valuewhen(plFound28, osc[lbR], 1) and _inRange28(plFound28[1]) // Price: Lower Low priceLL28 = low[lbR] < ta.valuewhen(plFound28, low[lbR], 1) bullCond28 = plotBull and priceLL28 and oscHL28 and plFound28 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound28 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 28', linewidth=2, color=bullCond28 ? bullColor : noneColor) plotshape(bullCond28 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 28 Label ', text=' B28 ', style=shape.labelup, location=location.absolute, color=bullColor28, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL28 = osc[lbR] < ta.valuewhen(plFound28, osc[lbR], 1) and _inRange28(plFound28[1]) // Price: Higher Low priceHL28 = low[lbR] > ta.valuewhen(plFound28, low[lbR], 1) hiddenBullCond28 = plotHiddenBull and priceHL28 and oscLL28 and plFound28 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound28 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 28', linewidth=2, color=hiddenBullCond28 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond28 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 28 Label', text=' H B28 ', style=shape.labelup, location=location.absolute, color=bullColor28, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #28 END ////// divergence Lookback period #29 // get pivots plFound29 = na(ta.pivotlow(osc, lbL29, lbR)) ? false : true _inRange29(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL29 = osc[lbR] > ta.valuewhen(plFound29, osc[lbR], 1) and _inRange29(plFound29[1]) // Price: Lower Low priceLL29 = low[lbR] < ta.valuewhen(plFound29, low[lbR], 1) bullCond29 = plotBull and priceLL29 and oscHL29 and plFound29 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound29 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 29', linewidth=2, color=bullCond29 ? bullColor : noneColor) plotshape(bullCond29 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 29 Label ', text=' B29 ', style=shape.labelup, location=location.absolute, color=bullColor29, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL29 = osc[lbR] < ta.valuewhen(plFound29, osc[lbR], 1) and _inRange29(plFound29[1]) // Price: Higher Low priceHL29 = low[lbR] > ta.valuewhen(plFound29, low[lbR], 1) hiddenBullCond29 = plotHiddenBull and priceHL29 and oscLL29 and plFound29 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound29 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 29', linewidth=2, color=hiddenBullCond29 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond29 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 29 Label', text=' H B29 ', style=shape.labelup, location=location.absolute, color=bullColor29, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #29 END ////// divergence Lookback period #30 // get pivots plFound30 = na(ta.pivotlow(osc, lbL30, lbR)) ? false : true _inRange30(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL30 = osc[lbR] > ta.valuewhen(plFound30, osc[lbR], 1) and _inRange30(plFound30[1]) // Price: Lower Low priceLL30 = low[lbR] < ta.valuewhen(plFound30, low[lbR], 1) bullCond30 = plotBull and priceLL30 and oscHL30 and plFound30 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound30 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 30', linewidth=2, color=bullCond30 ? bullColor : noneColor) plotshape(bullCond30 ? osc[lbR] : na, offset=-lbR, title='Regular Bullish 30 Label ', text=' B30 ', style=shape.labelup, location=location.absolute, color=bullColor30, textcolor=textColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL30 = osc[lbR] < ta.valuewhen(plFound30, osc[lbR], 1) and _inRange30(plFound30[1]) // Price: Higher Low priceHL30 = low[lbR] > ta.valuewhen(plFound30, low[lbR], 1) hiddenBullCond30 = plotHiddenBull and priceHL30 and oscLL30 and plFound30 and RSIwasBelowOS and isWithinLongRanges and not enableonlyOneLB //plot(plFound30 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 30', linewidth=2, color=hiddenBullCond30 ? hiddenBullColor : noneColor) plotshape(hiddenBullCond30 ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish 30 Label', text=' H B30 ', style=shape.labelup, location=location.absolute, color=bullColor30, textcolor=textColor) //------------------------------------------------------------------------------ ////// divergence Lookback period #30 END // combine divergence alerts intwo bullish and hidden combibullCond = (bullCond1 or bullCond2 or bullCond3 or bullCond4 or bullCond5 or bullCond6 or bullCond7 or bullCond8 or bullCond9 or bullCond10 or bullCond11 or bullCond12 or bullCond13 or bullCond14 or bullCond15 or bullCond16 or bullCond17 or bullCond18 or bullCond19 or bullCond20 or bullCond21 or bullCond22 or bullCond23 or bullCond24 or bullCond25 or bullCond26 or bullCond27 or bullCond28 or bullCond29 or bullCond30) combihiddenBullCond = (hiddenBullCond1 or hiddenBullCond2 or hiddenBullCond3 or hiddenBullCond4 or hiddenBullCond5 or hiddenBullCond6 or hiddenBullCond7 or hiddenBullCond8 or hiddenBullCond9 or hiddenBullCond10 or hiddenBullCond11 or hiddenBullCond12 or hiddenBullCond13 or hiddenBullCond14 or hiddenBullCond15 or hiddenBullCond16 or hiddenBullCond17 or hiddenBullCond18 or hiddenBullCond19 or hiddenBullCond20 or hiddenBullCond21 or hiddenBullCond22 or hiddenBullCond23 or hiddenBullCond24 or hiddenBullCond25 or hiddenBullCond26 or hiddenBullCond27 or hiddenBullCond28 or hiddenBullCond29 or hiddenBullCond30) ///////////////////////// Delays // wait for a Oscillator and Oscillator EMA cross oscCross = ((1 < (osc - oscema)) and (ta.barssince(combihiddenBullCond or combibullCond) <= oscCrosslookback) ) or not enableOscCross // wait for price to go above ema EmaIsBroken = (ta.ema(src, WaitForEmaBreakLen) < close) or not enableWaitForEmaBreak ///////////// check if price bounced before the alert priceBounced = priceBounceNeeded < (ta.highest(high, 1) - ta.lowest(low, priceBounceNeededLbL)) or not enablepriceBounceNeeded delaysEnabled = enablepriceBounceNeeded or enableOscCross or enableWaitForEmaBreak DelayState = oscCross and EmaIsBroken and priceBounced // dirty workaround to dont reprint the final hidden bull alert HiddenBullAndBounce0 = DelayState and (ta.barssince(combihiddenBullCond) == 0) HiddenBullAndBounce1 = DelayState and (ta.barssince(combihiddenBullCond) == 1) and not (ta.barssince(HiddenBullAndBounce0) < 1) HiddenBullAndBounce2 = DelayState and (ta.barssince(combihiddenBullCond) == 2) and not (ta.barssince(HiddenBullAndBounce1 or HiddenBullAndBounce0) < 2) HiddenBullAndBounce3 = DelayState and (ta.barssince(combihiddenBullCond) == 3) and not (ta.barssince(HiddenBullAndBounce1 or HiddenBullAndBounce0 or HiddenBullAndBounce2) < 3) HiddenBullAndBounce4 = DelayState and (ta.barssince(combihiddenBullCond) == 4) and not (ta.barssince(HiddenBullAndBounce1 or HiddenBullAndBounce0 or HiddenBullAndBounce2 or HiddenBullAndBounce3) < 5) HiddenBullAndBounce5 = DelayState and (ta.barssince(combihiddenBullCond) == 5) and not (ta.barssince(HiddenBullAndBounce1 or HiddenBullAndBounce0 or HiddenBullAndBounce2 or HiddenBullAndBounce3 or HiddenBullAndBounce4) < 6) HiddenBullAndBounce6 = DelayState and (ta.barssince(combihiddenBullCond) == 6) and not (ta.barssince(HiddenBullAndBounce1 or HiddenBullAndBounce0 or HiddenBullAndBounce2 or HiddenBullAndBounce3 or HiddenBullAndBounce4 or HiddenBullAndBounce5) < 7) HiddenBullAndBounce7 = DelayState and (ta.barssince(combihiddenBullCond) == 7) and not (ta.barssince(HiddenBullAndBounce1 or HiddenBullAndBounce0 or HiddenBullAndBounce2 or HiddenBullAndBounce3 or HiddenBullAndBounce4 or HiddenBullAndBounce5 or HiddenBullAndBounce6) < 8) HiddenBullAndBounce8 = DelayState and (ta.barssince(combihiddenBullCond) == 8) and not (ta.barssince(HiddenBullAndBounce1 or HiddenBullAndBounce0 or HiddenBullAndBounce2 or HiddenBullAndBounce3 or HiddenBullAndBounce4 or HiddenBullAndBounce5 or HiddenBullAndBounce6 or HiddenBullAndBounce7) < 9) HiddenBullAndBounce9 = DelayState and (ta.barssince(combihiddenBullCond) == 9) and not (ta.barssince(HiddenBullAndBounce1 or HiddenBullAndBounce0 or HiddenBullAndBounce2 or HiddenBullAndBounce3 or HiddenBullAndBounce4 or HiddenBullAndBounce5 or HiddenBullAndBounce6 or HiddenBullAndBounce7 or HiddenBullAndBounce8) < 10) HiddenBullAndBounce10 = DelayState and (ta.barssince(combihiddenBullCond) == 10) and not (ta.barssince(HiddenBullAndBounce1 or HiddenBullAndBounce0 or HiddenBullAndBounce2 or HiddenBullAndBounce3 or HiddenBullAndBounce4 or HiddenBullAndBounce5 or HiddenBullAndBounce6 or HiddenBullAndBounce7 or HiddenBullAndBounce8 or HiddenBullAndBounce9) < 11) FinalHiddenBullDelayAlert = delaysEnabled and (HiddenBullAndBounce1 or HiddenBullAndBounce0 or HiddenBullAndBounce2 or HiddenBullAndBounce3 or HiddenBullAndBounce4 or HiddenBullAndBounce5 or HiddenBullAndBounce6 or HiddenBullAndBounce7 or HiddenBullAndBounce8 or HiddenBullAndBounce9 or HiddenBullAndBounce10) FinalHiddenBullAlert = false FinalHiddenBullAlert2 = false if delaysEnabled FinalHiddenBullAlert := FinalHiddenBullDelayAlert FinalHiddenBullAlert2 := false if not delaysEnabled FinalHiddenBullAlert := false FinalHiddenBullAlert2 := combihiddenBullCond // dirty workaround to dont reprint the final bull alert BullAndBounce0 = DelayState and (ta.barssince(combibullCond) == 0) BullAndBounce1 = DelayState and (ta.barssince(combibullCond) == 1) and not (ta.barssince(BullAndBounce0) < 2) BullAndBounce2 = DelayState and (ta.barssince(combibullCond) == 2) and not (ta.barssince(BullAndBounce1 or BullAndBounce0) < 3) BullAndBounce3 = DelayState and (ta.barssince(combibullCond) == 3) and not (ta.barssince(BullAndBounce1 or BullAndBounce0 or BullAndBounce2) < 4) BullAndBounce4 = DelayState and (ta.barssince(combibullCond) == 4) and not (ta.barssince(BullAndBounce1 or BullAndBounce0 or BullAndBounce2 or BullAndBounce3) < 5) BullAndBounce5 = DelayState and (ta.barssince(combibullCond) == 5) and not (ta.barssince(BullAndBounce1 or BullAndBounce0 or BullAndBounce2 or BullAndBounce3 or BullAndBounce4) < 6) BullAndBounce6 = DelayState and (ta.barssince(combibullCond) == 6) and not (ta.barssince(BullAndBounce1 or BullAndBounce0 or BullAndBounce2 or BullAndBounce3 or BullAndBounce4 or BullAndBounce5) < 7) BullAndBounce7 = DelayState and (ta.barssince(combibullCond) == 7) and not (ta.barssince(BullAndBounce1 or BullAndBounce0 or BullAndBounce2 or BullAndBounce3 or BullAndBounce4 or BullAndBounce5 or BullAndBounce6) < 8) BullAndBounce8 = DelayState and (ta.barssince(combibullCond) == 8) and not (ta.barssince(BullAndBounce1 or BullAndBounce0 or BullAndBounce2 or BullAndBounce3 or BullAndBounce4 or BullAndBounce5 or BullAndBounce6 or BullAndBounce7) < 9) BullAndBounce9 = DelayState and (ta.barssince(combibullCond) == 9) and not (ta.barssince(BullAndBounce1 or BullAndBounce0 or BullAndBounce2 or BullAndBounce3 or BullAndBounce4 or BullAndBounce5 or BullAndBounce6 or BullAndBounce7 or BullAndBounce8) < 10) BullAndBounce10 = DelayState and (ta.barssince(combibullCond) == 10) and not (ta.barssince(BullAndBounce1 or BullAndBounce0 or BullAndBounce2 or BullAndBounce3 or BullAndBounce4 or BullAndBounce5 or BullAndBounce6 or BullAndBounce7 or BullAndBounce8 or BullAndBounce9) < 11) FinalBullDelayAlert = delaysEnabled and (BullAndBounce1 or BullAndBounce0 or BullAndBounce2 or BullAndBounce3 or BullAndBounce4 or BullAndBounce5 or BullAndBounce6 or BullAndBounce7 or BullAndBounce8 or BullAndBounce9 or BullAndBounce10) FinalBullAlert = false FinalBullAlert2 = false if delaysEnabled FinalBullAlert := FinalBullDelayAlert FinalBullAlert2 := false if not delaysEnabled FinalBullAlert := false FinalBullAlert2 := combibullCond ///////////// check if price bounced before the alert END // plot delay buy plotshape(FinalBullAlert ? osc : na, offset=0, title='Buy ', text=" buy ", style=shape.labelup, location=location.absolute, color=color.lime, textcolor=textColor) ////////////////// Stop Loss // Stop loss enableSL = input.bool(true, title='enable Stop Loss', group='══════════ Stop Loss Settings ══════════') whichSL = input.string(defval='use the low as SL', title='SL based on static % or based on the low', options=['use the low as SL', 'use the static % as SL'], group='══════════ Stop Loss Settings ══════════') whichOffset = input.string(defval='use % as offset', title='choose offset from the low', options=['use $ as offset', 'use % as offset'], group='Stop Loss at the low') lowPBuffer = input.float(0.35, title='SL Offset from the Low in %', group='Stop Loss at the low') / 100 lowDBuffer = input.float(100, title='SL Offset from the Low in $', group='Stop Loss at the low') SlLowLookback = input.int(title='SL lookback for Low', defval=5, minval=1, maxval=50, group='Stop Loss at the low') longSlLow = float(na) if whichOffset == "use % as offset" and whichSL == "use the low as SL" and enableSL longSlLow := ta.lowest(low, SlLowLookback) * (1 - lowPBuffer) if whichOffset == "use $ as offset" and whichSL == "use the low as SL" and enableSL longSlLow := ta.lowest(low, SlLowLookback) - lowDBuffer //plot(longSlLow, title="stoploss", color=color.new(#00bcd4, 0)) // long settings - 🔥 uncomment the 6 lines below to disable the alerts and enable the backtester longStopLoss = input.float(0.5, title='Stop Loss in %', group='static % Stop Loss', inline='Input 1') / 100 /////// Take profit longTakeProfit1 = input.float(2, title='Take Profit in %', group='Take Profit', inline='Input 1') / 100 //longTakeProfit2 = input.float(2, title='25% Take Profit in %', group='Take Profit', inline='Input 1') / 100 //longTakeProfit3 = input.float(2, title='25% Take Profit in %', group='Take Profit', inline='Input 1') / 100 //longTakeProfit4 = input.float(2, title='25% Take Profit in %', group='Take Profit', inline='Input 1') / 100 ////////////////// SL TP END /////////////////// alerts ///////////////ver final alert variable veryFinalAlert = FinalHiddenBullAlert2 or FinalHiddenBullAlert or FinalBullAlert or FinalBullAlert2 /////////////////// alerts selectalertFreq = input.string(defval='once per bar close', title='Alert Options', options=['once per bar', 'once per bar close', 'all'], group='═══════════ alert settings ═══════════') BuyAlertMessage = input.string(defval="Bullish Divergence detected, put your SL @", title='Buy Alert Message', group='═══════════ alert settings ═══════════') enableSlMessage = input.bool(true, title='enable Stop Loss Value at the end of "buy Alert message"', group='═══════════ alert settings ═══════════') AfterSLMessage = input.string(defval="", title='Buy Alert message after SL Value', group='═══════════ alert settings ═══════════') alertFreq = selectalertFreq == "once per bar" ? alert.freq_once_per_bar : selectalertFreq == "once per bar close" ? alert.freq_once_per_bar_close : selectalertFreq == "all" ? alert.freq_all : na if not enableSlMessage and veryFinalAlert alert(str.tostring(BuyAlertMessage), alertFreq) if enableSlMessage and veryFinalAlert alert(str.tostring(BuyAlertMessage) + str.tostring(longSlLow) + str.tostring(AfterSLMessage), alertFreq) if enableSlMessage alert(str.tostring(BuyAlertMessage) + str.tostring(longSlLow) + str.tostring(AfterSLMessage), alertFreq) alertcondition(veryFinalAlert, title='Bullish divergence', message='Bull Div {{ticker}}') ////////////////// Backtester ////////////////// Backtester input stuff // Backtesting Range settings - 🔥 uncomment the 6 lines below to disable the alerts and enable the backtester //startDate = input.int(title='Start Date', defval=1, minval=1, maxval=31, group='Backtesting range') //startMonth = input.int(title='Start Month', defval=1, minval=1, maxval=12, group='Backtesting range') //startYear = input.int(title='Start Year', defval=2016, minval=1800, maxval=2100, group='Backtesting range') //endDate = input.int(title='End Date', defval=1, minval=1, maxval=31, group='Backtesting range') //endMonth = input.int(title='End Month', defval=1, minval=1, maxval=12, group='Backtesting range') //endYear = input.int(title='End Year', defval=2040, minval=1800, maxval=2100, group='Backtesting range') ////////////////// Backtester // // 🔥 uncomment the all lines below for the backtester and revert for alerts // shortTrading = false // longTrading = plotBull or plotHiddenBull // longTP1 = strategy.position_size > 0 ? strategy.position_avg_price * (1 + longTakeProfit1) : strategy.position_size < 0 ? strategy.position_avg_price * (1 - longTakeProfit1) : na // //longTP2 = strategy.position_size > 0 ? strategy.position_avg_price * (1 + longTakeProfit2) : strategy.position_size < 0 ? strategy.position_avg_price * (1 - longTakeProfit2) : na // //longTP3 = strategy.position_size > 0 ? strategy.position_avg_price * (1 + longTakeProfit3) : strategy.position_size < 0 ? strategy.position_avg_price * (1 - longTakeProfit3) : na // //longTP4 = strategy.position_size > 0 ? strategy.position_avg_price * (1 + longTakeProfit4) : strategy.position_size < 0 ? strategy.position_avg_price * (1 - longTakeProfit4) : na // longSL = strategy.position_size > 0 ? strategy.position_avg_price * (1 - longStopLoss) : strategy.position_size < 0 ? strategy.position_avg_price * (1 + longStopLoss) : na // strategy.risk.allow_entry_in(longTrading == true and shortTrading == true ? strategy.direction.all : longTrading == true ? strategy.direction.long : shortTrading == true ? strategy.direction.short : na) // strategy.entry('Bull', strategy.long, comment='B Long', when=FinalBullAlert or FinalBullAlert2) // strategy.entry('Bull', strategy.long, comment='HB Long', when=FinalHiddenBullAlert2 or FinalHiddenBullAlert) // // check which SL to use // if enableSL and whichSL == 'use the static % as SL' // strategy.exit(id='longTP-SL', from_entry='Bull', limit=longTP1, stop=longSL) // // strategy.exit(id='longTP-SL', qty_percent=25, from_entry='Bull', limit=longTP2, stop=longSlLow) // // strategy.exit(id='longTP-SL', qty_percent=25, from_entry='Bull', limit=longTP3, stop=longSlLow) // // strategy.exit(id='longTP-SL', qty_percent=25, from_entry='Bull', limit=longTP4, stop=longSlLow) // // get bars since last entry for the SL at low to work // barsSinceLastEntry()=> // strategy.opentrades > 0 ? (bar_index - strategy.opentrades.entry_bar_index(strategy.opentrades-1)) : na // if enableSL and whichSL == 'use the low as SL' and ta.barssince(veryFinalAlert) < 2 and barsSinceLastEntry() < 2 // strategy.exit(id='longTP-SL', from_entry='Bull', limit=longTP1, stop=longSlLow) // // strategy.exit(id='longTP-SL', qty_percent=25, from_entry='Bull', limit=longTP2, stop=longSlLow) // // strategy.exit(id='longTP-SL', qty_percent=25, from_entry='Bull', limit=longTP3, stop=longSlLow) // // strategy.exit(id='longTP-SL', qty_percent=25, from_entry='Bull', limit=longTP4, stop=longSlLow) // if not enableSL // strategy.exit(id='longTP-SL', from_entry='Bull', limit=longTP1) // // strategy.exit(id='longTP-SL', qty_percent=25, from_entry='Bull', limit=longTP2) // // strategy.exit(id='longTP-SL', qty_percent=25, from_entry='Bull', limit=longTP3) // // strategy.exit(id='longTP-SL', qty_percent=25, from_entry='Bull', limit=longTP4)
Episodic Pivot
https://www.tradingview.com/script/PZghP0Uq-Episodic-Pivot/
yogy.frestarahmawan
https://www.tradingview.com/u/yogy.frestarahmawan/
163
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © yogy.frestarahmawan // original idea by stockbee episodic pivot screen 1 //@version=4 study("Episodic Pivot", overlay = false) cond1 = if close / close[1] > 1.04 true else false sma50vol = sma(volume, 50) cond2 = if volume > 3 * sma50vol true else false cond3 = if volume > 300000 true else false val = if cond1 and cond2 and cond3 1 else 0 plot(series=val, style = plot.style_columns, color=val > 0 ? color.green : color.red)
High Low Open Mid Ranges & Levels (Multi-Timeframe)
https://www.tradingview.com/script/yj4FibJH-High-Low-Open-Mid-Ranges-Levels-Multi-Timeframe/
Shanxia
https://www.tradingview.com/u/Shanxia/
997
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Shanxia //@version=5 indicator("High Low Open Mid Ranges", shorttitle="OHLM", overlay=true, max_lines_count=500, max_labels_count=500) var string title2 = "Table Options" //==========>>Inputs<<==========// tfbool = input.bool ( true, "", inline="bool1") higherTF = input.timeframe ( "W", "Timeframe ⏰ ", inline="bool1") bool3 = input.bool ( false, "Extend Last Range | ", inline="y4") bool4 = input.int ( 30, "", inline="y4") lstyle1 = input.string ( "Dotted", "  Linestyles", options=["Dotted", "Solid", "Dashed"], inline="in2") style1 = lstyle1 == "Dotted" ? line.style_dotted : lstyle1 == "Solid" ? line.style_solid : line.style_dashed lstyle2 = input.string ( "Solid", "", options=["Dotted", "Solid", "Dashed"], inline="in2") style2 = lstyle2 == "Dotted" ? line.style_dotted : lstyle2 == "Solid" ? line.style_solid : line.style_dashed ex = input.string ( "Right", "  Extend", options=["Right", "None"], inline="in3") ex1 = ex == "Right" ? extend.right : extend.none lwidth = input.string ( "2", "Width", options=["1", "2", "3", "4", "5"], inline="in3") width = lwidth == "1" ? 1 : lwidth == "2" ? 2 : lwidth == "3" ? 3 : lwidth == "4" ? 4 : 5 my_color = input.color ( color.aqua, "  Line", inline="in1") my_color2 = input.color ( #166cff, "", inline="in1") txtcol = input.color ( color.new(color.white, 10), "Text", inline="in1") txtcol2 = input.color ( color.new(color.aqua, 0), "", inline="in1") inp = input.bool ( true, "Price", inline="in4") inpoff = input.int ( 15, " | Offset", inline="in4") i_q = input.bool ( false, "Quarters | ", inline="in5") i_t = input.bool ( true, "Table | ", inline="in5") i_h = input.bool ( true, " Historic Ranges", inline="in5") i_mr1 = input.bool ( false, "", inline="in10", tooltip="Monday's Timezone (TZ) can be adjusted below") i_mr1a = input.string ( "Monday", "", options=["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], inline="in10") i_mr1ab = i_mr1a == "Monday" ? dayofweek.monday : i_mr1a == "Tuesday" ? dayofweek.tuesday : i_mr1a == "Wednesday" ? dayofweek.wednesday : i_mr1a == "Thursday" ? dayofweek.thursday : i_mr1a == "Friday" ? dayofweek.friday : i_mr1a == "Saturday" ? dayofweek.saturday : i_mr1a == "Sunday" ? dayofweek.sunday:na i_mr2 = input.color ( color.new(#705eff, 0), "  Line Color", inline="in9") i_mr3 = input.color ( color.new(#705eff, 0), "Text Color", inline="in9") i_mr4 = input.int ( 45, "|", inline="in10") i_v1 = input.bool ( true, "V-lines", inline="in12") i_v2 = input.string ( "Dashed", "| Style", options=["Dotted", "Solid", "Dashed"], inline="in12") i_v2a = i_v2 == "Dotted" ? line.style_dotted : i_v2 == "Solid" ? line.style_solid : line.style_dashed i_v3 = input.string ( "1", "  Width", options=["1", "2", "3", "4", "5"], inline="in13") i_v3a = i_v3 == "1" ? 1 : i_v3 == "2" ? 2 : i_v3 == "3" ? 3 : i_v3 == "4" ? 4 : 5 i_v4 = input.color ( color.new(#843dff,0), "", inline="in13") i_d1 = input.bool ( false, "Day of week labels", inline="in14", tooltip="The timezone(TZ) can be adjusted below") i_d2 = input.color ( #d1d4dc, "|", inline="in14") i_d3 = input.int ( 3, "  Offset", inline="in15") i_d4 = input.string ( "GMT+10", "TZ", options=["GMT+0", "GMT+1", "GMT+2", "GMT+3","GMT+4","GMT+5","GMT+6","GMT+7","GMT+8","GMT+9","GMT+10","GMT+11","GMT+12","GMT-1", "GMT-2", "GMT-3","GMT-4","GMT-5","GMT-6","GMT-7","GMT-8","GMT-9","GMT-10","GMT-11","GMT-12"], inline="in15") op1 = input.string ( "BRight", "  Position", options=["BRight", "BLeft", "TRight", "TLeft"], group=title2, inline="in6") op1a = op1 == "BRight" ? position.bottom_right : op1 == "BLeft" ? position.bottom_left : op1 == "TRight" ? position.top_right : op1 == "TLeft" ? position.top_left : na op2 = input.string ( "Normal", "Size", options=["Auto", "Tiny", "Small", "Normal", "Large", "Huge"], group=title2, inline="in6") op2a = op2 == "Normal" ? size.normal : op2 == "Tiny" ? size.tiny : op2 == "Normal" ? size.normal : op2 == "Small" ? size.small : op2 == "Large" ? size.large : op2 == "Huge" ? size.huge : op2 == "Auto" ? size.auto : na op3 = input.string ( "1", "  Border Width", options=["1", "2", "3", "4"], group=title2, inline="in7") op3a = op3 == "1" ? 1 : op3 == "2" ? 2 : op3 == "3" ? 3 : op3 == "4" ? 4 : na op4 = input.color ( #388cff, "|", group=title2, inline="in7") op5 = input.color ( color.new(#000000, 20), "  Colors", group=title2, inline="in8") op6 = input.color ( color.new(color.navy, 20), "", group=title2, inline="in8") op7 = input.color ( color.new(color.white, 10), "|", group=title2, inline="in8") op8 = input.color ( color.new(color.white,10), "", group=title2, inline="in8") //==========>>End of Inputs<<==========// //==========>>Main Security<<==========// i_mid = request.security ( syminfo.tickerid, higherTF, hl2, lookahead=barmerge.lookahead_on) i_open = request.security ( syminfo.tickerid, higherTF, open, lookahead=barmerge.lookahead_on) i_high = request.security ( syminfo.tickerid, higherTF, high, lookahead=barmerge.lookahead_on) i_low = request.security ( syminfo.tickerid, higherTF, low, lookahead=barmerge.lookahead_on) L_mid = i_mid L_open = i_open L_high = i_high L_low = i_low //==========>>Weekday Security<<==========// sec1 = request.security ( syminfo.tickerid, "D", high, lookahead=barmerge.lookahead_on) sec2 = request.security ( syminfo.tickerid, "D", low, lookahead = barmerge.lookahead_on) sec3 = request.security ( syminfo.tickerid, "D", open, lookahead = barmerge.lookahead_on) sec4 = request.security ( syminfo.tickerid, "D", hl2, lookahead = barmerge.lookahead_on) h = sec1 l = sec2 o = sec3 m = sec4 //==========>>Calculations<<===========// tq = (i_high + i_mid) / 2 bq = (i_mid + i_low) / 2 tql = tq bql = bq //==========>>Calc End<<===========// var label vlab1 = na var label vlab2 = na var label vlab3 = na var label vlab4 = na var label vlab5 = na var label vlab6 = na //==========>>Function for Main Ranges<<==========// f_line1(a, b, c) => var line hline = na var label hlabel = na if L_low[1] != L_low line.set_x2(hline, bar_index) line.set_extend(hline, extend.none) line.set_style(hline, style1) line.set_color(hline, i_h ? my_color : na) hline := line.new(bar_index, a, bar_index + 1, a, xloc.bar_index, ex1, my_color, style2, width) label.set_textcolor(hlabel, i_h ? txtcol2 : na) hlabel:=label.new(bar_index[1], a[1], inp ? "L" + + b + str.tostring(a[1]) : "L" + c, style=label.style_none, textcolor=bool3 ? na : i_h ? txtcol2 : na) //==========>>Function Extended Previous Ranges<<==========// f_line2(a, b, c) => var line hline = na if bool3 and L_low[1] != L_low line.set_x2(hline, bar_index) line.set_extend(hline, extend.none) line.set_style(hline, style1) line.set_color(hline, i_h ? my_color2 : na) hline := line.new(bar_index, a[1], bar_index + 1, a[1], xloc.bar_index, ex1, my_color2, style1, width) lb = label.new(bar_index + inpoff, a, inp ? higherTF+ b + str.tostring(a) : higherTF + c, textcolor=txtcol, style=label.style_none) label.delete(lb[1]) lba = label.new(bar_index + bool4, line.get_y1(hline), inp ? "L" + higherTF + b + str.tostring(line.get_y1(hline)[1]) : "L" + higherTF + c, style=label.style_none, textcolor=bool3 ? txtcol2 :na) label.delete(lba[1]) //==========>>Function Weekday Ranges<<==========// f_line3(a,b,c)=> var line h1 = na if i_mr1 and dayofweek(time, i_d4) == i_mr1ab and h[1] != h line.set_x2(h1, bar_index) line.set_extend(h1, extend.none) line.set_style(h1, style1) h1 := line.new(bar_index, a, bar_index + 1, a, xloc.bar_index, ex1, i_mr2, style2, width) a1 = line.get_y1(h1)[1] label.new(bar_index, a1, inp ? b + ": " + str.tostring(a1):b, style=label.style_none, textcolor=i_mr3) b1 = line.get_y1(h1) lb = label.new(bar_index + i_mr4, b1, inp? i_mr1a + c + ": " + str.tostring(b1) : i_mr1a + c, style=label.style_none, textcolor=i_mr3) label.delete(lb[1]) //==========>>Vertical Session Dividers<<==========// vline(a) => if ta.change(time(higherTF)) and i_v1 line.new(a, low - ta.tr , a, high + ta.tr, xloc.bar_index, extend.both, i_v4, i_v2a, i_v3a) vline(bar_index) //==========>>Arguments<===========// if tfbool f_line1( L_open, "O | ", "O"), f_line1( L_mid, "M | ", "M") f_line1( L_high, "H | ", "H"), f_line1(L_low, "L | ", "L") f_line2(L_open, " | Open | ", " | Open"), f_line2(L_mid, " | Mid | ", " | Mid") f_line2(L_high, " | High | ", " | High"), f_line2(L_low, " | Low | ", " | Low") if i_q f_line1( tql, "TQ | ", "TQ"), f_line1( bql, "BQ | ", "BQ") f_line2(tql, " | TQ | ", " | TQ"), f_line2(bql, " | BQ | ", " | BQ") f_line3( h, "H", "High"), f_line3( l, "L", "Low") f_line3( o, "O", "Open"), f_line3( m, "M", "Mid") //===========>>Table<<==========// var table pan = table.new(op1a, 5, 10, color.new(color.blue,100), i_t ? op4 : na, op3a, i_t ? op4 : na, op3a) tc(x,y,z) => table.cell(pan, x, y, z, text_color=op7, bgcolor=op5, text_size=op2a) ts(v, w, x, y) => z = request.security(syminfo.tickerid, v, w, lookahead=barmerge.lookahead_on ) table.cell(pan, x, y, str.tostring(z), text_color=op8, bgcolor=op6, text_size=op2a) if i_t tc(0,0,"TF"), tc(1,0,"Open"), tc(2, 0, "High"), tc(3,0, "Low") tc(4, 0, "Mid"), tc(0, 1, "D"), tc(0, 2, "YD"), tc(0,3,"W") tc(0,4, "LW"), tc(0,5, "M"), tc(0,6,"LM"), tc(0,7,"Q") tc(0,8,"LQ") ts('D', open, 1,1), ts('D', high, 2,1), ts('D', low, 3,1), ts('D', hl2, 4,1) ts('D', open[1], 1,2), ts('D', high[1], 2,2), ts('D', low[1], 3,2), ts('D', hl2[1], 4,2) ts('W', open, 1,3), ts('W', high, 2,3), ts('W', low, 3,3), ts('W', hl2, 4,3) ts('W', open[1], 1,4), ts('W', high[1], 2,4), ts('W', low[1], 3,4), ts('W', hl2[1], 4,4) ts('M', open, 1,5), ts('M', high, 2,5), ts('M', low, 3,5), ts('M', hl2, 4,5) ts('M', open[1], 1,6), ts('M', high[1], 2,6), ts('M', low[1], 3,6), ts('M', hl2[1], 4,6) ts('3M', open, 1,7), ts('3M', high, 2,7), ts('3M', low, 3,7), ts('3M', hl2, 4,7) ts('3M', open[1], 1,8), ts('3M', high[1], 2,8), ts('3M', low[1], 3,8), ts('3M', hl2[1], 4,8) //==========>>Day of Week Labels<<==========// plotshape(i_d1 ? ta.change(time('D')) and dayofweek(time, i_d4) == dayofweek.monday : na, "", shape.circle, location.bottom, color.new(color.black,100), i_d3, "MON", i_d2, false, size.tiny) plotshape(i_d1 ? ta.change(time('D')) and dayofweek(time, i_d4) == dayofweek.tuesday : na, "", shape.circle, location.bottom, color.new(color.black,100), i_d3, "TUE", i_d2, false, size.tiny) plotshape(i_d1 ? ta.change(time('D')) and dayofweek(time, i_d4) == dayofweek.wednesday : na, "", shape.circle, location.bottom, color.new(color.black,100), i_d3, "WED", i_d2, false, size.tiny) plotshape(i_d1 ? ta.change(time('D')) and dayofweek(time, i_d4) == dayofweek.thursday : na, "", shape.circle, location.bottom, color.new(color.black,100), i_d3, "THU", i_d2, false, size.tiny) plotshape(i_d1 ? ta.change(time('D')) and dayofweek(time, i_d4) == dayofweek.friday : na, "", shape.circle, location.bottom, color.new(color.black,100), i_d3, "FRI", i_d2, false, size.tiny) plotshape(i_d1 ? ta.change(time('D')) and dayofweek(time, i_d4) == dayofweek.saturday : na, "", shape.circle, location.bottom, color.new(color.black,100), i_d3, "SAT", i_d2, false, size.tiny) plotshape(i_d1 ? ta.change(time('D')) and dayofweek(time, i_d4) == dayofweek.sunday : na, "", shape.circle, location.bottom, color.new(color.black,100), i_d3, "SUN", i_d2, false, size.tiny)
[AB] Support/Resistance Drawing Tool
https://www.tradingview.com/script/elEijJZP-AB-Support-Resistance-Drawing-Tool/
akalibot1987
https://www.tradingview.com/u/akalibot1987/
65
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © akalibot1987 //@version=4 study("[AB] Support/Resistance Drawing Tool", max_lines_count=500, overlay=true) src = input(close, title="Source") step = input(0.1, title="Source Rounding") len = input(500, title="Length (Array)") lenSR = input(20, title="Sampled Support/Resistance Length") skip = input(2, title="Sampling Skip") transpSkip = input(5, title="Transparency Skip") colorR = input(0, title="Color R") colorG = input(0, title="Color G") colorB = input(0, title="Color B") custom_round(src, step)=> rounded = step*round(src/step) rounded = custom_round(src, step) resistance = highest(rounded, lenSR) support = lowest(rounded, lenSR) var arrayResistance = array.new_float(len) var arraySupport = array.new_float(len) array.shift(arrayResistance) array.shift(arraySupport) array.push(arrayResistance, resistance) array.push(arraySupport, support) for i = 0 to len-1 by skip rly = array.get(arrayResistance, i) sly = array.get(arraySupport, i) line.new(bar_index-len, rly, bar_index, rly, color=color.rgb(colorR,colorG,colorB,100-transpSkip)) line.new(bar_index-len, sly, bar_index, sly, color=color.rgb(colorR,colorG,colorB,100-transpSkip)) plot(rounded)
HESU - How EMA's are Supposed To Be Used
https://www.tradingview.com/script/IYZ5uPbO-HESU-How-EMA-s-are-Supposed-To-Be-Used/
Celar
https://www.tradingview.com/u/Celar/
18
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Celar //@version=4 study("How EMA's are Supposed To Be Used", shorttitle='HESU') vol = sma(volume, 10) rock = roc(vol, 5) ema20 = ema(close, 20) sma50 = sma(close, 50) max = highest(close, 50) color1 = rock[1] < rock or rock[2] < rock[1] or rock[3] < rock[2] or max[1]< max ? ema20 > sma50 and max[10]<max ? color.green : color.red : color.red x = plot(ema20, color = color.blue, linewidth = 3) y = plot(sma50, color = color.orange) fill(x, y, color=color1, transp = 60)
The Echo Forecast [LuxAlgo]
https://www.tradingview.com/script/Y8v4W3mX-The-Echo-Forecast-LuxAlgo/
LuxAlgo
https://www.tradingview.com/u/LuxAlgo/
3,731
study
5
CC-BY-NC-SA-4.0
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/ // © LuxAlgo //@version=5 indicator("Echo Forecast [LuxAlgo]","LuxAlgo - ECHO", overlay = true, max_bars_back = 1000, max_lines_count = 200) //-----------------------------------------------------------------------------} //Settings //-----------------------------------------------------------------------------{ length = input.int(50, 'Evaluation Window', minval = 0, maxval = 200) fcast = input.int(50, 'Forecast Window', minval = 1, maxval = 200) fmode = input.string('Similarity', 'Forecast Mode', options = ['Similarity','Dissimilarity']) cmode = input.string('Cumulative', 'Forecast Construction', options = ['Cumulative','Mean','Linreg']) src = input(close) //Style fcastCss = input(#2157f3, 'Forecast Style', inline = 'fcast_style', group = 'Style') fcastStyle = input.string('· · ·', '', options = ['──','- - -','· · ·'], inline = 'fcast_style', group = 'Style') showArea = input(true,'Show Area', inline = 'areas', group = 'Style') refArea = input(color.new(#ff5d00, 80), '', inline = 'areas', group = 'Style') corrArea = input(color.new(#089981, 80), '', inline = 'areas', group = 'Style') evalArea = input(color.new(color.gray, 80),'', inline = 'areas', group = 'Style') //-----------------------------------------------------------------------------} //Populate line arrays //-----------------------------------------------------------------------------{ var lines = array.new_line(0) if barstate.isfirst for i = 0 to fcast-1 array.push(lines,line.new(na,na,na,na , style = fcastStyle == '- - -' ? line.style_dashed : fcastStyle == '· · ·' ? line.style_dotted : line.style_solid , color = fcastCss)) //-----------------------------------------------------------------------------} //Calculations //-----------------------------------------------------------------------------{ var eval_window = box.new(na,na,na,na,na, bgcolor = evalArea) var ref_window = box.new(na,na,na,na,na, bgcolor = refArea) var corr_window = box.new(na,na,na,na,na, bgcolor = corrArea) n = bar_index d = src - src[1] //Get range maximum/minimum top = ta.highest(src, length + fcast * 2) btm = ta.lowest(src, length + fcast * 2) //Set forecast if barstate.islast k = 0 float val = na A = array.new_float(0) //Calculation window X = array.new_int(0) //Linreg independant variable //Populate calculation window for i = 0 to fcast*2+length A.push(src[i]) //Populate independant variable array if cmode == 'Linreg' X.push(n[i]) a = A.slice(0, fcast-1) //Reference window //Find window to produce forecast for i = 0 to length-1 b = A.slice(fcast + i, fcast * 2 + i - 1) //Evaluation window r = a.covariance(b) / (a.stdev() * b.stdev()) //Correlation //Maximization or minimization problem if fmode == 'Similarity' val := r >= nz(val, r) ? r : val else val := r <= nz(val, r) ? r : val k := val == r ? i : k //Set ECHO prev = src current = src for i = 0 to fcast-1 e = d[fcast + k + (fcast-i-1)] //Get forecast point if cmode == 'Mean' current := array.avg(a) + e else if cmode == 'Linreg' a = A.slice(0, fcast) x = X.slice(0, fcast) alpha = a.covariance(x) / x.variance() beta = a.avg() - alpha * x.avg() current := alpha * (n + i + 1) + beta + e else current += e l = lines.get(i) l.set_xy1(n+i, prev) l.set_xy2(n+i+1, current) prev := current //Set areas if showArea //Evaluation window eval_window.set_lefttop(n-length-fcast*2+1, top) eval_window.set_rightbottom(n-fcast+1, btm) //Reference window ref_window.set_lefttop(n-fcast+1, top) ref_window.set_rightbottom(n, btm) //Correlation window corr_window.set_lefttop(n-k-fcast*2+1, top) corr_window.set_rightbottom(n-k-fcast, btm) //-----------------------------------------------------------------------------}
Hotch v1.02 RSI+Fractals/VWAP Bands/Smoothed Moving Average.
https://www.tradingview.com/script/cK6p9RSk-Hotch-v1-02-RSI-Fractals-VWAP-Bands-Smoothed-Moving-Average/
Hotchachachaaa
https://www.tradingview.com/u/Hotchachachaaa/
112
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © plewis22782 //@version=4 // study("Hotch v1.02", overlay=true) n = input(title="Periods", defval=2, minval=2, type=input.integer) // UpFractal bool upflagDownFrontier = true bool upflagUpFrontier0 = true bool upflagUpFrontier1 = true bool upflagUpFrontier2 = true bool upflagUpFrontier3 = true bool upflagUpFrontier4 = true for i = 1 to n upflagDownFrontier := upflagDownFrontier and (high[n-i] < high[n]) upflagUpFrontier0 := upflagUpFrontier0 and (high[n+i] < high[n]) upflagUpFrontier1 := upflagUpFrontier1 and (high[n+1] <= high[n] and high[n+i + 1] < high[n]) upflagUpFrontier2 := upflagUpFrontier2 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+i + 2] < high[n]) upflagUpFrontier3 := upflagUpFrontier3 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+i + 3] < high[n]) upflagUpFrontier4 := upflagUpFrontier4 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+4] <= high[n] and high[n+i + 4] < high[n]) flagUpFrontier = upflagUpFrontier0 or upflagUpFrontier1 or upflagUpFrontier2 or upflagUpFrontier3 or upflagUpFrontier4 upFractal = (upflagDownFrontier and flagUpFrontier) // downFractal bool downflagDownFrontier = true bool downflagUpFrontier0 = true bool downflagUpFrontier1 = true bool downflagUpFrontier2 = true bool downflagUpFrontier3 = true bool downflagUpFrontier4 = true for i = 1 to n downflagDownFrontier := downflagDownFrontier and (low[n-i] > low[n]) downflagUpFrontier0 := downflagUpFrontier0 and (low[n+i] > low[n]) downflagUpFrontier1 := downflagUpFrontier1 and (low[n+1] >= low[n] and low[n+i + 1] > low[n]) downflagUpFrontier2 := downflagUpFrontier2 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+i + 2] > low[n]) downflagUpFrontier3 := downflagUpFrontier3 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+i + 3] > low[n]) downflagUpFrontier4 := downflagUpFrontier4 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+4] >= low[n] and low[n+i + 4] > low[n]) flagDownFrontier = downflagUpFrontier0 or downflagUpFrontier1 or downflagUpFrontier2 or downflagUpFrontier3 or downflagUpFrontier4 downFractal = (downflagDownFrontier and flagDownFrontier) rsiSource = input(title="RSI Source", type=input.source, defval=close) rsiLength = input(title="RSI Length", type=input.integer, defval=14) rsiValue = rsi(rsiSource, rsiLength) rsiLookback = input(title="RSI Lookback", type=input.integer, defval=3) ifRsiB40 = lowest(rsiValue,rsiLookback)<= 40 and lowest(rsiValue,rsiLookback)>30 ifRsiB30 = lowest(rsiValue,rsiLookback)<= 30 and lowest(rsiValue,rsiLookback)>20 ifRsiB20 = lowest(rsiValue,rsiLookback)<= 20 and lowest(rsiValue,rsiLookback)>0 plotB40 = ifRsiB40 and (downflagDownFrontier and flagDownFrontier) plotB30 = ifRsiB30 and (downflagDownFrontier and flagDownFrontier) plotB20 = ifRsiB20 and (downflagDownFrontier and flagDownFrontier) plotshape(plotB40, location=location.belowbar, offset=-n, color=#B0FF9E, style=shape.triangleup, size = size.small ) plotshape(plotB30, location=location.belowbar, offset=-n, color=#1EFF00, style=shape.triangleup, size = size.small ) plotshape(plotB20, location=location.belowbar, offset=-n, color=#0A5200, style=shape.triangleup, size = size.small ) ifRsiO60 = highest(rsiValue,rsiLookback)>= 60 and highest(rsiValue,rsiLookback)<70 ifRsiO70 = highest(rsiValue,rsiLookback)>= 70 and highest(rsiValue,rsiLookback)<80 ifRsiO80 = highest(rsiValue,rsiLookback)>= 80 and highest(rsiValue,rsiLookback)<100 plotO60 = ifRsiO60 and (upflagDownFrontier and flagUpFrontier) plotO70 = ifRsiO70 and (upflagDownFrontier and flagUpFrontier) plotO80 = ifRsiO80 and (upflagDownFrontier and flagUpFrontier) plotshape(plotO60, location=location.abovebar, offset=-n, color=#FF9B94, style=shape.triangledown, size = size.small ) plotshape(plotO70, location=location.abovebar, offset=-n, color=#FF0008, style=shape.triangledown, size = size.small ) plotshape(plotO80, location=location.abovebar, offset=-n, color=#750004, style=shape.triangledown, size = size.small ) //Vwap computeVWAP(src, isNewPeriod, stDevMultiplier) => var float sumSrcVol = na var float sumVol = na var float sumSrcSrcVol = na sumSrcVol := isNewPeriod ? src * volume : src * volume + sumSrcVol[1] sumVol := isNewPeriod ? volume : volume + sumVol[1] // sumSrcSrcVol calculates the dividend of the equation that is later used to calculate the standard deviation sumSrcSrcVol := isNewPeriod ? volume * pow(src, 2) : volume * pow(src, 2) + sumSrcSrcVol[1] _vwap = sumSrcVol / sumVol variance = sumSrcSrcVol / sumVol - pow(_vwap, 2) variance := variance < 0 ? 0 : variance stDev = sqrt(variance) lowerBand = _vwap - stDev * stDevMultiplier upperBand = _vwap + stDev * stDevMultiplier [_vwap, lowerBand, upperBand] hideonDWM = input(false, title="Hide VWAP on 1D or Above", group="VWAP Settings") var anchor = input(defval = "Session", title="Anchor Period", type=input.string, options=["Session", "Week", "Month", "Quarter", "Year", "Decade", "Century", "Earnings", "Dividends", "Splits"], group="VWAP Settings") src = input(title = "Source", type = input.source, defval = hlc3, group="VWAP Settings") offset = input(0, title="Offset", group="VWAP Settings") showBands = input(true, title="Calculate Bands", group="Standard Deviation Bands Settings") stdevMult = input(2.0, title="Bands Multiplier", group="Standard Deviation Bands Settings") timeChange(period) => change(time(period)) new_earnings = earnings(syminfo.tickerid, earnings.actual, barmerge.gaps_on, barmerge.lookahead_on) new_dividends = dividends(syminfo.tickerid, dividends.gross, barmerge.gaps_on, barmerge.lookahead_on) new_split = splits(syminfo.tickerid, splits.denominator, barmerge.gaps_on, barmerge.lookahead_on) isNewPeriod = anchor == "Earnings" ? new_earnings : anchor == "Dividends" ? new_dividends : anchor == "Splits" ? new_split : na(src[1]) ? true : anchor == "Session" ? timeChange("D") : anchor == "Week" ? timeChange("W") : anchor == "Month" ? timeChange("M") : anchor == "Quarter" ? timeChange("3M") : anchor == "Year" ? timeChange("12M") : anchor == "Decade" ? timeChange("12M") and year % 10 == 0 : anchor == "Century" ? timeChange("12M") and year % 100 == 0 : false float vwapValue = na float std = na float upperBandValue = na float lowerBandValue = na if not (hideonDWM and timeframe.isdwm) [_vwap, bottom, top] = computeVWAP(src, isNewPeriod, stdevMult) vwapValue := _vwap upperBandValue := showBands ? top : na lowerBandValue := showBands ? bottom : na plot(vwapValue, title="VWAP", color=#2962FF, offset=offset) upperBand = plot(upperBandValue, title="Upper Band", color=color.green, offset=offset) lowerBand = plot(lowerBandValue, title="Lower Band", color=color.green, offset=offset) fill(upperBand, lowerBand, title="Bands Fill", color= showBands ? color.new(color.green, 95) : na) // ATR Bands atrlength = input(title="ATR Length", defval=3, minval=1) smoothing = input(title="ATR Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"]) ma_function(source, atrlength) => if smoothing == "RMA" rma(source, atrlength) else if smoothing == "SMA" sma(source, atrlength) else if smoothing == "EMA" ema(source, atrlength) else wma(source, atrlength) ATR = ma_function(tr(true), atrlength) var bool longcondA = na var bool shortcondA = na var bool showLongA = na var bool showShortA = na var bool longcondB = na var bool shortcondB = na var bool showLongB = na var bool showShortB = na var bool showOnlyFirstSignal = true /////////////////////////////////////////////////////// Long and Short Conditions ///////////////////////////////////////////////////////////// //enter long trades when price is over MA and below https://www.tradingview.com/chart/NJKISpRE/#rsiOversold at bar close //enter short trade when price is under MA and over rsiOverbought at bar close //Get simple moving average user inputs len1 = input(title= "MA Period", type=input.integer, defval=1000) //input(21, minval=1, title="Length 1", group = "Smoothed MA Inputs") src1 = close //input(close, title="Source 1", group = "Smoothed MA Inputs") smma1 = 0.0 sma_1 = sma(src1, len1) smma1 := na(smma1[1]) ? sma_1 : (smma1[1] * (len1 - 1) + src1) / len1 plot(smma1, color=color.white, linewidth=2, title="SMMA") //get user inputs rsiOverboughtA = input(title="RSI Overbought", type=input.integer,defval=70) rsiOversoldA = input(title="RSI Oversold", type=input.integer,defval=30) //Get RSI Value var bool wasRsiOBA = na var bool wasRsiOSA = na ifRsiOBA = rsiValue>= rsiOverboughtA ifRsiOSA = rsiValue<= rsiOversoldA if ifRsiOBA wasRsiOBA := true if ifRsiOSA wasRsiOSA := true buySigA = downFractal and wasRsiOSA sellSigA = upFractal and wasRsiOBA plotshape(sellSigA, location=location.top, color=color.orange, style=shape.triangledown, size = size.small ) plotshape(buySigA, location=location.bottom, color=color.blue, style=shape.triangleup, size = size.small ) alertcondition(sellSigA, title="Sell Signal", message= "Potential selling point") alertcondition(buySigA, title="Buy Signal", message= "Potential buying point") //entrylogic // long = ifRsiOS && price over SMA // short = IfRsiOB && price under SMA longconditionA = wasRsiOSA and downFractal shortconditionA = wasRsiOBA and upFractal // showLongA := showOnlyFirstSignal ? longconditionA and not longconditionA[1] : longcondA showShortA := showOnlyFirstSignal ? shortconditionA and not shortconditionA[1] : shortcondA if (showLongA) wasRsiOSA := false if (showShortA) wasRsiOBA:=false
Relative Strength Index with Range Shift
https://www.tradingview.com/script/8fN04t1D-Relative-Strength-Index-with-Range-Shift/
kevindcarr
https://www.tradingview.com/u/kevindcarr/
44
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © kevindcarr //@version=5 indicator(title='Relative Strength Index with Range Shift', shorttitle='RSI', overlay=false, precision=1) var table conditionTable = table.new(position=position.top_right, columns=1, rows=1) log = input.string(title='Scale', options=['Logarithmic', 'Regular'], defval='Logarithmic') range_1 = input.string(title='Range Bias', options=['Bullish', 'Strong Bullish', 'Bearish', 'Strong Bearish', 'No Bias'], defval='Bullish') lookbackPeriod = input(title='Lookback Period', defval=14) source = input(title='Source', defval=close) rangeShift(range_2) => if range_2 == 'Bullish' [40, 60, 80] else if range_2 == 'Strong Bullish' [45, 65, 85] else if range_2 == 'Bearish' [35, 55, 75] else if range_2 == 'Strong Bearish' [30, 50, 70] else [40, 60, 80] condition(rsi, range_3) => [lo, mid, hi] = rangeShift(range_3) if rsi <= lo [color.green, 'Very Oversold'] else if rsi <= mid [color.yellow, 'Oversold'] else if rsi <= hi [color.orange, 'Overbought'] else [color.red, 'Very Overbought'] rsiSource = (log == 'Logarithmic' ? math.log(source) : source) rsi = ta.rsi(rsiSource, lookbackPeriod) [col, txt] = condition(rsi, range_1) table.cell(conditionTable, 0, 0, text=txt, bgcolor=col) plot(series=rsi, title='Relative Strength Index', color=col)
Oscillator Edges
https://www.tradingview.com/script/jUCzQeA9-Oscillator-Edges/
jarzido
https://www.tradingview.com/u/jarzido/
288
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © jarzido //@version=5 indicator('Oscillator Edges', overlay=true) src = input(title='Input', defval=close) preset = input.string(title="Osc. Preset", defval="Stoch 1", options=["None", "Specified RSI", "Specified Stoch", "Stoch 1", "Stoch 2"] ) showOsc = input.bool(title="Oscillator Mode", tooltip="Check this if you want to show the oscillator. Uncheck this if you prefer to use the indicator on the main chart with moving averages. " + "To use this, be sure to disable all the moving averages 1-6.", defval=false) length = input.int(40, title="RSI Length", minval=1) smoothing = input.int(title="RSI Smoothing", defval=1, minval=1) lag = input.int(title="Lag", tooltip="For plot backshadow", defval=3, minval=1) maColorChange = input.bool(title="MA Osc Color", tooltip="Use Oscillator color change for MA Colors", defval=true) //High Inputs osc_max = input.int(title="Osc. Max", inline="maxVal", tooltip="Maximum value of the oscillator. Lower this if you want color to change more drastically/sooner. Otherwise leave alone unless you're using one not built-in.", defval=100) osc_high = input(title='Osc. High', inline="high", tooltip="Above this value will trigger alerts/shapes", defval=90) shC = input(title='', inline="maxVal", defval=#FD1717) hC = input(title='', inline="high", defval=#FFEE00) //Low Inputs osc_low = input(title='Osc. Low',inline="lowest", tooltip="Below this value will trigger alerts/shapes", defval=15) osc_min = input.int(title="Osc. Min", inline="low", tooltip="Minimum value of the oscillator. Raise this if you want color to change more drastically/sooner. Otherwise leave alone unless you're using one not built-in.", defval=0) lC = input(title='', inline="lowest", defval=#003193) slC = input(title='', inline="low", defval=#00FF0E) //Background fill color bfC = input.color(title="Band Fill Color", tooltip = "Color to fill in the band when used in oscillator mode. Also used to fill in the neutral spaces between moving averages when not in oscillator mode.", defval=color.rgb(126, 87, 194, 82)) lowerBandLvl = input.float(title="Band Oscillator Levels", inline="band", tooltip="Band High/low levels for when you're in oscillator mode. Also " + "used for triggering bear/bull signals.", defval = 30) upperBandLvl = input.float(title="", inline="band", defval = 70) //Neutral Fill color nSymbolColor = input.color(title="Neutral Symbol Color", tooltip="The neutral color for symbols when the oscillator is between values, should you choose to use it. Enable visibility for these in the 'Styles' panel.", defval=color.new(color.gray, 50)) //Minimum and maximum transparency for the fill gradient and oscillator oscShadow= input.int(title="Osc Shadow transparency", defval=50) mint = input.int(title="Gradient Min Transparency", defval=75) maxt = input.int(title="Gradient Max Transparency", defval=92) qG = input.int(title="Gradient Smoothing", tooltip="An EMA is applied to the oscillator value to smoothen out transitions. This is the EMA lookback. Lower value=faster, choppier color transitions. Higher Value = smoother, less subtle transitions.", minval=1, defval=3) //Most of this came out of the built in ribbon from Tradingview. Their built in scripts save so much time and effort, I'm truly thankful they believe in open sourcing their code. <3 ma1_length = input.int(9 , "" , inline="MA #1", minval=1) ma2_length = input.int(14 , "" , inline="MA #2", minval=1) ma3_length = input.int(21 , "" , inline="MA #3", minval=1) ma4_length = input.int(50 , "" , inline="MA #4", minval=1) ma5_length = input.int(100 , "" , inline="MA #5", minval=1) ma6_length = input.int(200 , "" , inline="MA #6", minval=1) show_ma1 = input(true , "MA №1", inline="MA #1") show_ma2 = input(true , "MA №2", inline="MA #2") show_ma3 = input(true , "MA №3", inline="MA #3") show_ma4 = input(true , "MA №4", inline="MA #4") show_ma5 = input(true , "MA №5", inline="MA #5") show_ma6 = input(true , "MA №6", inline="MA #6") ma1_type = input.string("EMA" , "" , inline="MA #1", options=["SMA", "EMA", "RMA", "WMA", "VWMA", "HMA"]) ma2_type = input.string("EMA" , "" , inline="MA #2", options=["SMA", "EMA", "RMA", "WMA", "VWMA", "HMA"]) ma3_type = input.string("EMA" , "" , inline="MA #3", options=["SMA", "EMA", "RMA", "WMA", "VWMA", "HMA"]) ma4_type = input.string("EMA" , "" , inline="MA #4", options=["SMA", "EMA", "RMA", "WMA", "VWMA", "HMA"]) ma5_type = input.string("EMA" , "" , inline="MA #5", options=["SMA", "EMA", "RMA", "WMA", "VWMA", "HMA"]) ma6_type = input.string("EMA" , "" , inline="MA #6", options=["SMA", "EMA", "RMA", "WMA", "VWMA", "HMA"]) ma1_color = input(color.new(#FFFFFF, 95), "" , inline="MA #1") ma2_color = input(color.new(#FFFFFF, 80), "" , inline="MA #2") ma3_color = input(color.new(#FFFFFF, 65), "" , inline="MA #3") ma4_color = input(color.new(#FFFFFF, 50), "" , inline="MA #4") ma5_color = input(color.new(#FFFFFF, 35), "" , inline="MA #5") ma6_color = input(color.new(#FFFFFF, 20), "" , inline="MA #6") //-------------------------------------------Functions //built-in preset bips(type) => type == "None" ? src : type == "Specified RSI" ? ta.sma(ta.rsi(src, length), smoothing) : type == "Specified Stoch" ? ta.sma(ta.stoch(close, high, low, length), smoothing) : type == "Stoch 1" ? ta.sma(ta.stoch(close, high, low, 40), 2) : type == "Stoch 2" ? ta.sma(ta.stoch(close, high, low, 81), 2) : src ocC(n) => color = color.white if n >= osc_high color.from_gradient(n, osc_high, osc_max, hC, shC) else if n <= osc_low color.from_gradient(n, osc_min, osc_low, lC, slC) else color.white osc=bips(preset) val = osc[0] //I'm lazy, but this could help depending on the language/compiler. I'm not sure in terms of Pine. cc = ocC(val) oH = val >= osc_high oL = val <= osc_low lbC = showOsc? #787B86 : na sbgc = showOsc? bfC : na midBandLvl =((upperBandLvl - lowerBandLvl)/2) + lowerBandLvl rsiUpperBand = plot(showOsc? upperBandLvl : na, "OSC Upper Band", color=lbC) rsiLowerBand = plot(showOsc? lowerBandLvl : na, "OSC Lower Band", color=lbC) m = plot(showOsc? midBandLvl : na, "OSC Middle Band", color=lbC ) t = plot(showOsc? osc_high : na, "OSC Edge Band", color=showOsc? color.new(hC, 10) : na, style=plot.style_circles) b = plot(showOsc? osc_low: na, "OSC Edge Band", color=showOsc? color.new(lC, 10): na, style=plot.style_circles) fill(rsiUpperBand, rsiLowerBand, color=bfC, title="OSC Background Fill") pc = (oL or oH) ? cc : color.new(#FFFFFF, 20) bc = color.new(pc, 90) p1 = plot(showOsc ? osc : na, title="Oscillator", color=pc ) p2 = plot(showOsc ? ta.ema(osc, lag) : na, title="Osc Lag", color=color.new(#FFFFFF, 100)) fill(p1, p2, color=showOsc? color.new(ocC(val), oscShadow) : na) //--------------------------Moving Average stuff. A good amount of this comes directly from the builtin ribbon ma(source, length, type) => type == "SMA" ? ta.sma(source, length) : type == "EMA" ? ta.ema(source, length) : type == "RMA" ? ta.rma(source, length) : type == "WMA" ? ta.wma(source, length) : type == "VWMA" ? ta.vwma(source, length) : type == "HMA" ? ta.hma(source, length) : na ggc(oc, n) => vv = ta.ema(val, qG) r = osc_max - osc_min cor = r/2 if (not maColorChange) bfC else if (vv > cor) if (vv < osc_high) color.from_gradient(vv, cor, osc_high, color.new(bfC, mint), color.new(hC, maxt-(mint/2))) //high else color.from_gradient(vv, osc_high, osc_max, color.new(hC, maxt-(mint/2)+1), color.new(shC, maxt)) //highest else if (vv > osc_low) color.from_gradient(vv, osc_low, cor, color.new(lC, maxt-(mint/2)), color.new(bfC, mint)) //low else color.from_gradient(vv, osc_min, osc_low, color.new(slC, mint), color.new(lC, maxt-(mint/2))) //lowest ma1 = ma(src, ma1_length, ma1_type) ma2 = ma(src, ma2_length, ma2_type) ma3 = ma(src, ma3_length, ma3_type) ma4 = ma(src, ma4_length, ma4_type) ma5 = ma(src, ma5_length, ma5_type) ma6 = ma(src, ma6_length, ma6_type) allMa = array.from(ma1, ma2, ma3, ma4, ma5, ma6) mp1 = plot(show_ma1 ? ma1 : na, color = ma1_color, title="MA №1") mp2 = plot(show_ma2 ? ma2 : na, color = ma2_color, title="MA №2") mp3 = plot(show_ma3 ? ma3 : na, color = ma3_color, title="MA №3") mp4 = plot(show_ma4 ? ma4 : na, color = ma4_color, title="MA №4") mp5 = plot(show_ma5 ? ma5 : na, color = ma3_color, title="MA №5") mp6 = plot(show_ma6 ? ma6 : na, color = ma4_color, title="MA №6") fill(mp1, mp2, color=ggc(bc, 0)) fill(mp2, mp3, color=ggc(bc, 1)) fill(mp3, mp4, color=ggc(bc, 2)) fill(mp4, mp5, color=ggc(bc, 3)) fill(mp5, mp6, color=ggc(bc, 4)) //------------------------------Adding MA Cross and RSI Cross c2 = ta.ema(osc, lag) cO = ta.crossover(osc, c2) cU = ta.crossunder(osc, c2) // This to me seems like a very inefficient way that goes through a lot of un-needed comparisons. // @Tradingview, please forgive me for unnecessarily excercising your servers for the sake of readability and clean-ish code :C // I'm sure there's a more effective way to do this, purhaps via converting binary to a 6 bit int and moving from there, or perhaps in terms of just going through the array, // but I'm unfortunately not too familiar with how to do that in pine. I'd love to know for future reference, so I hope if somebody reading this knows how, they drop a comment. //At first I started just simply creating comparisons of all the possible scenarios, //and then one-by-one examine and confirm the behavior with predicted value, but then realized it quickly became a mess. //I a truth table in excel, got rid of all the contradictions (cO AND cU, cU AND cU[1], etc) and was left with what you see. //if the descriptive claims don't resonate with you, feel free to drop a comment. I'd really like to hear what people think about this. //Personally, I think the most relatively significant ones are where there was a cross in the previous candle, AND we are either: // A) crossing into high/low territorry immidiately after a cross // B) there were two crosses in different directions. //That brings us into mainly utilizing: 1, 3, 5, 7, 11, 13. //Even more significant, would be when the prior conditions are BOTH true, AND there was a cross on the previous candle. I'll call these "Double Cross" from now on. dTruth(a,b,c,d,e,f) => //cU, cO, oL, oH, cu[1], cO[1] // (( (a==1) == cU ) and ( (b==1) == cO ) and ( (c==1) == oL ) and ( (d==1) == oH ) and ( (e==1) == cU[1]) and ( (f==1) == cO[1]) ) //just organizing my thoughts... /// cU, cO, oL, oH, cU[1], cO[1] [cU/cO][oH/oL][dc] upDownLow = dTruth(1, 0, 1, 0, 0, 1) // *** //Oscillator Low. Crossed Over, Crossing Under. Possible Continuation cuol = dTruth(1, 0, 1, 0, 0, 0) // **| //Oscillator Low. Crossing Under Looks bottomy, but more research is needed. upDownHigh = dTruth(1, 0, 0, 1, 0, 1) // *** //Oscillator High. Crossed Over, Crossing Under. cuoh = dTruth(1, 0, 0, 1, 0, 0) // **| //Oscillator High. Crossed Under upDown = dTruth(1, 0, 0, 0, 0, 1) // *|* //-------------- Crossed Over, Crossing Under, down = dTruth(1, 0, 0, 0, 0, 0) // *|| //-------------- Crossing Under downUpLow = dTruth(0, 1, 1, 0, 1, 0) // *** //Oscillator Low. Crossed Under, Crossing Over cool = dTruth(0, 1, 1, 0, 0, 0) // **| //Oscillator Low. Crossing Over. downUpHigh = dTruth(0, 1, 0, 1, 1, 0) // *** //Oscillator High. Crossed Under, Crossing Over cooh = dTruth(0, 1, 0, 1, 0, 0) // **| //Oscillator High. Crossing Over downUp = dTruth(0, 1, 0, 0, 1, 0) // *|* //-------------- Crossed under, Crossing Over Low Bounce up = dTruth(0, 1, 0, 0, 0, 0) // *|| //-------------- Crossing Over. //v13 = dTruth(0, 0, 1, 0, 1, 0) // |*| //Oscillator Low. Crossed under //v14 = dTruth(0, 0, 1, 0, 0, 1) // |*| //Oscillator Low. Crossed Over oscLow = dTruth(0, 0, 1, 0, 0, 0) // |*| //Oscillator Low, ---------------------------------------------------------------------- //v16 = dTruth(0, 0, 0, 1, 1, 0) // |*| //Oscillator High. Crossed under. Possible Reversal //v17 = dTruth(0, 0, 0, 1, 0, 1) // |*| //Oscillator High. Crossed over. Possible Continuation oscHigh = dTruth(0, 0, 0, 1, 0, 0) // |*| //Oscillator High. //v19 = dTruth(0, 0, 0, 0, 1, 0) // ||| //Previous candlestick crossed up, and continued in the current direction. Did not reach high. //v20 = dTruth(0, 0, 0, 0, 0, 1) // ||| //Previous candlestick crossed down, and continued in the current direction. Did not reach low. //Even more notes/comments: //I've ommited a few, such as v19/v20 due to their prevelance, and because we've reached pines 64 plots. oops. //13,14,16,17,19,20 are ommmitted because they are reduntant with 2,8,4,10,5,6 [1] respectively. //technically upDown and DownUp can also be omitted for now //I really want to maintain such that the user can change and save default options for the indicator. If we have size/shape/location dynamic, the user loses this option. //Therefore, we must spell out every single scenario. //I will omit scenarios that happen often, and only include significant ones, such as the [double cross AND high/low] symbolSize = size.tiny //Oscillator High/Low Only plotshape(oscLow, title='Oscillator Low', style=shape.arrowup, color=cc, location=location.bottom, size=symbolSize) plotshape(oscHigh, title='Oscillator High', style=shape.arrowdown, color=cc, location=location.top, size=symbolSize) plotshape(upDownHigh, title='Up-Down High Bounce', style=shape.triangleup, color=cc, location=location.top, size=symbolSize) plotshape(upDownLow, title='Up-Down Low Bounce', style=shape.triangleup, color=cc, location=location.bottom, size=symbolSize) plotshape(downUpHigh, title='Down-Up High Bounce', style=shape.triangledown, color=cc, location=location.top, size=symbolSize) plotshape(downUpLow, title='Down-Up Low Bounce', style=shape.triangledown, color=cc, location=location.bottom, size=symbolSize) plotshape(cuoh, title='Crossing Under, High', style=shape.xcross, color=cc, location=location.top, size=symbolSize) plotshape(cuol, title='Crossing Under, Low', style=shape.diamond, color=cc, location=location.bottom, size=symbolSize) plotshape(cooh, title='Crossing Over, High', style=shape.diamond, color=cc, location=location.top, size=symbolSize) plotshape(cool, title='Crossing Over, Low', style=shape.xcross, color=cc, location=location.bottom, size=symbolSize) plotshape(up and not showOsc, title='Crossing Up', style=shape.triangleup, color=cc, location=location.bottom, size=symbolSize, display=display.none) plotshape(down and not showOsc, title='Crossing Down,', style=shape.triangledown, color=cc, location=location.top, size=symbolSize, display=display.none) alertcondition(oH and not oH[1], 'Oscillator High,', 'Oscillator High!') alertcondition(oL and not oL[1], 'Oscillator Low,', 'Oscillator Low!')
Price Action: Inside Bar Boxes
https://www.tradingview.com/script/db9fuGm0-Price-Action-Inside-Bar-Boxes/
LennyT
https://www.tradingview.com/u/LennyT/
1,097
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © LennyT //@version=4 study('Inside Bar Boxes', shorttitle="IB Boxes",overlay=true) //inputs // buffer zone around high-low highLowBuffer = input(0, "High-Low buffer zone") // bars highlight barHighlight = input(true, "Highlight bars in boxes") // Show all or only last box showOnlyLastBox = input(false, "Show only last Box") // show breaks showBreak = input(true, "Show boxes break") // Box background color and transparency bgTransparency = input(90, "Box transparency") bgColor = input(color.blue, "Background color", type=input.color) // color for insibe bars if barHighlight is true insideBarsColor = input(color.orange, "Inside bars body color", type=input.color) // variables var box myBox = na var float boxHigh = na var float boxLow = na varip int barIndex = 1 varip bool f = false // check IB isInsideBar(previousBar) => hp = high[previousBar]+highLowBuffer*syminfo.mintick lp = low[previousBar]+highLowBuffer*syminfo.mintick bodyStatus = (close >= open) ? 1 : -1 isIB = (close <= hp and close >= lp) and (open <= hp and open >= lp) isIB isIB = isInsideBar(barIndex) isBarHighlight = isIB and barHighlight barcolor(isBarHighlight ? insideBarsColor : na) if isIB and not isIB[1] and barstate.isconfirmed boxHigh := high[1] boxLow := low[1] f := true if showOnlyLastBox box.delete(id=myBox[1]) myBox := box.new(bar_index-1, high[1], bar_index, low[1], bgcolor=color.new(bgColor, bgTransparency)) barIndex := barIndex+1 else if isIB and isIB[1] and barstate.isconfirmed box.set_right(myBox[1], bar_index) barIndex := barIndex+1 else if isIB[1] and not isIB and barstate.isconfirmed box.set_right(myBox[1], bar_index) barIndex := 1 else if not isIB[1] and not isIB f := false plotshape(showBreak and f and crossover(close, boxHigh), color=color.green, location=location.belowbar, style=shape.triangleup) plotshape(showBreak and f and crossunder(close, boxLow), color=color.red, location=location.abovebar, style=shape.triangledown)
WMA Combo Crossover V2
https://www.tradingview.com/script/k7qyKXSd-WMA-Combo-Crossover-V2/
sueun123
https://www.tradingview.com/u/sueun123/
66
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © sueun123 // @version=4 // This is an upgrade of my indicator WMA Combo Crossover. Link: https://www.tradingview.com/script/X8qcBntl-WMA-Combo-Crossover/ // The upgrade was inspired from the CCI and Bollinger Bands indicator by matsu_bitmex. Link: https://www.tradingview.com/script/IkciCgbh/ study(title = "WMA Combo Crossover V2", shorttitle = "WMA Crossover V2", overlay = false, format = format.inherit, scale = scale.right) // WMA WMA1 = input(2, minval = 1) Source1 = input(close, title = "Source 1") wma1 = wma(2*wma(Source1, WMA1/2)-wma(Source1, WMA1), floor(sqrt(WMA1))) WMA2 = input(defval = 25, minval = 1) Source2 = input(close, title = "Source 2") wma2 = wma(2*wma(Source2, WMA2/2)-wma(Source2, WMA2), floor(sqrt(WMA2))) fillColor1 = wma1 > wma2 ? color.new(color.blue, transp = 70) : color.new(color.red, transp = 70) fillColor2 = wma1 > wma2 ? color.new(color.blue, transp = 0) : color.new(color.red, transp = 0) p1 = plot(wma1, color = color.white, transp = 0, title = "Quick WMA", linewidth = 1, style = plot.style_line, editable = true, display = display.all) p2 = plot(wma2, color = fillColor2, transp = 0, title = "Main Oscillator", linewidth = 1, style = plot.style_line, editable = true, display = display.all) fill(p1, p2, fillColor1, title = "WMA Background Colors") // BB sourceone = input(open, title = "High") sourcetwo = input(close, title = "Low") multiply = input(defval = 1.5, minval = 0.5, title = "Deviation") basisone = wma(sourceone, WMA2) basistwo = wma(sourcetwo, WMA2) deviationone = multiply * stdev(sourceone, WMA2) deviationtwo = multiply * stdev(sourcetwo, WMA2) upperbb = basisone + deviationone lowerbb = basistwo - deviationtwo p3 = plot(upperbb, title = "Upper", color = color.yellow, transp = 75, linewidth = 1, editable = true) p4 = plot(lowerbb, title = "Lower", color = color.yellow, transp = 75, linewidth = 1, editable = true) fillColorone = wma1 > upperbb ? color.new(color.yellow, transp = 65) : color.new(color.red, transp = 100) fillColortwo = wma1 < lowerbb ? color.new(color.yellow, transp = 65) : color.new(color.yellow, transp = 100) fill(p3, p1, fillColorone, title = "Outside Upper BB") // Price is very volatile going up fill(p1, p4, fillColortwo, title = "Outside Lower BB") // Price is very volatile going down //---END---
Prime Number Checker
https://www.tradingview.com/script/ZpTojxe2-Prime-Number-Checker/
Eliza123123
https://www.tradingview.com/u/Eliza123123/
69
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Eliza123123 //@version=4 study("Prime Number Checker v3", overlay = true) //v2 //more workable version of yesterdays script. please still only use on assets $10 to $100 as scalability hasn't been added for all assets yet. BG colors are theres to show historic prevalence of "primeness". //The table in the top right will flash purple when the open high low or close encounters "primeness". //When they all light up thats when you can potentially expect a reversal. Use on lower time frame to see the effect quickly. Note this still isn't a foolproof method for finding primes but I will be improving it in later editions //v3 //added scaling for pairs from $0.10 up to $1000. May still be slight different in indicator performance betwwen the two extremes of that scale. // Clear OHLC prime pivot points have been added. //Introducing the volumeometer. Pretty self explanatory. // Red candle count and green candle count for last 100 candles. f_close = close, f_low = low, f_high = high, f_open = open flagc = 0, flagl = 0, flagh = 0, flago = 0 //Assets $0.10-1 if close >= 0.100 and close < 0.9999 f_close := f_close * 100000 if low >= 0.100 and low < 0.9999 f_low := f_low * 100000 if high >= 0.100 and high < 0.9999 f_high := f_high * 100000 if open >= 0.100 and open < 0.9999 f_open := f_open * 100000 //Assets $1-10 if close >= 1.000 and close < 9.999 f_close := f_close * 10000 if low >= 1.000 and low < 9.999 f_low := f_low * 10000 if high >= 1.000 and high < 9.999 f_high := f_high * 10000 if open >= 1.000 and open < 9.999 f_open := f_open * 10000 //Assets $10-100 if close >= 10.000 and close < 99.999 f_close := f_close * 1000 if low >= 10.000 and low < 99.999 f_low := f_low * 1000 if high >= 10.000 and high < 99.999 f_high := f_high * 1000 if open >= 10.000 and open < 99.999 f_open := f_open * 1000 //Assets $100-1000 if close >= 100.000 and close < 999.999 f_close := f_close * 100 if low >= 100.000 and low < 999.999 f_low := f_low * 100 if high >= 100.000 and high < 999.999 f_high := f_high * 100 if open >= 100.000 and open < 999.999 f_open := f_open * 100 if f_close > 1 for i = 2 to 3 if (f_close % i) == 0 flagc := 1 for i = 4 to 5 if (f_close % i) == 0 flagc := 1 for i = 6 to 7 if (f_close % i) == 0 flagc := 1 for i = 8 to 9 if (f_close % i) == 0 flagc := 1 if f_low > 1 for i = 2 to 3 if (f_low % i) == 0 flagl := 1 for i = 4 to 5 if (f_low % i) == 0 flagl := 1 for i = 6 to 7 if (f_low % i) == 0 flagl := 1 for i = 8 to 9 if (f_low % i) == 0 flagl := 1 if f_high > 1 for i = 2 to 3 if (f_high % i) == 0 flagh := 1 for i = 4 to 5 if (f_high % i) == 0 flagh := 1 for i = 6 to 7 if (f_high % i) == 0 flagh := 1 for i = 8 to 9 if (f_high % i) == 0 flagh := 1 if f_open > 1 for i = 2 to 3 if (f_open % i) == 0 flago := 1 for i = 4 to 5 if (f_open % i) == 0 flago := 1 for i = 6 to 7 if (f_open % i) == 0 flago := 1 for i = 8 to 9 if (f_open % i) == 0 flago := 1 bgcolor(color = flagc == 0 ? color.yellow : na, transp = 99) bgcolor(color = flagl == 0 ? color.yellow : na, transp = 99) bgcolor(color = flagh == 0 ? color.yellow : na, transp = 99) bgcolor(color = flago == 0 ? color.yellow : na, transp = 99) bgcolor(color = flago == 0 and flagh == 0 ? color.purple : na, transp = 98) bgcolor(color = flago == 0 and flagl == 0 ? color.purple : na, transp = 98) bgcolor(color = flago == 0 and flagc == 0 ? color.purple : na, transp = 98) bgcolor(color = flagl == 0 and flagc == 0 ? color.purple : na, transp = 98) bgcolor(color = flagl == 0 and flagh == 0 ? color.purple : na, transp = 98) bgcolor(color = flagc == 0 and flagh == 0 ? color.purple : na, transp = 98) bgcolor(color = flagc == 0 and flagh == 0 and flago == 0 ? color.fuchsia : na, transp = 97) bgcolor(color = flagc == 0 and flagh == 0 and flagl == 0 ? color.fuchsia : na, transp = 97) bgcolor(color = flago == 0 and flagc == 0 and flagl == 0 ? color.fuchsia : na, transp = 97) bgcolor(color = flago == 0 and flagh == 0 and flagl == 0 ? color.fuchsia : na, transp = 97) volumesBeaten = 0 for i = 1 to 1440 if volume > volume[i] volumesBeaten := volumesBeaten + 1 volume_percent_class = (volumesBeaten / 1440) * 100 howManyreds = 0 for i = 1 to 100 if open[i] > close[i] howManyreds := howManyreds + 1 howManygreens = 0 for i = 1 to 100 if open[i] < close[i] howManygreens := howManygreens + 1 var testTable = table.new(position = position.top_right, columns = 2, rows = 4, bgcolor = color.white, border_width = 1) if barstate.islast table.cell(table_id = testTable, column = 0, row = 0, text = "Open is " + tostring(open), bgcolor = flago == 0 ? color.fuchsia : na) table.cell(table_id = testTable, column = 1, row = 0, text = "Close is " + tostring(close), bgcolor = flagc == 0 ? color.fuchsia : na) table.cell(table_id = testTable, column = 0, row = 1, text = "High is " + tostring(high), bgcolor = flagh == 0 ? color.fuchsia : na) table.cell(table_id = testTable, column = 1, row = 1, text = "Low is " + tostring(low), bgcolor = flagl == 0 ? color.fuchsia : na) table.cell(table_id = testTable, column = 0, row = 2, text = " Volume higher than " + tostring(volume_percent_class) + "% of recent data", bgcolor = color.black, text_color = color.white) table.cell(table_id = testTable, column = 1, row = 2, text = "Reds " + tostring(howManyreds), bgcolor = color.red, text_color = color.white) table.cell(table_id = testTable, column = 0, row = 3, text = "Hope this helps! Eliza x", bgcolor = #fc03a5, text_color = #d5ff03) table.cell(table_id = testTable, column = 1, row = 3, text = "Greens " + tostring(howManygreens), bgcolor = color.green, text_color = color.white) plotshape(flagc == 0 and flagh == 0 and flago == 0 and flagl == 0, location = location.belowbar, color = color.purple, text = "Piv", textcolor = color.white)
Volume Power Flow - Taylor V1
https://www.tradingview.com/script/gpJYUQC6-Volume-Power-Flow-Taylor-V1/
TaylorTneh
https://www.tradingview.com/u/TaylorTneh/
153
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © TaylorTneh //@version=4 study(title="Volume Power Flow", shorttitle="Flow Vol", format=format.volume, resolution="") //------------------------------------------------------------------------------------------------------- Volume Power Flow vflow = input(title="Volume Power Flow", defval=true) maType = input(title="VPF Average Type", options=["RMA", "Single EMA", "Double EMA"], defval="RMA") length = input(13, title="VPF Average Length : 8/13") x = 3.1 vpfred = color.red vpfgreen = color.green // Basic Volume Calcs // vol = volume bull = close>open?vol:0 bear = open>close?vol:0 // Double EMA Function // dema(src, len) => (2 * ema(src, len) - ema(ema(src, len), len)) // BEAR Moving Average Calculation bullma = maType == "Single EMA" ? ema(bull, length) : maType == "Double EMA" ? dema(bull, length) : rma(bull, length) // BEAR Moving Average Calculation // bearma = maType == "Single EMA" ? ema(bear, length) : maType == "Double EMA" ? dema(bear, length) : rma(bear, length) // ma dif // vf_dif = bullma-bearma vf_absolute = vf_dif > 0 ? vf_dif : vf_dif * (-1) // Volume Spikes // gsig=crossover(bull, bullma*x)?vol:na rsig=crossover(bear, bearma*x)?vol:na // Color Calcs // vdClr = vf_dif > 0 ? vpfgreen : vpfred vClr=close>open? vpfgreen:vpfred // Plots // vflowplot = vflow ? vf_absolute/2.5 : na plot(vflowplot, style=plot.style_area, color=vdClr, title="Volume Power Flow")
Relative Volume (rVol), Better Volume, Average Volume Comparison
https://www.tradingview.com/script/vKmS0WJP-Relative-Volume-rVol-Better-Volume-Average-Volume-Comparison/
kurtsmock
https://www.tradingview.com/u/kurtsmock/
1,076
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © kurtsmock //@version=5 // v3.0 6/15/22 - rVol indicator('rVol', precision=2) import kurtsmock/ArrayMatrixHUD/2 as sa import kurtsmock/PD/1 as pd //////////////////////////////////////// // Inputs ////////////////////////////// //////////////////////////////////////// { rv_g1 = 'Indicator Switches' rv_g2 = 'rVol Settings' rv_g3 = 'Better-er Volume Settings' rv_g4 = 'Volume Average Comparison/Bar Colors' rv_g5 = 'Validation Table Setting' tv = 'Total Volume', rv = 'rVol' vpt = 'Volume Per Tick', zvol = 'Z-Score of Ln(Volume)', nan = 'None' tt1 = 'Check the box if the symbol\'s exchange adjusts timestamp for Daylight Savings Time.\n\nNOTE: Cryptocurrencies do not adjust for DST.\n\n The script has some logic to test if it is working properly, but you\'ll want to make sure you keep this in mind. It won\'t catch everything.' s_bvol = input.bool(false, group=rv_g1, inline='a', title='Better Volume | ') s_rate = input.bool(false, group=rv_g1, inline='a', title='Volume Rating | ') s_weit = input.bool(false, group=rv_g1, inline='a', title='Weighted Volume') s_col = input.bool(false, group=rv_g1, inline='b', title='Colored Bars |') s_val = input.bool(false, group=rv_g1, inline='b', title='Validation Table | ') s_tab = input.bool(false, group=rv_g1, inline='b', title='Legend Table') s_dlst = input.bool(true , group=rv_g1, title='Daylight Savings Time Switch', tooltip=tt1) c_mode = input.string( rv, group=rv_g1, title='Volume Mode', options = [rv, tv]) c_calc = input.string(nan, group=rv_g1, title='Additional Calculation', options = [vpt, zvol, nan]) i_cycles = input.int( 10, group=rv_g2, title='rVol Cycles', minval=1) + 1 i_bvLength = input.int( 20, group=rv_g3, title='Better-er Lookback') i_maLen = input.int( 20, group=rv_g4, title='Volume Moving Average Length') i_uv = input.float( 2.2, group=rv_g4, title='Ultra High Volume Ratio') i_vhv = input.float( 1.8, group=rv_g4, title='Very High Volume Ratio') i_hv = input.float( 1.2, group=rv_g4, title='High Volume Ratio') i_nv = input.float( 0.8, group=rv_g4, title='Normal Volume Ratio') i_lv = input.float( 0.4, group=rv_g4, title='Low Volume Ratio') // } //////////////////////////////////////// // rVol //////////////////////////////// //////////////////////////////////////// { // -- Absolute time reference at beginning of chart { t = time("D") var START_BAR = 0 if t != t[1] and START_BAR == 0 START_BAR := bar_index var START_TIME = 0 var START_HOUR = 0 var START_MIN = 0 var START_SEC = 0 if bar_index == START_BAR and START_BAR > 0 START_TIME := time_close START_HOUR := hour START_MIN := minute START_SEC := second // plot(START_BAR) // plot(START_TIME) // plot(START_HOUR) // plot(START_MIN) // plot(START_SEC) //} // -- Find Beginning Bar of Interval (Daily Open) { newInterval = false var newTime = int(na) var rollingDays = 0 var rollingBars = 0 var totalDays = 0 rollingBars += 1 if rollingBars >= i_cycles rollingBars := 0 DST = (time_close - nz(newTime) + (month >= 3 and month < 11 ? 3600000 : -3600000)) % 86400000 notDST = (time_close - math.max(nz(newTime), START_TIME)) % 86400000 newInt = s_dlst and month >= 3 and month <= 11 ? (DST == 0 and notDST > DST and DST[1] > 0) or (notDST == 0 and DST > notDST) : notDST == 0 if newInt or t != t[1] newInterval := true newTime := time_close rollingDays += 1 totalDays += 1 if rollingDays >= i_cycles rollingDays := 0 curBarofDay = timeframe.isseconds ? 0 : ta.barssince(newInterval) barsInSession = timeframe.isintraday ? ((24 * 60) / timeframe.multiplier) : timeframe.multiplier barsInSession := math.floor(barsInSession) == barsInSession and timeframe.isintraday ? barsInSession - 1 : math.floor(barsInSession) // plot(DST, color=color.purple) // plot(notDST) // plot(newInt ? 1 : 0, color=color.fuchsia) // plotchar(newInterval, char="*", location = location.bottom, size = size.large) // plot(rollingDays, color=color.orange) // plot(rollingBars, color=color.orange) // plot(curBarofDay, color=color.green) // plot(barsInSession, color=color.red) // plot(totalDays) //} var values = matrix.new<float>(i_cycles, barsInSession + 1, 0) if barstate.isconfirmed and totalDays > 2 and not(timeframe.isseconds) matrix.set(values, rollingDays, math.min(curBarofDay, barsInSession), volume) else if barstate.isconfirmed and totalDays > 2 and timeframe.isseconds matrix.set(values, rollingBars, 0, volume) histVolume = array.new_float() avgHistVol = 0.0 if not(na(matrix.col(values, math.min(curBarofDay,barsInSession)))) histVolume := matrix.col(values, math.min(curBarofDay,barsInSession)) if not(na(array.avg(histVolume))) and barstate.isrealtime avgHistVol := array.avg(histVolume) else if not(na(array.avg(histVolume))) and barstate.ishistory array.remove(histVolume, rollingDays) avgHistVol := array.avg(histVolume) rVol = volume / avgHistVol _vol = c_mode == rv ? rVol : volume //} //////////////////////////////////////// // VPT & Z-Vol ///////////////////////// //////////////////////////////////////// { dist = pd.tick("rg") logVol = math.log(_vol) avgVol = ta.sma(logVol, 1000) stdevVol = ta.stdev(logVol, 1000) zvolTime = timenow > time + ((time_close - time) * 0.30) // Time delay for z-score of log(vol) to appear. Visually appealing and volume info before this point is not useful. _vpt = _vol / dist _zVol = (logVol - avgVol) / stdevVol _vol := c_calc == vpt ? _vpt : c_calc == zvol ? (zvolTime ? _zVol : 0) : _vol //} //////////////////////////////////////// // Volume Comparison With rVol ///////// //////////////////////////////////////// { vma = ta.sma(_vol, i_maLen) uhvMin = vma * i_uv, vhvMin = vma * i_vhv, hvMin = vma * i_hv, nvMin = vma * i_nv, lvMin = vma * i_lv volUHV = c_mode == tv or c_calc == vpt ? _vol >= uhvMin ? true : false : _vol >= i_uv ? true : false volVHV = c_mode == tv or c_calc == vpt ? _vol >= vhvMin and _vol < uhvMin ? true : false : _vol >= i_vhv and _vol < i_uv ? true : false volHV = c_mode == tv or c_calc == vpt ? _vol >= hvMin and _vol < vhvMin ? true : false : _vol >= i_hv and _vol < i_vhv ? true : false volNV = c_mode == tv or c_calc == vpt ? _vol >= nvMin and _vol < hvMin ? true : false : _vol >= i_nv and _vol < i_hv ? true : false volLV = c_mode == tv or c_calc == vpt ? _vol >= lvMin and _vol < nvMin ? true : false : _vol >= i_lv and _vol < i_nv ? true : false volVLV = c_mode == tv or c_calc == vpt ? _vol < lvMin ? true : false : _vol < i_lv ? true : false _col = volUHV ? color.new(color.purple, 30) : volVHV ? color.new(color.red, 30) : volHV ? color.new(color.orange, 30) : volNV ? color.new(color.green, 30) : volLV ? color.new(color.blue, 30) : color.new(color.silver, 30) defcol = color.new(color.gray, 50) //} // -- Volume Plot -- // { // Placed here to keep volume plot behind Better-er Volume Signals o_col = c_calc == zvol ? close>open ? color.new(color.green, 30) : color.new(color.red, 30) : _col plot(_vol, style=plot.style_columns, color=s_col ? o_col : defcol) hline(c_calc == vpt or c_calc == zvol ? 0 : 1, linestyle=hline.style_dashed) //} //////////////////////////////////////// // Better-er Volume //////////////////// //////////////////////////////////////// { rng = high - low v = _vol vBuy = (close - low) / (high - low) * v vSell = (high - close) / (high - low) * v vChurn = v / rng vLow = ta.lowest(v, i_bvLength) tClimaxUp = vBuy == ta.highest(vBuy, i_bvLength) ? 1 : 0 tClimaxDn = vSell == ta.highest(vSell, i_bvLength) ? 1 : 0 tChurn = vChurn == ta.highest(vChurn, i_bvLength) ? 1 : 0 tLow = v == vLow ? 1 : 0 // -- Test Conditions climax_up = tClimaxUp climax_down = tClimaxDn churn_bar = tChurn def_bar = not climax_up or climax_down or churn_bar climax_churn= tChurn and (tClimaxUp or tClimaxDn) low_vol = tLow ccc = climax_churn ? 1 : low_vol ? 2 : climax_up ? 3 : climax_down ? 4 : churn_bar ? 5 : def_bar ? 6 : 0 // -- Characters clear = color.new(color.white, 100) purple = color.new(#730064, 0) blue = color.new(#00c1e3, 0) green = color.new(#39bd44, 0) red = color.new(#ff391f, 0) orng = color.new(#ffa200, 0) plotchar(s_bvol and ccc == 1 and vBuy > vSell ? climax_churn : na, 'Climax Up + Churn', char='▲', location=location.top, size=size.tiny, color=purple) plotchar(s_bvol and ccc == 1 and vSell > vBuy ? climax_churn : na, 'Climax Down + Churn', char='▼', location=location.top, size=size.tiny, color=purple) plotchar(s_bvol and ccc == 3 and vBuy > vSell ? climax_up : na, 'Climax Up', char='▲', location=location.top, size=size.tiny, color=green) plotchar(s_bvol and ccc == 4 and vSell > vBuy ? climax_down : na, 'Climax Down', char='▼', location=location.top, size=size.tiny, color=red) plotchar(s_bvol and ccc == 5 ? churn_bar : na, 'Churn', char='■', location=location.top, size=size.tiny, color=orng) plotchar(s_bvol and ccc == 2 ? low_vol : na, 'Low Volume', char='■', location=location.top, size=size.tiny, color=blue) plotchar(s_bvol and ccc == 6 ? def_bar : na, 'Default Bar', char='■', location=location.bottom, size=size.tiny, color=clear) // } // -- Weighted Volume Plot -- // { plot(s_weit ? vBuy : na, "vBuy", style = plot.style_area, color = color.new(color.green,70)) plot(s_weit ? vSell : na, "vSell", style = plot.style_area, color = color.new(color.red,70)) //} //////////////////////////////////////// // Volume Rating /////////////////////// //////////////////////////////////////// { // Bullish Volume Rating ///////////////////////// { // -- Create Required Arrays var vcu = array.new_float(5, float(na)) // -- Create Pivot High and Test p_climaxUp = ta.pivothigh(vBuy, 2, 2) testBull = ta.valuewhen(p_climaxUp, p_climaxUp, 0) != ta.valuewhen(p_climaxUp[1], p_climaxUp[1], 0) // -- Add/Remove to/from Array if testBull and not(vBuy[2] == array.get(vcu, 0)) and vBuy[2] > vSell[2] array.unshift(vcu, vBuy[2]) if array.size(vcu) > 5 array.pop(vcu) if (ccc == 1 or ccc == 3) and vBuy > vSell array.fill(vcu, -1.0, 1, 5) array.set(vcu, 0, vBuy) // -- Sort Array vcuSort = array.copy(vcu) array.sort(vcuSort, order.descending) if array.size(vcuSort) > 5 array.pop(vcuSort) // -- Rate Bullish Volume Pivot Height vcuRating = float(na) if vBuy[2] == array.get(vcuSort, 0) vcuRating := 1 else if vBuy[2] == array.get(vcuSort, 1) vcuRating := 2 else if vBuy[2] == array.get(vcuSort, 2) vcuRating := 3 else if vBuy[2] == array.get(vcuSort, 3) vcuRating := 4 else if vBuy[2] == array.get(vcuSort, 4) vcuRating := 5 else vcuRating := float(na) // -- Bullish Volume Ratings plotchar(s_rate and vcuRating == 1 ? testBull : na, 'piv_u1', char='', text='1', location = location.top, color = color.green, offset=-2, size=size.tiny) plotchar(s_rate and vcuRating == 2 ? testBull : na, 'piv_u2', char='', text='2', location = location.top, color = color.green, offset=-2, size=size.tiny) plotchar(s_rate and vcuRating == 3 ? testBull : na, 'piv_u3', char='', text='3', location = location.top, color = color.green, offset=-2, size=size.tiny) plotchar(s_rate and vcuRating == 4 ? testBull : na, 'piv_u4', char='', text='4', location = location.top, color = color.green, offset=-2, size=size.tiny) plotchar(s_rate and vcuRating == 5 ? testBull : na, 'piv_u5', char='', text='5', location = location.top, color = color.green, offset=-2, size=size.tiny) //} // Bearish Volume Rating ///////////////////////// { // -- Create Required Arrays var vcd = array.new_float(5, float(na)) // -- Create Pivot High and Test p_climaxDn = ta.pivothigh(vSell, 2, 2) testBear = ta.valuewhen(p_climaxDn, p_climaxDn, 0) != ta.valuewhen(p_climaxDn[1], p_climaxDn[1], 0) // -- Add/Remove to/from Array if testBear and not(vSell[2] == array.get(vcd, 0)) and vSell[2] > vBuy[2] array.unshift(vcd, vSell[2]) if array.size(vcd) > 5 array.pop(vcd) if (ccc == 1 or ccc == 4) and vSell > vBuy array.fill(vcd, -1.0, 1, 5) array.set(vcd, 0, vSell) // -- Sort Array vcdSort = array.copy(vcd) array.sort(vcdSort, order.descending) if array.size(vcdSort) > 5 array.pop(vcdSort) // -- Rate Bearish Volume Pivot Height vcdRating = float(na) if vSell[2] == array.get(vcdSort, 0) vcdRating := 1 else if vSell[2] == array.get(vcdSort, 1) vcdRating := 2 else if vSell[2] == array.get(vcdSort, 2) vcdRating := 3 else if vSell[2] == array.get(vcdSort, 3) vcdRating := 4 else if vSell[2] == array.get(vcdSort, 4) vcdRating := 5 else vcdRating := float(na) // -- Bear Volume Ratings plotchar(s_rate and vcdRating == 1 ? testBear : na, 'piv_d1', char='', text='1', location = location.top, color = color.red, offset=-2, size=size.tiny) plotchar(s_rate and vcdRating == 2 ? testBear : na, 'piv_d2', char='', text='2', location = location.top, color = color.red, offset=-2, size=size.tiny) plotchar(s_rate and vcdRating == 3 ? testBear : na, 'piv_d3', char='', text='3', location = location.top, color = color.red, offset=-2, size=size.tiny) plotchar(s_rate and vcdRating == 4 ? testBear : na, 'piv_d4', char='', text='4', location = location.top, color = color.red, offset=-2, size=size.tiny) plotchar(s_rate and vcdRating == 5 ? testBear : na, 'piv_d5', char='', text='5', location = location.top, color = color.red, offset=-2, size=size.tiny) //} // Churn Rating ///////////////////////// { // -- Create Required Arrays var vcc = array.new_float(5, float(na)) // -- Create Pivot High and Test p_churn = ta.pivothigh(vChurn, 2, 2) testChurn = ta.valuewhen(p_churn, p_churn, 0) != ta.valuewhen(p_churn[1], p_churn[1], 0) // -- Add/Remove to/from Array if testChurn and not(ccc == 1) and not(vChurn[2] == array.get(vcc, 0)) array.unshift(vcc, vChurn[2]) if array.size(vcc) > 5 array.pop(vcc) if ccc == 5 array.fill(vcc, -1.0, 1, 5) array.set(vcc, 0, vChurn) // -- Sort Array vccSort = array.copy(vcc) array.sort(vccSort, order.descending) if array.size(vccSort) > 5 array.pop(vccSort) // -- Rate Bearish Volume Pivot Height vccRating = float(na) if vChurn[2] == array.get(vccSort, 0) vccRating := 1 else if vChurn[2] == array.get(vccSort, 1) vccRating := 2 else if vChurn[2] == array.get(vccSort, 2) vccRating := 3 else if vChurn[2] == array.get(vccSort, 3) vccRating := 4 else if vChurn[2] == array.get(vccSort, 4) vccRating := 5 else vccRating := float(na) // -- Churn Volume Ratings plotchar(s_rate and vccRating == 1 ? testChurn : na, 'piv_c1', char='', text='1', location = location.bottom, color = color.black, offset=-2, size=size.tiny) plotchar(s_rate and vccRating == 2 ? testChurn : na, 'piv_c2', char='', text='2', location = location.bottom, color = color.black, offset=-2, size=size.tiny) plotchar(s_rate and vccRating == 3 ? testChurn : na, 'piv_c3', char='', text='3', location = location.bottom, color = color.black, offset=-2, size=size.tiny) plotchar(s_rate and vccRating == 4 ? testChurn : na, 'piv_c4', char='', text='4', location = location.bottom, color = color.black, offset=-2, size=size.tiny) plotchar(s_rate and vccRating == 5 ? testChurn : na, 'piv_c5', char='', text='5', location = location.bottom, color = color.black, offset=-2, size=size.tiny) //} //} //////////////////////////////////////// // Table Color Legend ////////////////// //////////////////////////////////////// { ip_col = color.new(color.blue, 90) var table ip = table.new(position.middle_right, columns=3, rows=8, bgcolor=ip_col, frame_color=color.black, frame_width=1, border_color=color.black, border_width=1) if s_tab table.cell(ip, 1, 1, 'Better-er Volume', text_color=#000000, text_halign=text.align_center, text_size=size.small) table.cell(ip, 1, 2, '▲ Climax Up+Chrn', text_color=#9e0089, text_halign=text.align_right, text_size=size.small) table.cell(ip, 1, 3, '▼ Climax Down+Chrn', text_color=#9e0089, text_halign=text.align_right, text_size=size.small) table.cell(ip, 1, 4, '▲ Climax Up', text_color=#39bd44, text_halign=text.align_right, text_size=size.small) table.cell(ip, 1, 5, '▼ Climax Down', text_color=#ff391f, text_halign=text.align_right, text_size=size.small) table.cell(ip, 1, 6, '■ Low Volume', text_color=#00c1e3, text_halign=text.align_right, text_size=size.small) table.cell(ip, 1, 7, '■ Churn', text_color=#ffa200, text_halign=text.align_right, text_size=size.small) table.cell(ip, 2, 1, 'Volume Threshold', text_color=#000000, text_halign=text.align_center, text_size=size.small) table.cell(ip, 2, 2, 'Ultra High Volume', text_color=color.purple, text_halign=text.align_right, text_size=size.small) table.cell(ip, 2, 3, 'Very High Volume', text_color=color.red, text_halign=text.align_right, text_size=size.small) table.cell(ip, 2, 4, 'High Volume', text_color=color.orange, text_halign=text.align_right, text_size=size.small) table.cell(ip, 2, 5, 'Normal Volume', text_color=color.green, text_halign=text.align_right, text_size=size.small) table.cell(ip, 2, 6, 'Low Volume', text_color=color.blue, text_halign=text.align_right, text_size=size.small) table.cell(ip, 2, 7, 'Very Low Volume', text_color=color.silver, text_halign=text.align_right, text_size=size.small) //} //////////////////////////////////////// // Validate Volume Values ////////////// //////////////////////////////////////// { i_valOff = input.int(0, group=rv_g5, title='Validation Table Offset', minval=0) offset = i_valOff if s_val sa.viewArray(histVolume, position.top_right, size.small, 10, totalDays > 2, offset) tz = table.new(position.top_center,1,1) table.cell(tz, 0,0,syminfo.timezone) //}
DMA Thrust Count Notification
https://www.tradingview.com/script/aEs0KYZ5-DMA-Thrust-Count-Notification/
Methuz
https://www.tradingview.com/u/Methuz/
28
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © pleasedHare87433 //@version=4 study("Thrust Count Notification", precision=0) var thrustCount = 0 a = input(true, title="Enable 1st MA") len = input(3, minval=1, title="Length") src = input(close, title="Source") off = input(3, title="offset") out = sma(src, len) outoff = offset(out, 3) if low > outoff or high < outoff thrustCount := thrustCount + 1 if cross(low, outoff) or cross(high, outoff) thrustCount := 0 _color = close > outoff ? color.green : color.red threshould = input(title="Thrust Threshold", type=input.integer, defval=8, minval=1, step = 1) shouldAlert = thrustCount > 8 alertcondition(shouldAlert, title="High Thrust", message="Thrust > 8 for {{ticker}}") plot(thrustCount, title="Thrust Count", style=plot.style_histogram, color=_color, linewidth=3)
ReNKoLiNe - A line on chart mimicking RENKO bricks
https://www.tradingview.com/script/Y4gEooX7-ReNKoLiNe-A-line-on-chart-mimicking-RENKO-bricks/
KristianStefanov
https://www.tradingview.com/u/KristianStefanov/
25
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © KristianStefanov //@version=4 // DESCRIPTION // RENKOLINE Idicator - mimics RENKO charts on ANY timeframe. It is not absolutely fixed, which is actually advantage, //because it does not close bricks before the actual close of a candle. // An advantage, if one knows how to play with the "bricksize" //Of course it has a short side of delaying entry in case the direction momentum continiues. //CDL is difference between current close and the RenkoLine Candle(close) to Line(renko). This could provide idea for the deviation between candle close and line value. //It is only a value. I did not find a way to draw it properly. Someone more experienced could help :) //DEFINITIONS AND EXPRESSIONS - INPUTs study("ReNKoLiNe", shorttitle="RNL", overlay=true) max_bar_back = 72000 PIPu=input(title="PIPs+", type=input.float, defval=0.0010) PIPd=input(title="PIPs-", type=input.float, defval=-0.0010) var RNL = close CDL_CloseToRenkoLine = (close - RNL) //CALCULAIONS & RULES if(close[0]-RNL[1]<= PIPd) RNL := close[0] if(close[0]-RNL[1]>= PIPu) RNL := close[0] else RNL[1] //DRAW ON CHART plot(RNL, linewidth=2,title="RNL", color=color.rgb(177,165,79)) plot(CDL_CloseToRenkoLine,title="CDL", linewidth=2,style=plot.style_histogram, color=color.rgb(7,165,150))
ZigZag Chart with Supertrend
https://www.tradingview.com/script/nEzUk66b-ZigZag-Chart-with-Supertrend/
LonesomeTheBlue
https://www.tradingview.com/u/LonesomeTheBlue/
1,483
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © LonesomeTheBlue //@version=4 study("ZigZag Chart with SuperTrend", max_bars_back = 500, max_lines_count = 500, explicit_plot_zorder = true) prd = input(defval = 4, title="ZigZag Period", minval = 2, maxval = 50, group = "Setup") showmast = input(defval = "Supertrend", title = "Show => ", options = ["Moving Average", "Supertrend"], group = "Setup", inline = "mova") malen = input(defval = 20, title=" MA Length", minval = 2, maxval = 200, group = "Setup", tooltip = "Used for Moving Average") atrlen = input(defval = 10, title=" ATR Length", minval = 2, maxval = 50, group = "Setup", tooltip = "Used for Supertrend") atrmult = input(defval = 2., title=" ATR Multiplier", minval = 0.1, maxval = 10., step = 0.1, group = "Setup", tooltip = "Used for Supertrend") bodycolup = input(defval = color.lime, title = "Body Color", inline = "bcol", group = "Colors") bodycoldown = input(defval = color.red, title = "", inline = "bcol", group = "Colors") bodycoltop = input(defval = #b5b5b8, title = "Wick Color", inline = "wcol", group = "Colors") bodycolbottom = input(defval = #b5b5b8, title = "", inline = "wcol", group = "Colors") chbarcolor = input(defval = true, title = "Change Bar Color by Supertrend", tooltip = "Supertrend should be activated using the option above", group = "Colors") // get/keep highest/lowest closing prices float ph = highestbars(close, prd) == 0 ? close : na float pl = lowestbars(close, prd) == 0 ? close : na var dir = 0 dir := iff(ph and na(pl), 1, iff(pl and na(ph), -1, dir)) var max_array_size = 320 var zigzag = array.new_float(0) add_to_zigzag(value, bindex)=> array.unshift(zigzag, bindex) array.unshift(zigzag, value) if array.size(zigzag) > max_array_size array.pop(zigzag) array.pop(zigzag) update_zigzag(value, bindex)=> if array.size(zigzag) == 0 add_to_zigzag(value, bindex) else if (dir == 1 and value > array.get(zigzag, 0)) or (dir == -1 and value < array.get(zigzag, 0)) array.set(zigzag, 0, value) array.set(zigzag, 1, bindex) 0. bool dirchanged = (dir != dir[1]) if ph or pl if dirchanged add_to_zigzag(dir == 1 ? ph : pl, bar_index) else update_zigzag(dir == 1 ? ph : pl, bar_index) // definition for candles, moving averages and supertrend var zzcandles = array.new_line(0) var zztopwicks = array.new_line(0) var zzbottomwicks = array.new_line(0) var maarray = array.new_line(0) var float zz_high = na var float zz_low = na var zigzagtrueRange = array.new_float(0) var zigzagatr = array.new_float(0) varip float st_up = na varip float st_dn = na varip float st_trendup = na varip float st_trenddn = na float st_trendup_1 = st_trendup float st_trenddn_1 = st_trenddn varip int st_trend = 1 var zzstdir = array.new_float(0) var zzsupertrend = array.new_float(0) rma_sum(length)=> array.size(zigzagtrueRange) >= length ? array.avg(array.slice(zigzagtrueRange, 0, length)) : na // calculate rma for truerange of zigzag candles zigzag_rma(length)=> float alpha = 1. / length float ret = array.size(zigzagatr) == 0 ? rma_sum(length) : na(array.get(zigzagatr, 0)) ? rma_sum(length) : alpha * array.get(zigzagtrueRange, 0) + (1 - alpha) * array.get(zigzagatr, 0) // shift left the candles shift_left_candles()=> // 3 "for" loops, not to get loop error for x = 0 to (array.size(zzcandles) > 0 ? array.size(zzcandles) - 1 : na) line.set_x1(array.get(zzcandles, x), bar_index - x) line.set_x2(array.get(zzcandles, x), bar_index - x) for x = 0 to (array.size(zztopwicks) > 0 ? array.size(zztopwicks) - 1 : na) line.set_x1(array.get(zztopwicks, x), bar_index - x) line.set_x2(array.get(zztopwicks, x), bar_index - x) for x = 0 to (array.size(zzbottomwicks) > 0 ? array.size(zzbottomwicks) - 1 : na) line.set_x1(array.get(zzbottomwicks, x), bar_index - x) line.set_x2(array.get(zzbottomwicks, x), bar_index - x) // calculate ATR for zigzag candles and keep them in an array zigzag_atr(length, insert)=> float hi = array.size(zztopwicks) > 0 ? line.get_y1(array.get(zztopwicks, 0)) : na float hi_1 = array.size(zztopwicks) > 1 ? line.get_y1(array.get(zztopwicks, 1)) : na float cl = array.size(zzcandles) > 0 ? line.get_y2(array.get(zzcandles, 0)) : na float cl_1 = array.size(zzcandles) > 1 ? line.get_y2(array.get(zzcandles, 1)) : na float lo = array.size(zzbottomwicks) > 0 ? line.get_y1(array.get(zzbottomwicks, 0)) : na if insert if array.size(zigzagtrueRange) > 100 array.pop(zigzagtrueRange) if array.size(zigzagatr) > 100 array.pop(zigzagatr) array.unshift(zigzagtrueRange, na(hi_1) ? hi - lo : max(max(hi - lo, abs(hi - cl[1])), abs(lo - cl_1))) array.unshift(zigzagatr, zigzag_rma(length)) else array.set(zigzagtrueRange, 0, na(hi_1) ? hi - lo : max(max(hi - lo, abs(hi - cl[1])), abs(lo - cl_1))) array.set(zigzagatr, 0, zigzag_rma(length)) // calculate/show zigzag candles, calculate zigza atr, zigzag supertrend and keep them in the arrays if array.size(zigzag) >= 4 zz_high := max(zz_high, high) zz_low := min(zz_low, low) if dirchanged // draw/keep candle body array.unshift(zzcandles, line.new(x1 = bar_index, y1 = array.get(zigzag, 2), x2 = bar_index, y2 = array.get(zigzag, 0), color = array.get(zigzag, 0) >= array.get(zigzag, 2) ? bodycolup : bodycoldown, width = 5)) // draw/keep top wicks zz_high := max(high, array.get(zigzag, 0), array.get(zigzag, 2)) zz_low := min(low, array.get(zigzag, 0), array.get(zigzag, 2)) array.unshift(zztopwicks, line.new(x1 = bar_index, y1 = zz_high, x2 = bar_index, y2 = max(array.get(zigzag, 2), array.get(zigzag, 0)), color = bodycoltop)) // draw/keep bottom wicks array.unshift(zzbottomwicks, line.new(x1 = bar_index, y1 = zz_low, x2 = bar_index, y2 = min(array.get(zigzag, 2), array.get(zigzag, 0)), color = bodycolbottom)) // remove old array elements if array.size(zzcandles) > 125 line.delete(array.pop(zzcandles)) line.delete(array.pop(zztopwicks)) line.delete(array.pop(zzbottomwicks)) // insert new atr value to the array zigzag_atr(atrlen, true) else // set close/high/low of the candle line.set_y2(array.get(zzcandles, 0), array.get(zigzag, 0)) line.set_y1(array.get(zztopwicks, 0), zz_high) line.set_y2(array.get(zztopwicks, 0), max(array.get(zigzag, 2), array.get(zigzag, 0))) line.set_y1(array.get(zzbottomwicks, 0), zz_low) line.set_y2(array.get(zzbottomwicks, 0), min(array.get(zigzag, 2), array.get(zigzag, 0))) // update atr value in the array zigzag_atr(atrlen, false) // shift left the candles shift_left_candles() // calculate zigzag supertrend float cl = array.size(zzcandles) > 0 ? line.get_y2(array.get(zzcandles, 0)) : na float cl_1 = array.size(zzcandles) > 1 ? line.get_y2(array.get(zzcandles, 1)) : na float hi = array.size(zztopwicks) > 0 ? line.get_y1(array.get(zztopwicks, 0)) : na float lo = array.size(zzbottomwicks) > 0 ? line.get_y1(array.get(zzbottomwicks, 0)) : na hl2_ = (hi + lo) / 2 st_up := hl2_ - (atrmult * array.get(zigzagatr, 0)) st_dn := hl2_ + (atrmult * array.get(zigzagatr, 0)) st_trendup := cl_1 > st_trendup_1 ? max(st_up, st_trendup_1) : st_up st_trenddn := cl_1 < st_trenddn_1 ? min(st_dn, st_trenddn_1) : st_dn st_trend := cl > st_trenddn_1 ? 1 : cl < st_trendup_1 ? -1 : nz(st_trend, 1) if dirchanged if array.size(zzsupertrend) > 124 array.pop(zzsupertrend) array.pop(zzstdir) array.unshift(zzsupertrend, st_trend == 1 ? st_trendup : st_trenddn) array.unshift(zzstdir, st_trend) else array.set(zzsupertrend, 0, st_trend == 1 ? st_trendup : st_trenddn) array.set(zzstdir, 0, st_trend) // show zigzag moving average if enabled if showmast == "Moving Average" and array.size(zigzag) > malen * 2 + 2 for x = 0 to (array.size(maarray) > 0 ? array.size(maarray) - 1 : na) line.delete(array.pop(maarray)) float oldpoint = na for x = 0 to (array.size(zigzag) > 0 ? array.size(zigzag) - 1 : na) by 2 if x > array.size(zigzag) - malen * 2 - 1 or x >= 250 break float zzma = 0.0 for y = x to x + malen * 2 - 1 by 2 zzma += array.get(zigzag, y) / malen if not na(oldpoint) array.unshift(maarray, line.new(x1 = bar_index - round(x / 2) + 1, y1 = oldpoint, x2 = bar_index - round(x / 2), y2 = zzma, color = color.blue, width = 2)) oldpoint := zzma // show zigzag supertrend if enabled if showmast == "Supertrend" and array.size(zigzag) > atrlen * 2 + 2 var zzstlines = array.new_line(0) var zzstlabels = array.new_label(0) for x = 0 to (array.size(zzstlines) > 0 ? array.size(zzstlines) - 1 : na) line.delete(array.pop(zzstlines)) for x = 0 to (array.size(zzstlabels) > 0 ? array.size(zzstlabels) - 1 : na) label.delete(array.pop(zzstlabels)) // 2 "for" loops, not to get loop error for x = 0 to (array.size(zzsupertrend) > 1 ? array.size(zzsupertrend) - 2 : na) if array.get(zzstdir, x) == array.get(zzstdir, x + 1) array.unshift(zzstlines, line.new(x1 = bar_index - x, y1 = array.get(zzsupertrend, x), x2 = bar_index - x - 1, y2 = array.get(zzsupertrend, x + 1), color = array.get(zzstdir, x) == 1 ? bodycolup : bodycoldown, width = 2)) for x = 0 to (array.size(zzsupertrend) > 1 ? array.size(zzsupertrend) - 2 : na) if array.get(zzstdir, x) != array.get(zzstdir, x + 1) array.unshift(zzstlabels, label.new( x = bar_index - x, y = array.get(zzsupertrend, x), color = array.get(zzstdir, x) == 1 ? bodycolup : bodycoldown, style = array.get(zzstdir, x) == 1 ? label.style_triangleup : label.style_triangledown, size = size.tiny)) // changr bar color by zigzag supertrend if enabled barcolor(chbarcolor and showmast == "Supertrend" ? (st_trend == 1 ? bodycolup : bodycoldown) : na)
[jav] Better Bollinger Bands
https://www.tradingview.com/script/T4W4kg5q-jav-Better-Bollinger-Bands/
javabgar
https://www.tradingview.com/u/javabgar/
63
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © javabgar // @version=4 // ______________________________________________________________________________________________ study("[jav] Better Bollinger", overlay=true) // ______________________________________________________________________________________________ // inputs per = input(defval = 20 , title = "Bollinger period", type=input.integer) sel = input(defval = "VWMA", title = "Selection of MAv", type=input.string , options = ["SMA", "EMA", "WMA", "VWMA", "RMA"]) shw = input(defval = false , title = "Show Classic BB?") mul = input(defval = 2.00 , title = "Bollinger multip", step = 0.05) // ______________________________________________________________________________________________ // functions // Moving Average Selector MvAvg(_src, _len) => sel == "SMA" ? sma(_src, _len) : sel == "EMA" ? ema(_src, _len) : sel == "WMA" ? wma(_src, _len) : sel == "VWMA" ? vwma(_src, _len) : sel == "RMA" ? rma(_src, _len) : na // Main function: calculates Better BBs and Classic BBs. BBB(_src, _per) => _av = MvAvg(_src, _per) // ema of close _s1 = stdev(_src, _per) // stdev of close _df = _src - _av // difference between close and ema _s2 = stdev(_df, _per) // stdev of that difference _vl = MvAvg(high - low, _per) // ema of high-low difference _dn = _av - (_s1 + _s2 + _vl/2) // upper BBB _up = _av + (_s1 + _s2 + _vl/2) // lower BBB _di = _dn + _vl/2 // inner lower BBB _ui = _up - _vl/2 // inner upper BBB _uB = _av + mul * _s1 // upper classic BB _dB = _av - mul * _s1 // upper classic BB [_av, _up, _ui, _di, _dn, _uB, _dB] // ______________________________________________________________________________________________ // results [av, up, ui, di, dn, uB, dB] = BBB(close, per) // ______________________________________________________________________________________________ // plots extcol = color.new(color.red , 00) intcol = color.new(color.red , 80) avgcol = color.new(color.black, 00) bbccol = color.new(color.blue , 00) pav = plot(av, color=avgcol, linewidth=1) puu = plot(up, color=extcol, linewidth=1) pll = plot(dn, color=extcol, linewidth=1) pul = plot(ui, color=intcol, linewidth=1) plu = plot(di, color=intcol, linewidth=1) fill(puu, pul, color=intcol) fill(pll, plu, color=intcol) puB = plot(shw ? uB : na, color = bbccol, linewidth=1) pdB = plot(shw ? dB : na, color = bbccol, linewidth=1) // ______________________________________________________________________________________________
Multi timeframes RSI Screener & indicator by noop42
https://www.tradingview.com/script/SXvO29GN/
noop-noop
https://www.tradingview.com/u/noop-noop/
318
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © noop42 //@version=4 study("MTF RSI Screener & indicator by noop42", overlay=false) // Input parameters src = input(close, title="Source") repainting = input(title="Allow repaint ? (enabled = live values)", type=input.bool, defval=true, group="Options") show_screener = input(title="Show Screener", type=input.bool, defval=true, group="Options") show_lines = input(title="Show RSI lines ?", type=input.bool, defval=true, group="Options") tf1 = input(title="Timeframe 1", type=input.resolution, defval="5", group="Options") tf2 = input(title="Timeframe 2", type=input.resolution, defval="15", group="Options") tf3 = input(title="Timeframe 3", type=input.resolution, defval="60", group="Options") tf4 = input(title="Timeframe 4", type=input.resolution, defval="240", group="Options") tf1_cvg_opt = input(true, "Include Timeframe #1 in convergence signals", group="Options") tf2_cvg_opt = input(true, "Include Timeframe #2 in convergence signals", group="Options") tf3_cvg_opt = input(true, "Include Timeframe #3 in convergence signals", group="Options") tf4_cvg_opt = input(false, "Include Timeframe #4 in convergence signals", group="Options") lengthRSI = input(14, "RSI Length", minval=1, group="RSI") rsi_low = input(30, title="RSI Oversold Level", group="RSI") rsi_high = input(70, title="RSI Overbought Level", group="RSI") // Custom functions rp_security(_symbol, _res, _src) => security(_symbol, _res, _src[barstate.isrealtime ? (repainting ? 0 : 1) : 0], gaps=false) get_movement(rsi) => rsi > rsi[1] ? "Bull" : "Bear" show_drawings(data) => show_lines ? data : na // MTF RSI rsi_tf1 = rp_security(syminfo.tickerid, tf1, rsi(src,lengthRSI)) rsi_tf2 = rp_security(syminfo.tickerid, tf2, rsi(src,lengthRSI)) rsi_tf3 = rp_security(syminfo.tickerid, tf3, rsi(src,lengthRSI)) rsi_tf4 = rp_security(syminfo.tickerid, tf4, rsi(src,lengthRSI)) rsi1ob = rsi_tf1 > rsi_high rsi1os = rsi_tf1 < rsi_low rsi2ob = rsi_tf2 > rsi_high rsi2os = rsi_tf2 < rsi_low rsi3ob = rsi_tf3 > rsi_high rsi3os = rsi_tf3 < rsi_low rsi4ob = rsi_tf4 > rsi_high rsi4os = rsi_tf4 < rsi_low tf1mov = get_movement(rsi_tf1) tf2mov = get_movement(rsi_tf2) tf3mov = get_movement(rsi_tf3) tf4mov = get_movement(rsi_tf4) // Colors obColor = color.blue osColor = #d43128 bullColor = #20b8e6 bearColor = color.red tf1movColor = tf1mov == "Bull" ? bullColor : bearColor tf2movColor = tf2mov == "Bull" ? bullColor : bearColor tf3movColor = tf3mov == "Bull" ? bullColor : bearColor tf4movColor = tf4mov == "Bull" ? bullColor : bearColor tf1RSIColor = rsi1ob ? obColor : rsi1os ? osColor : tf1movColor tf2RSIColor = rsi2ob ? obColor : rsi2os ? osColor : tf2movColor tf3RSIColor = rsi3ob ? obColor : rsi3os ? osColor : tf3movColor tf4RSIColor = rsi4ob ? obColor : rsi4os ? osColor : tf4movColor tf1status = rsi1ob ? "Overbought" : rsi1os ? "Oversold" : "OK" tf2status = rsi2ob ? "Overbought" : rsi2os ? "Oversold" : "OK" tf3status = rsi3ob ? "Overbought" : rsi3os ? "Oversold" : "OK" tf4status = rsi4ob ? "Overbought" : rsi4os ? "Oversold" : "OK" // Convergences rsi_ob_convergence = (tf1_cvg_opt ? rsi1ob : true) and (tf2_cvg_opt ? rsi2ob : true) and (tf3_cvg_opt ? rsi3ob : true) and (tf4_cvg_opt ? rsi4ob : true) rsi_os_convergence = (tf1_cvg_opt ? rsi1os : true) and (tf2_cvg_opt ? rsi2os : true) and (tf3_cvg_opt ? rsi3os : true) and (tf4_cvg_opt ? rsi4os : true) // Screener default_bg = #cccccc var tbl = table.new(position.top_right, 4, 6) if (show_screener) if (barstate.islast) table.cell(tbl, 0, 0, "TimeFrame", bgcolor = default_bg) table.cell(tbl, 1, 0, "RSI", bgcolor = default_bg) table.cell(tbl, 2, 0, "Movement", bgcolor = default_bg) table.cell(tbl, 3, 0, "RSI Status", bgcolor = default_bg) table.cell(tbl, 0, 1, tf1+(tf1_cvg_opt ? "*" : ""), bgcolor = default_bg) table.cell(tbl, 1, 1, tostring(rsi_tf1, '#.##'), bgcolor = tf1RSIColor) table.cell(tbl, 2, 1, tf1mov, bgcolor = tf1RSIColor) table.cell(tbl, 3, 1, tf1status, bgcolor = tf1RSIColor) table.cell(tbl, 0, 2, tf2+(tf2_cvg_opt ? "*" : ""), bgcolor = default_bg) table.cell(tbl, 1, 2, tostring(rsi_tf2, '#.##'), bgcolor = tf2RSIColor) table.cell(tbl, 2, 2, tf2mov, bgcolor = tf2RSIColor) table.cell(tbl, 3, 2, tf2status, bgcolor = tf2RSIColor) table.cell(tbl, 0, 3, tf3+(tf3_cvg_opt ? "*" : ""), bgcolor = default_bg) table.cell(tbl, 1, 3, tostring(rsi_tf3, '#.##'), bgcolor = tf3RSIColor) table.cell(tbl, 2, 3, tf3mov, bgcolor = tf3RSIColor) table.cell(tbl, 3, 3, tf3status, bgcolor = tf3RSIColor) table.cell(tbl, 0, 4, tf4+(tf4_cvg_opt ? "*" : ""), bgcolor = default_bg) table.cell(tbl, 1, 4, tostring(rsi_tf4, '#.##'), bgcolor = tf4RSIColor) table.cell(tbl, 2, 4, tf4mov, bgcolor = tf4RSIColor) table.cell(tbl, 3, 4, tf4status, bgcolor = tf4RSIColor) // Warning convergence alerts rsi_warning_message = (rsi_os_convergence ? "RSI OS convergence" : rsi_ob_convergence ? "RSI OB convergence" : "No RSI warning") rsi_warning_color = rsi_os_convergence ? osColor : rsi_ob_convergence ? obColor : default_bg table.cell(tbl, 0, 5, "Warnings", bgcolor = color.orange) table.cell(tbl, 1, 5, rsi_warning_message, bgcolor = rsi_warning_color) // Oscillators // Zones & lines ob_zone_color = obColor os_zone_color = osColor invisible = #00000000 h0 = hline(show_drawings(rsi_high), "Upper Band", color=ob_zone_color) hmid = hline(show_drawings(50), "Middle Band", color=#ffffff45) h1 = hline(show_drawings(rsi_low), "Lower Band", color=os_zone_color) obZone = hline(show_drawings(rsi_high), color=invisible) osZone = hline(show_drawings(rsi_low), color=invisible) plot(show_drawings(rsi_tf1), "RSI #1", color=tf1RSIColor, linewidth=1, transp=20) plot(show_drawings(rsi_tf2), "RSI #2", color=tf2RSIColor, linewidth=2, transp=40) plot(show_drawings(rsi_tf3), "RSI #3", color=tf3RSIColor, linewidth=3, transp=60) plot(show_drawings(rsi_tf4), "RSI #4", color=tf4RSIColor, linewidth=4, transp=80) // Shapes plotshape(show_drawings(rsi_os_convergence) ? 1 : 0, color=bullColor, location=location.bottom, size=size.tiny, style=shape.triangleup, title="Bullish movement") plotshape(show_drawings(rsi_ob_convergence) ? 1 : 0, color=bearColor, location=location.top, size=size.tiny, style=shape.triangledown, title="Bearish movement")
Bitcoin Halving Events
https://www.tradingview.com/script/KMJVA5zu-Bitcoin-Halving-Events/
kevindcarr
https://www.tradingview.com/u/kevindcarr/
96
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © kevindcarr //@version=5 indicator(title='Bitcoin Halving Events', shorttitle='Bitcoin Halvings', overlay=true) showLabels = input(defval=true, title="Show labels") isDate(y, m, d) => val = timestamp(y, m, d) if val <= time and val > time[1] true else false // First Halving if isDate(2012, 11, 28) line.new(bar_index, low, bar_index, high, xloc.bar_index, extend.both, color=color.yellow) if (showLabels) label.new(bar_index, low, text='1st Halving - Nov 28, 2012', style=label.style_label_upper_left, textcolor=color.black, color=color.yellow, textalign=text.align_right) // Second Halving if isDate(2016, 7, 9) line.new(bar_index, low, bar_index, high, xloc.bar_index, extend.both, color=color.yellow) if (showLabels) label.new(bar_index, low, text='2nd Halving - Jul 9, 2016', style=label.style_label_upper_left, textcolor=color.black, color=color.yellow, textalign=text.align_right) // Third Halving if isDate(2020, 5, 11) line.new(bar_index, low, bar_index, high, xloc.bar_index, extend.both, color=color.yellow) if (showLabels) label.new(bar_index, low, text='3rd Halving - May 11, 2020', style=label.style_label_upper_left, textcolor=color.black, color=color.yellow, textalign=text.align_right) // Fourth Halving (Estimated) if isDate(2024, 8, 10) line.new(bar_index, low, bar_index, high, xloc.bar_index, extend.both, color=color.yellow) if (showLabels) label.new(bar_index, low, text='4th Halving - (approx) Aug 10, 2024', style=label.style_label_upper_left, textcolor=color.black, color=color.yellow, textalign=text.align_right)
Barcolor X 2021-9-28
https://www.tradingview.com/script/diGq7sQW-Barcolor-X-2021-9-28/
geno777
https://www.tradingview.com/u/geno777/
21
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=4 // Updated to Version 4 2021-7-1 // © geno777 // This barcolor setting adds dimension to whether it's above or below where it was X bars ago by adding a // longer term argument to filter out sideways price action. For example, the white price bars show when // the price stayed above where it was five bars ago AND twenty bars ago. study("Barcolor X 2021-9-28", shorttitle = "BC-X", overlay=true) // Getting Inputs len = input(5, minval=1, title="Fast Length") len2 = input(20, minval=1, title="Slow Length") src = input(title="Source", type=input.source, defval=close) // Plot colors col_grow_above = #ffffff col_grow_below = #4CAF50 col_fall_above = #0000ff col_fall_below = #ff0000 // Putting it together. barcolor(src >= src[len2] ? (src > src[len] ? col_grow_above : col_fall_above) : (src < src[len] ? col_fall_below : col_grow_below))
Cumulative Relative Strength Index
https://www.tradingview.com/script/1YakJCrH-Cumulative-Relative-Strength-Index/
TradeAutomation
https://www.tradingview.com/u/TradeAutomation/
183
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // @version=4 // Author = TradeAutomation study(title="Cumulative Relative Strength Index", shorttitle="CRSI", format=format.price, precision=2, resolution="") src = input(close, "Source", type = input.source) len = input(2, minval=1, title="RSI Length") up = rma(max(change(src), 0), len) down = rma(-min(change(src), 0), len) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) CumulationLength = input(2, "Cumulation Length") CumulativeRSI = sum(rsi, CumulationLength) plot(CumulativeRSI, "Cumulative RSI", color=color.purple) upperhline = hline(100*CumulationLength*input(80, "Upper Line %")*.01) lowerhline = hline(100*CumulationLength*input(20, "Lower Line %")*.01) fill(upperhline, lowerhline, color=color.new(color.gray, 80) , title="Background")
Special Time Period
https://www.tradingview.com/script/ZPJqx2b1/
only_fibonacci
https://www.tradingview.com/u/only_fibonacci/
223
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © only_fibonacci //@version=4 study("Special Time Period",overlay=false) res = input(title="Period", type=input.string, defval="D") //Resolution, eg. '60' - 60 minutes, 'G' - daily, 'H' - weekly, 'A' - monthly, '5G' - 5 days, '12M' - one year, '3A' - one quarter c=security(syminfo.tickerid,res,close) // close o=security(syminfo.tickerid,res,open) // open h=security(syminfo.tickerid,res,high) // high l=security(syminfo.tickerid,res,low) // low plotcandle(o==o[1]?na:o,h==h[1]?na:h,l==l[1]?na:l,c==c[1]?na:c,title="Candle",color=o<c?color.green:color.red,wickcolor=color.black)
Baekdoo multi OverSold OverBuy colored Candle
https://www.tradingview.com/script/ovRU9WnN-Baekdoo-multi-OverSold-OverBuy-colored-Candle/
traderbaekdoosan
https://www.tradingview.com/u/traderbaekdoosan/
52
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © traderbaekdoosan //@version=4 study("Baekdoo multi OverSold OverBuy colored Candle", overlay=true) //stochastic slow stoch_length = input(14, minval=1) stoch_OverBought = input(80) stoch_OverSold = input(20) //RSI RSI_length = input( 30 ) RSI_overSold = input( 30 ) RSI_overBought = input( 70 ) //CCI cci_length = input(20, minval=1) cci_src = input(hlc3, title="Source") cci_ma = sma(cci_src, cci_length) cci = (cci_src - cci_ma) / (0.015 * dev(cci_src, cci_length)) cci_overSold = input( -170 ) cci_overBought = input( 220 ) //Parabolic SAR start = input(0.007) increment = input(0.007) maximum = input(0.09, "Max Value") out = sar(start, increment, maximum) AA=stoch(close, high, low, stoch_length) < stoch_OverSold ? 1 : 0 BB=rsi(close, RSI_length) < RSI_overSold ? 1 : 0 CC=cci < cci_overSold ? 1 : 0 DD=out > close ? 1 : 0 result_pos=AA+BB+CC+DD barcolor(open<close and result_pos == 4 and volume > ema(volume, 78)/2 ? color.new(color.red, 0) : open<close and result_pos == 3 ? color.new(color.red, 25) : open<close and result_pos == 2 ? color.new(color.red, 50) : open<close and result_pos == 1? color.new(color.red, 75) : na) plotshape(open<close and result_pos == 4 and volume > ema(volume, 78)/2 , style=shape.arrowup, color=#FF0000, location=location.belowbar, size=size.tiny) plotshape(open<close and result_pos == 4 and volume > ema(volume, 78)/2 , text="OverSold", style=shape.labelup, color=#FF0000, textcolor=color.white, location=location.belowbar, size=size.tiny) AAA=stoch(close, high, low, stoch_length) > stoch_OverBought ? 1 : 0 BBB=rsi(close, RSI_length) > RSI_overBought ? 1 : 0 CCC=cci > cci_overBought ? 1 : 0 DDD=out < close ? 1 : 0 result_neg=AAA+BBB+CCC+DDD barcolor(open>close and result_neg == 4 and volume > ema(volume, 78)/2 ? color.new(color.blue, 0) : open>close and result_neg == 3 ? color.new(color.blue, 25) : open>close and result_neg == 2 ? color.new(color.blue, 50) : open>close and result_neg == 1? color.new(color.blue, 75) : na) plotshape(open>close and result_neg == 4 and volume > ema(volume, 78)/2 , style=shape.arrowdown, color=#0000FF, location=location.abovebar, size=size.tiny) plotshape(open>close and result_neg == 4 and volume > ema(volume, 78)/2 , text="OverBuy", style=shape.labeldown, color=#0000FF, textcolor=color.white, location=location.abovebar, size=size.tiny)
SAR MTF levels
https://www.tradingview.com/script/03sZlXya-SAR-MTF-levels/
Troptrap
https://www.tradingview.com/u/Troptrap/
21
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © mildSnail31034 //@version=4 study("SAR MTF levels", overlay=true) showsar = input(title="Show Parabolic SAR", type=input.bool, defval=true) start = input(title="SAR Start", type=input.float, step=0.001,defval=0.02) increment = input(title="SAR increment", type=input.float, step=0.001,defval=0.02) maxsar = input(title="SAR max", type=input.float, step=0.01, defval=0.2) lbloff = input(title="Labels offset(bars)", type=input.integer,defval=3,minval=0) psar = sar(start,increment, maxsar) sar1 = security(syminfo.tickerid,"1",psar) sar5 = security(syminfo.tickerid,"5",psar) sar15 = security(syminfo.tickerid,"15",psar) sar60 = security(syminfo.tickerid,"60",psar) sar4hr = security(syminfo.tickerid,"240",psar) sarD = security(syminfo.tickerid,"D",psar) sarW = security(syminfo.tickerid,"W",psar) sarM = security(syminfo.tickerid,"M",psar) bullcolor = input(title="Bull color",type=input.color,defval=color.green) bearcolor = input(title="Bear color",type=input.color,defval=color.red) sar1lvl = input(title="Show 1m level",type=input.bool,defval=true) sar1line = input(title="Show 1m line",type=input.bool,defval=false) sar1color = sar1[0]>close ? bearcolor:bullcolor plot(sar1lvl and sar1line ? sar1:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sar1color) plotshape(sar1lvl?sar1:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="1m",color=sar1color) sar5lvl = input(title="Show 5m level",type=input.bool,defval=true) sar5line = input(title="Show 5m line",type=input.bool,defval=false) sar5color = sar5[0]>close ? bearcolor:bullcolor plot(sar5lvl and sar5line ? sar5:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sar5color) plotshape(sar5lvl?sar5:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="5m",color=sar5color) sar15lvl = input(title="Show 15m level",type=input.bool,defval=true) sar15line = input(title="Show 15m line",type=input.bool,defval=false) sar15color = sar15[0]>close ? bearcolor:bullcolor plot(sar15lvl and sar15line ? sar15:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sar15color) plotshape(sar15lvl?sar15:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="15m",color=sar15color) sar60lvl = input(title="Show 1hr level",type=input.bool,defval=true) sar60line = input(title="Show 1hr line",type=input.bool,defval=false) sar60color = sar60[0]>close ? bearcolor:bullcolor plot(sar60lvl and sar60line ? sar60:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sar60color) plotshape(sar60lvl?sar60:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="1hr",color=sar60color) sar4hrlvl = input(title="Show 4hrs level",type=input.bool,defval=true) sar4hrline = input(title="Show 4hrs line",type=input.bool,defval=false) sar4hrcolor = sar4hr[0]>close ? bearcolor:bullcolor plot(sar4hrlvl and sar4hrline ? sar4hr:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sar4hrcolor) plotshape(sar4hrlvl?sar4hr:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="4h",color=sar4hrcolor) sarDlvl = input(title="Show daily level",type=input.bool,defval=true) sarDline = input(title="Show daily line",type=input.bool,defval=false) sarDcolor = sarD[0]>close ? bearcolor:bullcolor plot(sarDlvl and sarDline ? sarD:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sarDcolor) plotshape(sarDlvl?sarD:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="D",color=sarDcolor) sarWlvl = input(title="Show weekly level",type=input.bool,defval=true) sarWline = input(title="Show weekly line",type=input.bool,defval=false) sarWcolor = sarW[0]>close ? bearcolor:bullcolor plot(sarWlvl and sarWline ? sarW:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sarWcolor) plotshape(sarWlvl?sarW:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="W",color=sarWcolor) sarMlvl = input(title="Show monthly level",type=input.bool,defval=true) sarMline = input(title="Show monthly line",type=input.bool,defval=false) sarMcolor = sarM[0]>close ? bearcolor:bullcolor plot(sarMlvl and sarMline ? sarM:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sarMcolor) plotshape(sarMlvl?sarM:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="M",color=sarMcolor)
Gann HiLo Activator
https://www.tradingview.com/script/Ggq66ykL-Gann-HiLo-Activator/
starbolt
https://www.tradingview.com/u/starbolt/
276
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © starbolt //@version=5 indicator('Gann HiLo Activator', overlay=true) len = input.int(3, 'Length', step=1, minval=1) displace = input.int(1, 'Displace', step=1, minval=0) ma_type = input.string('SMA', 'MA Type', options=['SMA', 'EMA', 'WMA', 'ALMA', 'VWMA', 'HMA', 'LSMA', 'SMMA', 'DEMA']) alma_offset = input.float(0.85, 'ALMA Offset', step=0.01, minval=0, maxval=1) alma_sigma = input.float(6, 'ALMA Sigma', step=0.01) lsma_offset = input.int(0, 'LSMA Offset', step=1) //Hilo Activator float hilo = na hi = ta.sma(high, len) lo = ta.sma(low, len) // Exponential Moving Average (EMA) if ma_type == 'EMA' hi := ta.ema(high, len) lo := ta.ema(low, len) // Weighted Moving Average (WMA) if ma_type == 'WMA' hi := ta.wma(high, len) lo := ta.wma(low, len) // Arnaud Legoux Moving Average (ALMA) if ma_type == 'ALMA' hi := ta.alma(high, len, alma_offset, alma_sigma) lo := ta.alma(low, len, alma_offset, alma_sigma) // Hull Moving Average (HMA) if ma_type == 'HMA' hi := ta.wma(2 * ta.wma(high, len / 2) - ta.wma(high, len), math.round(math.sqrt(len))) lo := ta.wma(2 * ta.wma(low, len / 2) - ta.wma(low, len), math.round(math.sqrt(len))) // Volume-weighted Moving Average (VWMA) if ma_type == 'VWMA' hi := ta.vwma(high, len) lo := ta.vwma(low, len) // Least Square Moving Average (LSMA) if ma_type == 'LSMA' hi := ta.linreg(high, len, lsma_offset) lo := ta.linreg(low, len, lsma_offset) // Smoothed Moving Average (SMMA) if ma_type == 'SMMA' hi := (hi[1] * (len - 1) + high) / len lo := (lo[1] * (len - 1) + low) / len // Double Exponential Moving Average (DEMA) if ma_type == 'DEMA' e1_high = ta.ema(high, len) e1_low = ta.ema(low, len) hi := 2 * e1_high - ta.ema(e1_high, len) lo := 2 * e1_low - ta.ema(e1_low, len) hilo := close > hi[displace] ? 1 : close < lo[displace] ? -1 : hilo[1] ghla = hilo == -1 ? hi[displace] : lo[displace] color = hilo == -1 ? color.red : color.green //Alerts buyCondition = hilo == 1 and hilo[1] == -1 sellCondition = hilo == -1 and hilo[1] == 1 if buyCondition alert('Long', alert.freq_once_per_bar) if sellCondition alert('Short', alert.freq_once_per_bar) //Plots plot(ghla, color=color, style=plot.style_cross)
Forex Session Volume Explorer
https://www.tradingview.com/script/jRbGv6i1-Forex-Session-Volume-Explorer/
DasanC
https://www.tradingview.com/u/DasanC/
67
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © EmpiricalFX //@version=4 study("Forex Session Vol Explorer",overlay=false) //Groups gp0 = "Introduction" gp1 = "Forex Trading Sessions" gp2 = "Session Configuration" //Tooltips t1 = "This indicator is an exploration of how Forex Sessions affect volume. The colored plots below represent the accumulative volume during each of the four major trading sessions: London, New York, Tokyo, and Sydney. Plots have been normalized as a percentage of total volume, i.e. London = 34.2 signifies that 34.2% of all volume occurs during the London Session.Trading the session with the highest volume will greatly benefit your Win Rate, especially when using \"typical\" indicators and strategies." //Intro dummy0 = input(true,"Hover over ( ! ) for Introduction",group=gp0, tooltip=t1) //Sessions london = input(title="London Session", type=input.session, defval="0300-1200",group=gp1) ny = input(title="New York Session", type=input.session, defval="0800-1700",group=gp1) tokyo = input(title="Tokyo Session", type=input.session, defval="2000-0400",group=gp1) sydney = input(title="Sydney Session", type=input.session, defval="1700-0200",group=gp1) //Config input_src = input("Volume","Accumulation Data Source",options=["Volatility","Volume"],group=gp2,tooltip="Volume accumulates intrabar volume.\nVolatility accumulates intrabar true range.") London = input(title="Show London Session", type=input.bool, defval=true,group=gp2) LondonColor = input(color.blue,"London Color",input.color,group=gp2) NY = input(title="Show New York Session", type=input.bool, defval=true,group=gp2) NYColor = input(color.red,"New York Color",input.color,group=gp2) Tokyo = input(title="Show Tokyo Session", type=input.bool, defval=true,group=gp2) TokyoColor = input(color.yellow,"Tokyo Color", input.color,group=gp2) Sydney = input(title="Show Sydney Session", type=input.bool, defval=true,group=gp2) SydneyColor = input(color.green,"Sydney Color",input.color,group=gp2) //Returns true if given session is current is_session(sess) => not na(time("D", sess)) //Data Curation var London_accum = 0.0 var NY_accum = 0.0 var Tokyo_accum = 0.0 var Sydney_accum = 0.0 var Vol_accum = 0.0 src = input_src == "Volume" ? nz(volume) : input_src == "Volatility" ? nz(tr) : na if(timeframe.isdaily or timeframe.isweekly or timeframe.ismonthly) var notice = label.new(bar_index,1,"Sorry! Session analysis only\nworks on Intraday Charts!",color=color.white,style=label.style_label_center,size=size.huge) label.set_x(notice,bar_index) if(not(timeframe.isdaily or timeframe.isweekly or timeframe.ismonthly)) if(London and is_session(london)) London_accum += src if(NY and is_session(ny)) NY_accum += src if(Tokyo and is_session(tokyo)) Tokyo_accum += src if(Sydney and is_session(sydney)) Sydney_accum += src Vol_accum := (London_accum + NY_accum + Tokyo_accum + Sydney_accum) plot(London?100*London_accum/Vol_accum:na,"London Session Accumulated Volume",LondonColor,2,editable=false) plot(NY?100*NY_accum/Vol_accum:na,"New York Session Accumulated Volume",NYColor,2,editable=false) plot(Tokyo?100*Tokyo_accum/Vol_accum:na,"Tokyo Session Accumulated Volume",TokyoColor,2,editable=false) plot(Sydney?100*Sydney_accum/Vol_accum:na,"Sydney Session Accumulated Volume",SydneyColor,2,editable=false)
Mid to High daily % - MA & Threshold
https://www.tradingview.com/script/jhR7A9mC-Mid-to-High-daily-MA-Threshold/
slowdavid21
https://www.tradingview.com/u/slowdavid21/
49
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © slowdavid21 //@version=4 study("MA - Mid to High daily %") source = (((high-(low+((high-low)/2)))/((low+((high-low)/2))))*100) lengthfast = input(30,minval=1) lengthslow= input(90,minval=1) threshold = input (10, minval=1) MAfast = sma(source,lengthfast) MAslow = sma(source,lengthslow) plot(MAfast,'MAfast',color.red) plot(MAslow,'MAslow',color.white) plot(threshold,"threshold",color.yellow) plot(((high-(low+((high-low)/2)))/((low+((high-low)/2))))*100)
Pythagorean Moving Averages (and more)
https://www.tradingview.com/script/b8VSLLbN-Pythagorean-Moving-Averages-and-more/
OztheWoz
https://www.tradingview.com/u/OztheWoz/
56
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © OztheWoz //@version=4 study("Pythagorean Averages", overlay=true, max_bars_back=250) ////////////////// //// INPUTS //// ////////////////// mmaonf = input(true, "Harmonic MA", group="🏮 On/Off 🏮") gmaonf = input(true, "Geometric MA", group="🏮 On/Off 🏮") amaonf = input(true, "Arithmetic MA", group="🏮 On/Off 🏮") qmaonf = input(true, "Quadratic MA", group="🏮 On/Off 🏮") cmaonf = input(true, "Cubic MA", group="🏮 On/Off 🏮") mmasrc = input(close, "Harmonic MA Source", group="🌌 Source 🌌") gmasrc = input(close, "Geometric MA Source", group="🌌 Source 🌌") amasrc = input(close, "Arithmetic MA Source", group="🌌 Source 🌌") qmasrc = input(close, "Quadratic MA Source", group="🌌 Source 🌌") cmasrc = input(close, "Cubic MA Source", group="🌌 Source 🌌") mmalen = input(200, "Harmonic MA Length", group = "🥮 Length 🥮") gmalen = input(200, "Geometric MA Length", group = "🥮 Length 🥮") amalen = input(200, "Arithmetic MA Length", group = "🥮 Length 🥮") qmalen = input(200, "Quadratic MA Length", group = "🥮 Length 🥮") cmalen = input(200, "Cubic MA Length", group = "🥮 Length 🥮") ///////////////////////// //// HARMONIC MEAN //// ///////////////////////// // p = -1 mma(hsrc, hlen) => hkey = 1/hsrc for i = 1 to (hlen - 1) hkey := hkey + (1/hsrc)[i] avg = hkey/hlen hend = 1/avg hend ////////////////////////// //// GEOMETRICAL MEAN //// ////////////////////////// // p = 0 nroot(nsrc, nlen) => num = nsrc sqrt = pow(num, 1/nlen) sqrt gma(gsrc, glen) => gkey = gsrc for i = 1 to (glen - 1) gkey := gkey * gsrc[i] nroot(gkey, glen) ///////////////////////////// //// ARITHMETICAL MEAN //// ///////////////////////////// // p = 1 // NOTE: this is the same as the sma(src, len) function, the purpose // of this was to show how this function existed. ama(asrc, alen) => akey = asrc for i = 1 to (alen - 1) akey := akey + asrc[i] avg = akey/(alen) avg ////////////////////////// //// QUADRATIC MEAN //// ////////////////////////// // p = 2 qma(qsrc, qlen) => qkey = pow(qsrc, 2) for i = 1 to (qlen - 1) qkey := qkey + (pow(qsrc, 2))[i] qavg = qkey/qlen qend = nroot(qavg, 2) qend ////////////////////// //// CUBIC MEAN //// ////////////////////// // p = 2 cma(csrc, clen) => ckey = pow(csrc, 3) for i = 1 to (clen - 1) ckey := ckey + (pow(csrc, 3))[i] cavg = ckey/clen cend = nroot(cavg, 3) cend ///////////////// //// PLOTS //// ///////////////// plot(mmaonf ? (mma(mmasrc, mmalen)) : na, color=color.fuchsia) plot(gmaonf ? (gma(gmasrc, gmalen)) : na, color=color.olive) plot(amaonf ? (ama(amasrc, amalen)) : na, color=color.aqua) plot(qmaonf ? (qma(qmasrc, qmalen)) : na, color=color.yellow) plot(cmaonf ? (cma(cmasrc, cmalen)) : na, color=color.red)
Delayed-Velocity
https://www.tradingview.com/script/DNAgH8qa-Delayed-Velocity/
tech24trader-ben-au
https://www.tradingview.com/u/tech24trader-ben-au/
15
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © tech24trader-ben-au //@version=4 study("Delayed-Velocity") vel = mom(hl2, 24) avg_vel = sma(vel, 12) plot(vel, title="velocity", color = #ff8800) plot(avg_vel, title="ma", color = #0000ff) plot(0, title="ground", color = #ff0000)