Bill Williams. Candles bear / bullish spread + Alligator.Bill Williams. Candles bear / bullish spread + Alligator.
Cerca negli script per "bear"
RSI_EMA & Bearish EngulfingThis is a RSI-RSI of EMA and bearish candlestick reversal pattern formed by two candlesticks. Following an uptrend, the first candlestick is a up candlestick which is followed by a down candlestick which has a long real body that engulfs or contains the real body of the prior bar. following an uptrend, if RSI and EMA line cross then Sell and for downtrend if RSI and EMA line cross then Buy.
Bullish/Bearish Candelstick patternHey!
This time I took the pattern recognizer from a previous script I worked.
It overlays the Arrows on the chart.
Legend:
#Maroon colour: Strong bearish signal
#Red colour: Bearish signal
#Dark Green colour: Strong bullish signal
#Lime: Bullish signal
NOTE: Also, you can untick the patterns you don't find useful, but I kept every pattern to get a complete script.
I unticked:
Morning Star
Evening Star
Shooting Star
Bullish Harami (too bearish on corrective phase)
Hanging Man
Red Cloud Cover
Better RSI with bullish / bearish market cycle indicator This script improves the default RSI. First. it identifies regions of the RSI which are oversold and overbought by changing the color of RSI from white to red. Second, it adds additional reference lines at 20,40,50,60, and 80 to better gauge the RSI value. Finally, the coolest feature, the middle 50 line is used to indicate which cycle the price is currently at. A green color at the 50 line indicates a bullish cycle, a red color indicators a bearish cycle, and a white color indicates a neutral cycle.
The cycles are determined using the RSI as follows:
if RSI is overbought, cycle switches to bullish until RSI falls below 40, at which point it becomes neutral
if RSI is oversold, cycle switches bearish until RSI rises above 60, at which point it becomes neutral
a neutral cycle is exited at either overbought or oversold conditions
Very useful, please give it a try and let me know what you think
CCI AnalysesThis script analyses the CCI indicator values, showing when a fall in price or a rise in price may happen, or when the CCI is confirming the trend.
The user can personalize:
The period to be used and the range of the CCI bands ( by default)
The slow SMA period to be used and the price percentage variation to react for bullish/bearish
Consecutive number of bullish/bearish in order to consider the CCI as a trend confirmation rather than a price reversal
CMYK VRMI◊ Introduction
This script indicates the relative movement of price x volume.
◊ Origin
Based on 'The Relative Momentum Index' by Roger Altman : February, 1993 issue of Technical Analysis of Stocks & Commodities magazine.
While RSI counts up and down days from close to close, the Relative Momentum Index counts up and down days from the close relative to a close x number of days ago.
This results in an RSI that is smoother. The input has been changed to the change of a smoothed close multiplied by a smoothed volume.
The polarity of VRMI indicates bearish/bullish movement.
◊ Adjustments
CMYK color theme applied.
◊ Usage
VRMI indicates the force the market moves with.
◊ Future Prospects
-
◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊
CMYK VRMI RAYS ◊ Introduction
Introducing VRMI in this script, an RMI based on price movement and volume, to indicate bullish and bearish trends.
This script marks the background depending on RMI <> VRMI , VRMI polarity and large buy/sell sprees.
◊ Origin
Based on 'The Relative Momentum Index' by Roger Altman : February, 1993 issue of Technical Analysis of Stocks & Commodities magazine.
While RSI counts up and down days from close to close, the Relative Momentum Index counts up and down days from the close relative to a close x number of days ago.
This results in an RSI that is smoother.
In addition VRMI reacts quick, it is used to cut off latency from RMI, and it's polarity indicates the beginning and end of a trend.
Large buy sell sprees and detected in their proportion with an sma on the volume
◊ Adjustments
CMYK color theme applied.
◊ Usage
This indicator can be used to detect trends and mark reversals.
◊ Prospects
◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊ ◊
Bats Bearish Divergence Detector (BRED-)After the release of BUBD+ here comes BRED- for calling the tops.
6 indicators are tested for the presence of any bearish Divergences and are plotted on chart as soon as they are.
Note - Price can move up after bearish divergence as well so its not foolproof. However multiple bearish divergences signify that bulls are losing power and price might reverse downwards.
Instead of blindly trusting the divergence on this indicator I suggest that you use this as a tracking mechanism instead. Once you spot a bearish divergence here, go to the oscillator that was called by the indicator and see the strength of the divergence involved.
This way you dont have to look at the indicators for divergence all the time, just only when the indicator calls for it. (Note that different timeframes will have different divergences so make sure you watch most of them. Higher timeframes indicate larger potential reversals)
Colour -
MACD- Aqua blue
RSI - Red
Stoch RSI - pink
CCI - Orange
MFI - Teal (Blue)
RVI - Silver
If you want to change the number of indicators you can do so from the bottom and remove the indicators you dont want to see by commenting them out.
1337 VolumeThis volume indicator gives you a unique perspective and ability to analyze volume in any market. The upper line that is always >=0 represents average up volume over a user definable period while the lower line that is always <= 0 represents the average down volume over a user definable period.
green == bullish candle but volume lower than average
lime == bullish candle with above average volume
crimson == bearish candle with below average volume
red == bearish candle with above average volume
This indicator is very useful for spotting bottoms / tops (do a visual backtest and observe its behavior) as well as entry opportunities.
By default, the lookback period for average volume is 7, but I encourage you to change this value in order to find settings that work best for your particular market.
If you have any feedback or ideas for improvement, please comment.
Enjoy :D
Super Envolvente (Bullish y Bearish)Identificador de Super-envolventes (SE), se encarga de darle un color verde a la SE alzista (Bullish) verde y rojo a la bajista (Bearish).
Candlestick Patterns Identified (updated 3/11/15)I decided to republish this one without the trend filter and with all the major symbols active. This will allow for all the patterns to show up.
Due to 15 different candlestick formations in this one script, it will be difficult to turn off the last few due to screen size. You can turn off individual patterns on the settings screen.
I have everything spelled out except the hammer and inverted hammer. They are "H" and "IH" respectively on the charts. They show up so often that they cluttered the charts.
The default script has: Doji, Evening Star, Morning Star, Shooting Star, Hammer, Inverted Hammer, Bearish Harami, Bullish Harami, Bearish Engulfing, Bullish Engulfing, Piercing Line, Bullish Belt, Bullish Kicker, Bearish Kicker, Hanging man, and Dark Cloud Cover. You can turn off what you don't like. The Piercing Line, Bullish Belt, and the Kickers will usually show up better in the daily charts.
I recommend watching videos with Stephen Bigalow to get a feel for how to trade these. You will want to add an 8 EMA to your chart with his setups. Enjoy.
If you want the old version: Take a look at the related ideas below.
Candlesticks Patterns IdentifiedI was using another script that colored the bars to show the different candle patterns. Thanks to HPotter (www.tradingview.com). Unfortunately, I can't think that fast when looking across a screen of charts with different color bars. Fortunately, Tradingview came up with symbols and names on 2/26/15. I decided to take my favorite symbols and attach them to a name. This makes it easier to see what is going on and where your entry would be if it confirms. Works beautifully for me. Decided to share. I also added the ability to alter what shows up based upon a look back. A bullish engulfing at the top of a trend, or a bearish harami at the bottom of the trend, is nearly useless and clutters the chart. I have the default set for the open of the current bar to be higher or lower than the open from 5 bars back. You can adjust in the settings to what you like. This trend setting is on all the patterns except doji. If you want to see all the candle patterns, set it to "1".
The doji can be adjusted as well. I left some other patterns at the bottom of the script, but they are turned off. They became too much of a clutter for me. I prefer DovCaspi's pattern finder for hammers and stars: I use his due to the clean appearance.
The default script has: Doji, Bearish Harami, Bullish Harami, Bearish Engulfing, Bullish Engulfing, Piercing Line, Bullish Belt, Bullish Kicker, and Bearish Kicker. You can turn off what you don't like. The Piercing Line, Bullish Belt, and the Kickers will usually show up better in the daily charts.
If you would like the updated version, see the Related Ideas below:
Keltner Channel with auto highlighting of Bear/Bull reversals*** New version @ ****
All options configurable.
Reversals are marked using crosses. as well as highlighted using green/red color (depending on bull/bear). Enjoy!
Bearish signal using Point of Control (POC) with PAC by guruThis indicator code helps traders identify potential sell opportunities using several important technical indicators:
Point of Control (POC) – This is the price level where the most volume was traded over the past several days.
Previous Day's Low – This shows the lowest price reached during the previous day.
PAC (Price Action Channel) EMA – These are two moving averages (one based on the low price and one based on the close price) that help determine if the price is trending within a certain range.
Volume SMA – This is a 3-day simple moving average (SMA) of volume, which helps filter out signals based on market activity.
What the Script Does:
Point of Control (POC):
The script looks at the last 50 days (configurable) and calculates which price level had the highest trading volume.
It then plots a red line on the chart at the POC level. This is important because it helps identify areas where there was strong market interest in the past.
Volume Moving Average:
The script calculates a 3-day SMA of volume, but it excludes the current day to avoid premature signals based on today’s trading.
The volume SMA is used to ensure there’s enough market activity (with a threshold set to 25 units) before triggering a sell signal.
Price Action Channel (PAC) EMA:
The PAC consists of two exponential moving averages (EMAs):
The PAC Low EMA: This is based on the low prices over the last 34 periods (configurable).
The PAC Close EMA: This is based on the closing prices over the last 34 periods.
These EMAs help determine if the price is trending above or below certain price levels.
Sell Signal Logic: The script checks three conditions before displaying a "Sell" signal:
Price Below POC and Previous Day’s Low:
The close price must be below both the Point of Control (POC) and the previous day's low.
Volume SMA Above 25:
The 3-day volume SMA must be greater than 25. This ensures the signal only triggers when there’s enough trading volume in the market.
Today’s Low is Above PAC EMAs:
Today's low price must be above both the PAC low EMA and the PAC close EMA. This prevents sell signals when prices are already significantly below the PAC, indicating possible exhaustion in the downtrend.
If all three conditions are met, the script will display a red "Sell" label on the chart, signaling a potential selling opportunity.
No Sell Signal if Price Reverses:
If the price crosses back above the POC or the previous day's low, the script will remove the sell signal and reset for a new opportunity.
Summary of Conditions:
For the script to display a "Sell" label:
The close price must be below the Point of Control (POC) and the previous day’s low.
The 3-day volume SMA (excluding today) must be greater than 25 units.
The low price of the current day must be above both the PAC low EMA and the PAC close EMA.
If these conditions are met, a red sell label appears on the chart as a potential signal for a short (sell) trade.
SMC EASY MONEY//@version=5
indicator("SMC EASY MONEY",overlay = true, max_bars_back = 5000, max_lines_count = 500, max_boxes_count = 500, max_labels_count = 500)
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------- Input Settings
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------}
//Order Blocks
//----------------------------------------{
show_order_blocks=input.bool(true,"Order Blocks",group = 'Order Blocks', inline = "ob1")
ibull_ob_css = input.color(#5d606b19, '', inline = 'ob1', group = 'Order Blocks')
ibear_ob_css = input.color(#5d606b19, '', inline = 'ob1', group = 'Order Blocks')
ob_type__= input.string('All', '',options = , group = 'Order Blocks',inline = 'ob1')
i_tf_ob = input.timeframe("", "Timeframe", group = 'Order Blocks', inline = "ob2")
mittigation_filt= input.string('Wicks', "Mitigation Method",options = , group = 'Order Blocks',inline = 'ob3')
overlapping_filt= input(true, 'Hide Overlap', inline = 'ob3', group = 'Order Blocks')
max_obs = input.int(4, 'Max OBs', minval = 3, group = 'Order Blocks', inline = 'ob4')
length_extend_ob = input.int(defval = 20,title = "Length", minval = 0, maxval = 500 ,group = 'Order Blocks', inline = "ob4")
ob_extend = input.bool(false,"Extend",group = 'Order Blocks', inline = "ob4")
text_size_ob =input.string("Large", options= , title="Text Size",inline="ob1_t", group="Order Blocks")
text_size_ob_ = text_size_ob == "Small" ? size.tiny : text_size_ob == "Medium" ? size.small : text_size_ob == "Large" ? size.normal : text_size_ob == "Medium2" ? size.normal : text_size_ob == "Large2" ? size.large : size.huge
ob_text_color_1 = input.color(#787b86 , '', inline = 'ob1_t', group = 'Order Blocks')
volume_text = input.bool(true, 'Volume', group='Order Blocks',inline = 'ob1_t')
percent_text = input.bool(true, 'Percentage', group='Order Blocks',inline = 'ob1_t')
show_line_ob = input.string("On", title = "Mid Line", options= , group='Order Blocks',inline='ob1_l')
show_line_ob_1=show_line_ob=="On"?true:false
line_style_ob = input.string("Solid", title = "Line Style", options= , group='Order Blocks',inline='ob1_l')
line_style_ob_1 = line_style_ob=="Solid" ? line.style_solid : line_style_ob=="Dashed" ? line.style_dashed : line.style_dotted
show_order_blocks_mtf=input.bool(false,"MTF Order Blocks",group = 'Order Blocks', inline = "m_ob1")
ibull_ob_css_2 = input.color(#5d606b19, '', inline = 'm_ob1', group = 'Order Blocks')
ibear_ob_css_2 = input.color(#5d606b19, '', inline = 'm_ob1', group = 'Order Blocks')
ob_type__mtf= input.string('All', '',options = , group = 'Order Blocks',inline = 'm_ob1')
i_tf_ob_mtf = input.timeframe("240", "Timeframe", group = 'Order Blocks', inline = "mob2")
mittigation_filt_mtf= input.string('Wicks', "Mitigation Method",options = , group = 'Order Blocks',inline = 'mob3')
overlapping_filt_mtf= input(true, 'Hide Overlap', inline = 'mob3', group = 'Order Blocks')
max_obs_mtf = input.int(4, 'Max OBs', minval = 3, group = 'Order Blocks', inline = "mob4")
length_extend_ob_mtf = input.int(defval = 20,title = "Length", minval = 0, maxval = 500 ,group = 'Order Blocks', inline = "mob4")
ob_extend_mtf = input.bool(false,"Extend",group = 'Order Blocks', inline = "mob4")
v_filter = input.bool(true, 'Internal Bull/Bear Activity', group='Order Blocks',inline = 'volume')
text_size_ob2 =input.string("Medium", options= , title="Text Size",inline="ob2_t", group="Order Blocks")
text_size_ob_2 = text_size_ob2 == "Small" ? size.tiny : text_size_ob2 == "Medium" ? size.small : text_size_ob2== "Large" ? size.normal : text_size_ob2 == "Medium2" ? size.normal : text_size_ob2 == "Large2" ? size.large : size.huge
ob_text_color_2 = input.color(#787b86 , '', inline = 'ob2_t', group = 'Order Blocks')
volume_text_2 = input.bool(true, 'Volume', group='Order Blocks',inline = 'ob2_t')
percent_text_2 = input.bool(true, 'Percentage', group='Order Blocks',inline = 'ob2_t')
show_line_ob2 = input.string("On", title = "Mid Line", options= , group='Order Blocks',inline='ob2_l')
show_line_ob_2=show_line_ob2=="On"?true:false
line_style_ob2 = input.string("Solid", title = "Line Style", options= , group='Order Blocks',inline='ob2_l')
line_style_ob_2 = line_style_ob2=="Solid" ? line.style_solid : line_style_ob2=="Dashed" ? line.style_dashed : line.style_dotted
v_buy = #00dbff4d
v_sell = #e91e634d
tf_s1=i_tf_ob_mtf==''?timeframe.period:i_tf_ob_mtf
timeframe_st=not(str.contains(tf_s1,'S')) and not(str.contains(tf_s1,'D')) and not(str.contains(tf_s1,'W')) and not(str.contains(tf_s1,'M')) ? str.tonumber(tf_s1)>=60? str.tostring(str.tonumber(tf_s1)/60) +"H": tf_s1 +"M" : tf_s1
timeframe1=timeframe_st + ' : '
show_iob = ob_type__=='All' or ob_type__=='Internal' //input(true, 'Internal', inline = 'ob', group = 'Order Blocks')
show_ob = ob_type__=='All' or ob_type__=='External' //input(false, 'External', inline = 'ob', group = 'Order Blocks')
show_iob_mtf = ob_type__mtf=='All' or ob_type__mtf=='Internal' //input(true, 'Internal', inline = 'ob', group = 'Order Blocks')
show_ob_mtf = ob_type__mtf=='All' or ob_type__mtf=='External' //input(false, 'External', inline = 'ob', group = 'Order Blocks')
ob_showlast = 5//input.int(10, 'LookBack', minval = 1, inline = 'ob', group = 'Order Blocks')
iob_showlast = 5//input.int(5, 'LookBack', minval = 1, inline = 'iob', group = 'Order Blocks')
max_width_ob = 3//input.float(3, 'Max OB Width', minval = 0.1,maxval = 3, inline = 'close', group = 'Order Blocks')
max_width_ob:=max_width_ob==3?20:max_width_ob
style = 'Colored'
v_lookback= 10
ob_loockback=10
timediff=(time -time )/100
//----------------------------------------}
//BOS and MSS
//----------------------------------------{
// Constants
color CLEAR = color.rgb(0,0,0,100)
// Inputs
showms=input(true,title="Market Structure ",inline="0",group = "Market Structure")
bosColor1 = input.color(#787b86 , '', group="Market Structure",inline="0")
bosColor2 = input.color(#787b86 , '', group="Market Structure",inline="0")
ms_type =input.string("All", options= , title="", group="Market Structure",inline="0")
show_equal_highlow = input(false, 'Equal Highs & Lows', group = 'Market Structure',inline = 'equilibrium_zone')
eq_bear_color = input.color(#787b86 , '', group="Market Structure",inline="equilibrium_zone")
eq_bull_color = input.color(#787b86 , '', group="Market Structure",inline="equilibrium_zone")
eq_threshold = input.float(0.3, '', minval = 0, maxval = 0.5, step = 0.1, group = 'Market Structure',inline = 'equilibrium_zone')
showSwing = input.bool(false, 'Swing Points', group="Market Structure",inline="3")
swingSize_swing = input.int(10, "Swing Point Period",inline="4", group="Market Structure")
label_sizes_s =input.string("Medium", options= , title="Label Size",inline="4", group="Market Structure")
label_size_buysell_s = label_sizes_s == "Small" ? size.tiny : label_sizes_s == "Medium" ? size.small : label_sizes_s == "Large" ? size.normal : label_sizes_s == "Medium2" ? size.normal : label_sizes_s == "Large2" ? size.large : size.huge
label_size_buysell = label_sizes_s == "Small" ? size.tiny : label_sizes_s == "Medium" ? size.small : label_sizes_s == "Large" ? size.normal : label_sizes_s == "Medium2" ? size.normal : label_sizes_s == "Large2" ? size.large : size.huge
swingColor = input.color(#787b86 , '', group="Market Structure",inline="3")
swingSize = 3
length_eqh = 3
//----------------------------------------}
//Fair Value Gaps (FVG
//----------------------------------------{
show_fvg = input(true, 'Fair Value Gaps (FVG)', group = 'Fair Value Gaps', inline = 'fvg_css')
i_tf = input.timeframe("", "Timeframe", group = 'Fair Value Gaps',inline = 'tf')
max_width_fvg = input.float(1.5, 'Max Width', minval = 0, maxval = 5.0, step = 0.1, group = 'Fair Value Gaps',inline = 'width')
remove_small = input.bool(true,"Filter FVG",group = 'Fair Value Gaps', inline = "width")
mittigation_filt_fvg= input.string('Touch', 'Mitigation Method',options = , group = 'Fair Value Gaps', inline = "mt")
fvg_color_fill = input.bool(true,"Fill",group = 'Fair Value Gaps', inline = "mt")
fvg_shade_fill = input.bool(false,"Shade",group = 'Fair Value Gaps', inline = "mt")
max_fvg = input.int(defval = 4,title = "Max FVG", minval = 0, maxval = 50 ,group = 'Fair Value Gaps', inline = "OS")
length_extend = input.int(defval = 20,title = "Length", minval = 0, maxval = 100 ,group = 'Fair Value Gaps', inline = "OS")
fvg_extend = input.bool(false,"Extend",group = 'Fair Value Gaps', inline = "OS")
i_mtfbearishfvgcolor = input.color(#2962ff , "", group = 'Fair Value Gaps', inline = "fvg_css")
i_mtfbullishfvgcolor = input.color(#c2185b, "", group = 'Fair Value Gaps', inline = "fvg_css")
mid_style = input.string('Solid', ' Style', , group="Fair Value Gaps",inline="mid")
i_midPointColor = input.color(#787b86, "", group = 'Fair Value Gaps',inline="mid")
fvg_extend_B = input.bool(true,"Extend (Current)",group = 'Fair Value Gaps', inline = "mid")
i_bullishfvgcolor = color.new(color.green,100)
i_bearishfvgcolor = color.new(color.green,90)
i_fillByMid = true
i_deleteonfill = true
i_textColor = color.white
i_mtf = "HTF"
i_tfos = 10
i_mtfos = 50
//----------------------------------------}
//Liquidity Levels
//----------------------------------------{
liquidity_level_group = "Liquidity Levels"
currentTF = input.bool(true, title = "Liquidity Levels", group=liquidity_level_group, inline="1")
htfTF = input.timeframe("", title = "Timeframe", inline="1_",group=liquidity_level_group)
leftBars = input.int(8, title = "Pivot Length", group=liquidity_level_group, inline="2")
mitiOptions = input.string("Remove", title = "Mitigated", inline="3", options= , group=liquidity_level_group)
_candleType = input.string("Close", title = "Method", options= , group=liquidity_level_group,inline = '3')
displayLimit = input.int(6, title = "Max Levels", group=liquidity_level_group, inline="4")
length_extend_liq = input.int(defval = 20,title = "Length", minval = 0, maxval = 500 ,group = liquidity_level_group, inline = "4")
extentionMax = input.bool(false, title = "Extend", group=liquidity_level_group, inline="4")
_highLineStyleHTF = "Solid"//input.string("Solid", title = "Line Style", options= , group=liquidity_level_group,inline='5')
highLineStyleHTF = _highLineStyleHTF=="Solid" ? line.style_solid : _highLineStyleHTF=="Dashed" ? line.style_dashed : line.style_dotted
box_width = 2.5//input.float(3.0, title = "Width", group=liquidity_level_group,inline='5', minval = 1, maxval = 10, step = 0.5)
lineWidthHTF=2
lowLineColorHTF = input.color(#00bbf94d, "", group = liquidity_level_group, inline = "1")
highLineColorHTF = input.color(#e91e624d, "", group = liquidity_level_group, inline = "1")
liquidity_text_color = input.color(#ffffff , 'Text Color', inline = '5', group = liquidity_level_group)
highBoxBorderColorHTF = color.new(highLineColorHTF,90)
lowBoxBorderColorHTF = color.new(lowLineColorHTF,90)
displayStyle_liq = "Boxes"//'Lines'
//----------------------------------------}
//Key Levels
//----------------------------------------{
var Show_4H_Levels = input.bool(defval=false, title='4H', group='Key Levels', inline='4H')
Color_4H_Levels = input.color(title='', defval=color.orange, group='Key Levels', inline='4H')
Style_4H_Levels = input.string('Dotted', ' Style', , group="Key Levels",inline="4H")
Text_4H_Levels = input.bool(defval=false, title='Shorten', group='Key Levels', inline='4H')
var Show_Daily_Levels = input.bool(defval=false, title='Daily', group='Key Levels', inline='Daily')
Color_Daily_Levels = input.color(title='', defval=#08bcd4, group='Key Levels', inline='Daily')
Style_Daily_Levels = input.string('Dotted', ' Style', , group="Key Levels",inline="Daily")
Text_Daily_Levels = input.bool(defval=false, title='Shorten', group='Key Levels', inline='Daily')
var Show_Monday_Levels = input.bool(defval=false, title='Monday', group='Key Levels', inline='Monday')
Color_Monday_Levels = input.color(title='', defval=color.white, group='Key Levels', inline='Monday')
Style_Monday_Levels = input.string('Dotted', ' Style', , group="Key Levels",inline="Monday")
Text_Monday_Levels = input.bool(defval=false, title='Shorten', group='Key Levels', inline='Monday')
var Show_Weekly_Levels = input.bool(defval=false, title='Weekly', group='Key Levels', inline='Weekly')
WeeklyColor = input.color(title='', defval=#fffcbc, group='Key Levels', inline='Weekly')
Weekly_style = input.string('Dotted', ' Style', , group="Key Levels",inline="Weekly")
WeeklyTextType = input.bool(defval=false, title='Shorten', group='Key Levels', inline='Weekly')
var Show_Monthly_Levels = input.bool(defval=false, title='Monthly', group='Key Levels', inline='Monthly')
MonthlyColor = input.color(title='', defval=#098c30, group='Key Levels', inline='Monthly')
Monthly_style = input.string('Dotted', ' Style', , group="Key Levels",inline="Monthly")
MonthlyTextType = input.bool(defval=false, title='Shorten', group='Key Levels', inline='Monthly')
var Show_Quaterly_Levels = input.bool(defval=false, title='Quarterly', group='Key Levels', inline='Quarterly')
quarterlyColor = input.color(title='', defval=#bcffd0, group='Key Levels', inline='Quarterly')
Quaterly_style = input.string('Dotted', ' Style', , group="Key Levels",inline="Quarterly")
QuarterlyTextType = input.bool(defval=false, title='Shorten', group='Key Levels', inline='Quarterly')
var Show_Yearly_Levels = input.bool(defval=false, title='Yearly', group='Key Levels', inline='Yearly')
YearlyColor = input.color(title='', defval=#ffbcdb, group='Key Levels', inline='Yearly')
Yearly_style = input.string('Dotted', ' Style', , group="Key Levels",inline="Yearly")
YearlyTextType = input.bool(defval=false, title='Shorten', group='Key Levels', inline='Yearly')
labelsize = input.string(defval='Medium', title='Text Size', options= ,group = "Key Levels", inline='H')
var pdhtext = Text_Daily_Levels ? 'PDH' : 'Prev Day High'
var pdltext = Text_Daily_Levels ? 'PDL' : 'Prev Day Low'
var dotext = Text_Daily_Levels ? 'DO' : 'Daily Open'
var pdmtext = Text_Daily_Levels ? 'PDM' : 'Prev Day Mid'
var pwhtext = WeeklyTextType ? 'PWH' : 'Prev Week High'
var pwltext = WeeklyTextType ? 'PWL' : 'Prev Week Low'
var wotext = WeeklyTextType ? 'WO' : 'Weekly Open'
var pwmtext = WeeklyTextType ? 'PWM' : 'Prev Week Mid'
var pmhtext = MonthlyTextType ? 'PMH' : 'Prev Month High'
var pmltext = MonthlyTextType ? 'PML' : 'Prev Month Low'
var motext = MonthlyTextType ? 'MO' : 'Monthly Open'
var pmmtext = MonthlyTextType ? 'PMM' : 'Prev Month Mid'
var pqhtext = QuarterlyTextType ? 'PQH' : 'Prev Quarter High'
var pqltext = QuarterlyTextType ? 'PQL' : 'Prev Quarter Low'
var qotext = QuarterlyTextType ? 'QO' : 'Quarterly Open'
var pqmtext = QuarterlyTextType ? 'PQM' : 'Prev Quarter Mid'
var cyhtext = YearlyTextType ? 'CYH' : 'Current Year High'
var cyltext = YearlyTextType ? 'CYL' : 'Current Year Low'
var yotext = YearlyTextType ? 'YO' : 'Yearly Open'
var cymtext = YearlyTextType ? 'CYM' : 'Current Year Mid'
var pihtext = Text_4H_Levels ? 'P-4H-H' : 'Prev 4H High'
var piltext = Text_4H_Levels ? 'P-4H-L' : 'Prev 4H Low'
var iotext = Text_4H_Levels ? '4H-O' : '4H Open'
var pimtext = Text_4H_Levels ? 'P-4H-M' : 'Prev 4H Mid'
var pmonhtext = Text_Monday_Levels ? 'MDAY-H' : 'Monday High'
var pmonltext = Text_Monday_Levels ? 'MDAY-L' : 'Monday Low'
var pmonmtext = Text_Monday_Levels ? 'MDAY-M' : 'Monday Mid'
displayStyle = 'Standard'
distanceright = 25
radistance = 250
linesize = 'Small'
linestyle = 'Solid'
var untested_monday = false
//----------------------------------------}
//Session Levels
//----------------------------------------{
var is_londonrange_enabled = input.bool(defval=false, title='London', group='Session Levels', inline='london')
var london_OC = input.bool(defval=true, title='O/C', group='Session Levels', inline='london')
var london_HL = input.bool(defval=true, title='H/L', group='Session Levels', inline='london')
var is_usrange_enabled = input.bool(defval=false, title='New York', group='Session Levels', inline='US')
var us_OC = input.bool(defval=true, title='O/C', group='Session Levels', inline='US')
var us_HL = input.bool(defval=true, title='H/L', group='Session Levels', inline='US')
var is_tokyorange_enabled = input.bool(defval=false, title='Tokyo', group='Session Levels', inline='asia')
var asia_OC = input.bool(defval=true, title='O/C', group='Session Levels', inline='asia')
var asia_HL = input.bool(defval=true, title='H/L', group='Session Levels', inline='asia')
SessionTextType = false//input.bool(defval=false, title='ShortHand', group='Sessions', inline='FXColor')
Londont = "0800-1600"
USt = "1400-2100"
Asiat = "0000-0900"
LondonColor = input.color(title='', defval=color.white, group='Session Levels', inline='london')
USColor = input.color(title='', defval=color.white, group='Session Levels', inline='US')
AsiaColor = input.color(title='', defval=color.white, group='Session Levels', inline='asia')
Short_text_London = input.bool(defval=false, title='Shorten', group='Session Levels', inline='london')
Short_text_NY = input.bool(defval=false, title='Shorten', group='Session Levels', inline='US')
Short_text_TKY = input.bool(defval=false, title='Shorten', group='Session Levels', inline='asia')
var London_high_text = Short_text_London ? 'Lon-H' : 'London High'
var London_low_text = Short_text_London ? 'Lon-L' : 'London Low'
var London_open_text = Short_text_London ? 'Lon-O' : 'London Open'
var NY_high_text = Short_text_NY ? 'NY-H' : 'New York High'
var NY_low_text = Short_text_NY ? 'NY-L' : 'New York Low'
var NY_open_text = Short_text_NY ? 'NY-O' : 'New York Open'
var Tokyo_high_text = Short_text_TKY ? 'TK-H' : 'Tokyo High'
var Tokyo_low_text = Short_text_TKY ? 'TK-L' : 'Tokyo Low'
var Tokyo_open_text = Short_text_TKY ? 'TK-O' : 'Tokyo Open'
//-----------------------------------------------------------------------------}
//Global variables
//-----------------------------------------------------------------------------{
color transparent = #ffffff00
length = 50
is_newbar(res) =>
t = time(res)
not na(t) and (na(t ) or t > t )
Show_MS(x, y, txt, css, dashed, down, lbl_size)=>
label.new(int(math.avg(x, bar_index)), y, txt, color = transparent, textcolor = css, style = down ? label.style_label_down : label.style_label_up, size = lbl_size)
line.new(x, y, bar_index, y, color = css, style = dashed ? line.style_dashed : line.style_solid)
f_barssince(_cond, _count) =>
_barssince = bar_index - ta.valuewhen(_cond, bar_index, _count)
_barssince
//Swings detection/measurements
calculate_swing_points(length)=>
var prev = 0
prev := high > ta.highest(length) ? 0 : low < ta.lowest(length) ? 1 : prev
t = prev == 0 and prev != 0 ? high : 0
b = prev == 1 and prev != 1 ? low : 0
var t_MS = 0, var int_t_MS = 0
var internal_y_up = 0., var internal_x_up = 0, var internal_y_dn = 0., var internal_x_dn = 0
var y_up = 0., var x_up = 0 , var y_dn = 0., var x_dn = 0
var crossed_up = true, var crossed_down = true
var internal_up_broke = true, var internal_dn_broke = true
var up_trailing = high, var down_trailing = low
var up_trailing_x = 0, var down_trailing_x = 0
var high_text = '', var low_text = ''
bullish_OB_Break = false
bearish_OB_Break = false
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------- Market Structure
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bosConfType = 'Candle High'//input.string('Candle Close', 'BOS Confirmation', , tooltip='Choose whether candle close/wick above previous swing point counts as a BOS.')
MSS = true//input.bool(false, 'Show MSS', tooltip='Renames the first counter t_MS BOS to MSS' )
// showSwing = false//input.bool(true, 'Show Swing Points', tooltip='Show or hide HH, LH, HL, LL')
// Functions
lineStyle(x) =>
switch x
'Solid' => line.style_solid
'Dashed' => line.style_dashed
'Dotted' => line.style_dotted
pivot_high_found = ta.pivothigh(high, swingSize_swing, swingSize_swing)
pivot_low_found = ta.pivotlow(low, swingSize_swing, swingSize_swing)
var float prevHigh_s = na,var float prevLow_s = na,var int prevHighIndex_s = na,var int prevLowIndex_s = na
bool higher_highs = false, bool lower_highs = false, bool higher_lows = false, bool lower_lows = false
var int prevSwing_s = 0
if not na(pivot_high_found)
if pivot_high_found >= prevHigh_s
higher_highs := true
prevSwing_s := 2
else
lower_highs := true
prevSwing_s := 1
prevHigh_s := pivot_high_found
prevHighIndex_s := bar_index - swingSize_swing
if not na(pivot_low_found)
if pivot_low_found >= prevLow_s
higher_lows := true
prevSwing_s := -1
else
lower_lows := true
prevSwing_s := -2
prevLow_s := pivot_low_found
prevLowIndex_s := bar_index - swingSize_swing
if higher_highs and showSwing
label.new(bar_index - swingSize_swing, pivot_high_found, 'HH', color=CLEAR, style=label.style_label_down, textcolor=swingColor,size = label_size_buysell_s)
if lower_highs and showSwing
label.new(bar_index - swingSize_swing, pivot_high_found, 'LH', color=CLEAR, style=label.style_label_down, textcolor=swingColor,size = label_size_buysell_s)
if higher_lows and showSwing
label.new(bar_index - swingSize_swing, pivot_low_found, 'HL', color=CLEAR, style=label.style_label_up, textcolor=swingColor,size = label_size_buysell_s)
if lower_lows and showSwing
label.new(bar_index - swingSize_swing, pivot_low_found, 'LL', color=CLEAR, style=label.style_label_up, textcolor=swingColor,size = label_size_buysell_s)
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------- Fair Value Gaps
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// }
// ———————————————————— Global data {
//Using current bar data for HTF highs and lows instead of security to prevent future leaking
var htfH = open
var htfL = open
if close > htfH
htfH:= close
if close < htfL
htfL := close
//Security Data, used for HTF Bar Data reference
sClose = request.security(ticker.standard(syminfo.tickerid), i_tf, close , barmerge.gaps_off, barmerge.lookahead_on)
sHighP2 = request.security(ticker.standard(syminfo.tickerid), i_tf, high , barmerge.gaps_off, barmerge.lookahead_on)
sLowP2 = request.security(ticker.standard(syminfo.tickerid), i_tf, low , barmerge.gaps_off, barmerge.lookahead_on)
sOpen = request.security(ticker.standard(syminfo.tickerid), i_tf, open , barmerge.gaps_off, barmerge.lookahead_on)
sBar = request.security(ticker.standard(syminfo.tickerid), i_tf, bar_index, barmerge.gaps_off, barmerge.lookahead_on)
// }
//var keyword can be used to hold data in memory, with pinescript all data is lost including variables unless the var keyword is used to preserve this data
var bullishgapholder = array.new_box(0)
var bearishgapholder = array.new_box(0)
var bullishgapholder_fill = array.new_box(0)
var bearishgapholder_fill = array.new_box(0)
var bullish_high_holder = array.new_line(0)
var bearish_high_holder = array.new_line(0)
var bullish_low_holder = array.new_line(0)
var bearish_low_holder = array.new_line(0)
var bullishmidholder = array.new_line(0)
var bearishmidholder = array.new_line(0)
var bullishlabelholder = array.new_label(0)
var bearishlabelholder = array.new_label(0)
var transparentcolor = color.new(color.white,100)
var fvg_apper=false
var fvg_break=false
fvg_apper:=false
fvg_break:=false
// ———————————————————— Functions {
//function paramaters best declared with '_' this helps defer from variables in the function scope declaration and elsewhere e.g. close => _close
create_fvg_func(_upperlimit,_lowerlimit,_midlimit,_bar,_boxholder,_boxholder_fill,_midholder,_highholder,_lowholder,_labelholder,_boxcolor,_mtfboxcolor, _htf)=>
timeholder = str.tostring(i_tf)
offset = i_mtfos
boxbgcolor = _mtfboxcolor
bg_color = color.new(_mtfboxcolor,90)
if _htf == false
timeholder := str.tostring(timeframe.period)
offset := i_tfos
boxbgcolor := _boxcolor
array.push(_boxholder,box.new(_bar,_upperlimit,_bar+(timediff)*length_extend,_lowerlimit,border_color=fvg_color_fill? bg_color : na,bgcolor = fvg_color_fill? bg_color : na, extend = fvg_extend ? extend.right:extend.none,xloc = xloc.bar_time,text='',text_color=#787b86,text_halign=text.align_right,text_size=size.small))
array.push(_boxholder_fill,box.new(_bar,_upperlimit,_bar+(timediff)*length_extend,_lowerlimit,border_color=fvg_color_fill? bg_color : na ,bgcolor = fvg_color_fill? bg_color : na, extend = fvg_extend ? extend.right:extend.none,xloc = xloc.bar_time))
array.push(_midholder,line.new(_bar,(_lowerlimit+_upperlimit)/2.0,_bar+(timediff)*length_extend,_midlimit,color = i_midPointColor, extend = fvg_extend ? extend.right:extend.none,style=lineStyle(mid_style),width=1,xloc = xloc.bar_time))
array.push(_lowholder,line.new(_bar,_lowerlimit,_bar+(timediff)*length_extend,_lowerlimit,color = i_fillByMid?boxbgcolor:na, extend = fvg_extend ? extend.right:extend.none,width=1,xloc = xloc.bar_time))
array.push(_highholder,line.new(_bar,_upperlimit,_bar+(timediff)*length_extend,_upperlimit,color = i_fillByMid?boxbgcolor:na, extend = fvg_extend ? extend.right:extend.none,width=1,xloc = xloc.bar_time))
//checks for gap between current candle and 2 previous candle e.g. low of current candle and high of the candle before last, this is the fair value gap.
check_fvg_func(_close,_high,_highp2,_low,_lowp2,_open,_bar,_htf)=>
gap=0
thold_ = (ta.highest(_high,300) - ta.lowest(_low,300)) * math.max(max_width_fvg, 0.1) / 100.
if _open > _close // red
if _lowp2>_high
if not(remove_small) or math.abs(_lowp2 -_high) > thold_
upperlimit = _high//_close - (_close - _lowp2 )
lowerlimit = _lowp2//_close - (_close-_high)
midlimit = lowerlimit + ((upperlimit - lowerlimit) / 2.)
gap:=1
create_fvg_func(upperlimit,lowerlimit,midlimit,_bar,bullishgapholder,bullishgapholder_fill,bullishmidholder,bullish_high_holder,bullish_low_holder,bullishlabelholder,i_bullishfvgcolor,i_mtfbullishfvgcolor,_htf)
else
if _low>_highp2
if not(remove_small) or math.abs(_low - _highp2) > thold_
upperlimit = _low//_close - (_close-_low)
lowerlimit = _highp2//_close- (_close - _highp2),
midlimit = lowerlimit + ((upperlimit - lowerlimit) / 2.)
gap:=-1
create_fvg_func(upperlimit,lowerlimit,midlimit,_bar,bearishgapholder,bearishgapholder_fill,bearishmidholder,bearish_high_holder,bearish_low_holder,bearishlabelholder,i_bearishfvgcolor,i_mtfbearishfvgcolor,_htf)
gap
//Used to remove the gap from its relevant array as a result of it being filled.
delete_fvg_func(_currentgap,_currentgap_fill,_i,_boxholder,_boxholder_fill,_midholder,_highholder,_lowholder,_labelholder)=>
array.remove(_boxholder,_i)
array.remove(_boxholder_fill,_i)
currentmid=array.get(_midholder,_i)
currenthigh=array.get(_highholder,_i)
currentlow=array.get(_lowholder,_i)
array.remove(_midholder,_i)
array.remove(_highholder,_i)
array.remove(_lowholder,_i)
if i_deleteonfill
line.delete(currentmid)
line.delete(currenthigh)
line.delete(currentlow)
else
line.set_extend(currentmid, extend.none)
line.set_x2(currentmid,time)
line.set_extend(currenthigh, extend.none)
line.set_x2(currenthigh,time)
line.set_extend(currentlow, extend.none)
line.set_x2(currentlow,time)
if i_deleteonfill
box.delete(_currentgap)
box.delete(_currentgap_fill)
else
box.set_extend(_currentgap,extend.none)
box.set_right(_currentgap,time)
//checks if gap has been filled either by 0.5 fill (i_fillByMid) or SHRINKS the gap to reflect the true value gap left.
validate_fvg_func(_high,_low)=>
fvg_removed=0
if array.size(bullishgapholder) > 0
for i = array.size(bullishgapholder)-1 to 0
if fvg_extend_B
currentgap_fill = array.get(bullishgapholder_fill,i)
currentgap = array.get(bullishgapholder,i)
cmid = array.get(bullishmidholder,i)
chigh = array.get(bullish_high_holder,i)
clow = array.get(bullish_low_holder,i)
line.set_x2(cmid,timenow+(timediff)*length_extend)
line.set_x2(chigh,timenow+(timediff)*length_extend)
line.set_x2(clow,timenow+(timediff)*length_extend)
box.set_right(currentgap_fill,timenow+(timediff)*length_extend)
box.set_right(currentgap,timenow+(timediff)*length_extend)
if mittigation_filt_fvg=='Touch'
currentgap_fill = array.get(bullishgapholder_fill,i)
currentgap = array.get(bullishgapholder,i)
currentmid = array.get(bullishmidholder,i)
currenthigh = array.get(bullish_high_holder,i)
currentlow = array.get(bullish_low_holder,i)
currenttop = box.get_top(currentgap)
if high > currenttop
fvg_removed:=1
delete_fvg_func(currentgap,currentgap_fill,i,bullishgapholder,bullishgapholder_fill,bullishmidholder,bullish_high_holder,bullish_low_holder,bullishlabelholder)
if mittigation_filt_fvg=='Wicks'
currentgap_fill = array.get(bullishgapholder_fill,i)
currentgap = array.get(bullishgapholder,i)
currentmid = array.get(bullishmidholder,i)
currenthigh = array.get(bullish_high_holder,i)
currentlow = array.get(bullish_low_holder,i)
currenttop = box.get_bottom(currentgap)
currentbottom = box.get_top(currentgap_fill)
if high > currentbottom and fvg_shade_fill
currentgap_f = array.get(bullishgapholder_fill,i)
cur_bottom=box.get_bottom(currentgap_f)
_bottom=box.get_bottom(currentgap)
if _bottom==cur_bottom
box.set_bottom(currentgap_f,high)
else
box.set_bottom(currentgap_f,math.max(cur_bottom,high))
box.set_bgcolor(currentgap_f,#787b865e)
if high > currenttop
fvg_removed:=1
delete_fvg_func(currentgap,currentgap_fill,i,bullishgapholder,bullishgapholder_fill,bullishmidholder,bullish_high_holder,bullish_low_holder,bullishlabelholder)
if mittigation_filt_fvg=='Close'
currentgap_fill = array.get(bullishgapholder_fill,i)
currentgap = array.get(bullishgapholder,i)
currentmid = array.get(bullishmidholder,i)
currenthigh = array.get(bullish_high_holder,i)
currentlow = array.get(bullish_low_holder,i)
currenttop = box.get_bottom(currentgap)
currentbottom = box.get_top(currentgap_fill)
if high > currentbottom and fvg_shade_fill
currentgap_f = array.get(bullishgapholder_fill,i)
cur_bottom=box.get_bottom(currentgap_f)
_bottom=box.get_bottom(currentgap)
if _bottom==cur_bottom
box.set_bottom(currentgap_f,high)
else
box.set_bottom(currentgap_f,math.max(cur_bottom,high))
box.set_bgcolor(currentgap_f,#787b865e)
if close > currenttop
fvg_removed:=1
delete_fvg_func(currentgap,currentgap_fill,i,bullishgapholder,bullishgapholder_fill,bullishmidholder,bullish_high_holder,bullish_low_holder,bullishlabelholder)
if mittigation_filt_fvg=='Average'
currentgap_fill = array.get(bullishgapholder_fill,i)
currentgap = array.get(bullishgapholder,i)
currentmid = array.get(bullishmidholder,i)
currenthigh = array.get(bullish_high_holder,i)
currentlow = array.get(bullish_low_holder,i)
currenttop = line.get_y1(currentmid)
currentbottom = box.get_top(currentgap_fill)
if high > currentbottom and fvg_shade_fill
currentgap_f = array.get(bullishgapholder_fill,i)
cur_bottom=box.get_bottom(currentgap_f)
_bottom=box.get_bottom(currentgap)
if _bottom==cur_bottom
box.set_bottom(currentgap_f,high)
else
box.set_bottom(currentgap_f,math.max(cur_bottom,high))
box.set_bgcolor(currentgap_f,#787b865e)
if high > currenttop
fvg_removed:=1
delete_fvg_func(currentgap,currentgap_fill,i,bullishgapholder,bullishgapholder_fill,bullishmidholder,bullish_high_holder,bullish_low_holder,bullishlabelholder)
if array.size(bearishgapholder) > 0
for i = array.size(bearishgapholder)-1 to 0
if fvg_extend_B
currentgap_fill = array.get(bearishgapholder_fill,i)
currentgap = array.get(bearishgapholder,i)
cmid = array.get(bearishmidholder,i)
chigh = array.get(bearish_high_holder,i)
clow = array.get(bearish_low_holder,i)
line.set_x2(cmid,timenow+(timediff)*length_extend)
line.set_x2(chigh,timenow+(timediff)*length_extend)
line.set_x2(clow,timenow+(timediff)*length_extend)
box.set_right(currentgap_fill,timenow+(timediff)*length_extend)
box.set_right(currentgap,timenow+(timediff)*length_extend)
if mittigation_filt_fvg=='Touch'
currentgap_fill = array.get(bearishgapholder_fill,i)
currentgap = array.get(bearishgapholder,i)
currenttop = box.get_top(currentgap)
currentmid = array.get(bearishmidholder,i)
currenthigh = array.get(bearish_high_holder,i)
currentlow = array.get(bearish_low_holder,i)
if low < currenttop
fvg_removed:=-1
delete_fvg_func(currentgap,currentgap_fill,i,bearishgapholder,bearishgapholder_fill,bearishmidholder,bearish_high_holder,bearish_low_holder,bearishlabelholder)
if mittigation_filt_fvg=='Wicks'
currentgap_fill = array.get(bearishgapholder_fill,i)
currentgap = array.get(bearishgapholder,i)
currenttop = box.get_bottom(currentgap)
currentmid = array.get(bearishmidholder,i)
currenthigh = array.get(bearish_high_holder,i)
currentlow = array.get(bearish_low_holder,i)
currentbottom = box.get_top(currentgap_fill)
if low < currentbottom and fvg_shade_fill
currentgap_f = array.get(bearishgapholder_fill,i)
cur_bottom=box.get_bottom(currentgap_f)
_bottom=box.get_bottom(currentgap)
if _bottom==cur_bottom
box.set_bottom(currentgap_f,low)
else
box.set_bottom(currentgap_f,math.min(cur_bottom,low))
box.set_bgcolor(currentgap_f,#787b865e)
if low < currenttop
fvg_removed:=-1
delete_fvg_func(currentgap,currentgap_fill,i,bearishgapholder,bearishgapholder_fill,bearishmidholder,bearish_high_holder,bearish_low_holder,bearishlabelholder)
if mittigation_filt_fvg=='Close'
currentgap_fill = array.get(bearishgapholder_fill,i)
currentgap = array.get(bearishgapholder,i)
currenttop = box.get_bottom(currentgap)
currentmid = array.get(bearishmidholder,i)
currenthigh = array.get(bearish_high_holder,i)
currentlow = array.get(bearish_low_holder,i)
currentbottom = box.get_top(currentgap_fill)
if low < currentbottom and fvg_shade_fill
currentgap_f = array.get(bearishgapholder_fill,i)
cur_bottom=box.get_bottom(currentgap_f)
_bottom=box.get_bottom(currentgap)
if _bottom==cur_bottom
box.set_bottom(currentgap_f,low)
else
box.set_bottom(currentgap_f,math.min(cur_bottom,low))
box.set_bgcolor(currentgap_f,#787b865e)
if close < currenttop
fvg_removed:=-1
delete_fvg_func(currentgap,currentgap_fill,i,bearishgapholder,bearishgapholder_fill,bearishmidholder,bearish_high_holder,bearish_low_holder,bearishlabelholder)
if mittigation_filt_fvg=='Average'
currentgap_fill = array.get(bearishgapholder_fill,i)
currentgap = array.get(bearishgapholder,i)
currentmid = array.get(bearishmidholder,i)
currenttop = line.get_y1(currentmid)
currenthigh = array.get(bearish_high_holder,i)
currentlow = array.get(bearish_low_holder,i)
currentbottom = box.get_top(currentgap_fill)
if low < currentbottom and fvg_shade_fill
currentgap_f = array.get(bearishgapholder_fill,i)
cur_bottom=box.get_bottom(currentgap_f)
_bottom=box.get_bottom(currentgap)
if _bottom==cur_bottom
box.set_bottom(currentgap_f,low)
else
box.set_bottom(currentgap_f,math.min(cur_bottom,low))
box.set_bgcolor(currentgap_f,#787b865e)
if low < currenttop
fvg_removed:=-1
delete_fvg_func(currentgap,currentgap_fill,i,bearishgapholder,bearishgapholder_fill,bearishmidholder,bearish_high_holder,bearish_low_holder,bearishlabelholder)
fvg_removed
// pine provided function to determine a new bar
if is_newbar(i_tf)
htfH := high
htfL := low
// }
fvg_gap=0
// User Input, allow MTF data calculations
if is_newbar(i_tf) and (i_mtf == "Current + HTF" or i_mtf == "HTF") and show_fvg and barstate.isconfirmed
fvg_gap:=check_fvg_func(sClose,htfH,sHighP2,htfL,sLowP2,sOpen,time ,true)
alertcondition(fvg_gap==1,"Bullish FVG","Bullish FVG Found Ez-SMC")
alertcondition(fvg_gap==-1,"Bearish FVG","Bearish FVG Found Ez-SMC")
fvg_removed=validate_fvg_func(high,low)
alertcondition(fvg_removed==1,"Bullish FVG Break","Bullish FVG Broken Ez-SMC")
alertcondition(fvg_removed==-1,"Bearish FVG Break","Bearish FVG Broken Ez-SMC")
if array.size(bullishgapholder) > max_fvg
d_box=array.shift(bullishgapholder)
box.delete(d_box)
if array.size(bullishgapholder_fill) > max_fvg
d_box=array.shift(bullishgapholder_fill)
box.delete(d_box)
if array.size(bullishmidholder) > max_fvg
d_line=array.shift(bullishmidholder)
line.delete(d_line)
if array.size(bullish_high_holder) > max_fvg
d_line=array.shift(bullish_high_holder)
line.delete(d_line)
if array.size(bullish_low_holder) > max_fvg
d_line=array.shift(bullish_low_holder)
line.delete(d_line)
if array.size(bearishgapholder) > max_fvg
d_box_=array.shift(bearishgapholder)
box.delete(d_box_)
if array.size(bearishgapholder_fill) > max_fvg
d_box_=array.shift(bearishgapholder_fill)
box.delete(d_box_)
if array.size(bearishmidholder) > max_fvg
d_line_=array.shift(bearishmidholder)
line.delete(d_line_)
if array.size(bearish_high_holder) > max_fvg
d_line_=array.shift(bearish_high_holder)
line.delete(d_line_)
if array.size(bearish_low_holder) > max_fvg
d_line_=array.shift(bearish_low_holder)
line.delete(d_line_)
n=bar_index
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------- Liquidity Levels
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// --
highLineColor = highLineColorHTF//input.color(#1f4ef5, "High Line ", group = liquidity_level_group, inline = "1")
lowLineColor = lowLineColorHTF//input.color(#fd441c, "Low Line", group = liquidity_level_group, inline = "1")
highBoxBgColor = highLineColorHTF//input.color(color.new(#1f4ef5, 80), "High Box Bg ", group = liquidity_level_group, inline = "2")
highBoxBorderColor = highBoxBorderColorHTF//input.color(color.new(#1f4ef5, 80), "Box Border", group = liquidity_level_group, inline = "2")
lowBoxBgColor = lowLineColorHTF//input.color(color.new(#fd441c, 80), "Low Box Bg ", group = liquidity_level_group, inline = "3")
lowBoxBorderColor = lowBoxBorderColorHTF//input.color(color.new(#fd441c, 80), "Box Border", group = liquidity_level_group, inline = "3")
atr_liq = ta.atr(300)
float thold_liq = atr_liq * (box_width / 10)
// --
// --
// --
// ----------------------------------------------------
// Functions
// ----------------------------------------------------
tf_multi(tf) =>
ts = timeframe.in_seconds("")
htfs = timeframe.in_seconds(tf)
htfs/ts
display_limit_line(_array) =>
if array.size(_array) > displayLimit/2
a = array.shift(_array)
line.delete(a)
display_limit_box(_array) =>
if array.size(_array) > displayLimit/2
a = array.shift(_array)
box.delete(a)
remove_mitigated_lines(_array, _hl) =>
m = false
if array.size(_array) > 0
for i = array.size(_array) - 1 to 0 by 1
l = array.get(_array, i)
hh = _candleType == "Close" ? close : high
ll = _candleType == "Close" ? close : low
if _hl == "High" and hh > line.get_y1(l)
array.remove(_array, i)
if mitiOptions == "Show"
line.new(line.get_x1(l),line.get_y1(l),time,line.get_y1(l), xloc=xloc.bar_time, color = highLineColorHTF, style=highLineStyleHTF, width = lineWidthHTF)
line.delete(l)
m := true
if _hl == "Low" and ll < line.get_y1(l)
array.remove(_array, i)
if mitiOptions == "Show"
line.new(line.get_x1(l),line.get_y1(l),time,line.get_y1(l), xloc=xloc.bar_time, color = lowLineColorHTF, style=highLineStyleHTF, width = lineWidthHTF)
line.delete(l)
m := true
display_limit_line(_array)
m
remove_mitigated_boxes(_array, _hl) =>
m = false
if array.size(_array) > 0
for i = array.size(_array) - 1 to 0 by 1
l = array.get(_array, i)
hh = _candleType == "Close" ? close : high
ll = _candleType == "Close" ? close : low
if _hl == "High" and hh > box.get_top(l)
array.remove(_array, i)
if mitiOptions == "Show"
box.new(box.get_left(l),box.get_top(l),time,box.get_bottom(l), xloc=xloc.bar_time, bgcolor = color.new(highBoxBgColor, 90), border_color = color.new(highBoxBorderColor, 90), border_style = highLineStyleHTF)
box.delete(l)
m := true
if _hl == "Low" and ll < box.get_top(l)
array.remove(_array, i)
if mitiOptions == "Show"
box.new(box.get_left(l),box.get_top(l),time,box.get_bottom(l), xloc=xloc.bar_time, bgcolor = color.new(lowBoxBgColor, 90), border_color = color.new(lowBoxBorderColor, 90), border_style = highLineStyleHTF)
box.delete(l)
m := true
display_limit_box(_array)
m
extend_line_to_current(lineArray) =>
if array.size(lineArray) > 0
for i = array.size(lineArray) - 1 to 0 by 1
l = array.get(lineArray, i)
timeExt = timenow + ((timediff)*length_extend_liq)
line.set_x2(l, timeExt)
extend_box_to_current(boxArray) =>
if array.size(boxArray) > 0
for i = array.size(boxArray) - 1 to 0 by 1
b = array.get(boxArray, i)
timeExt = timenow + ((timediff)*length_extend_liq)
box.set_right(b, timeExt)
// ----------------------------------------------------
// Higher TimeFrame
// ----------------------------------------------------
// Varibles
// Lines
var highLineArrayHTF = array.new_line()
var lowLineArrayHTF = array.new_line()
// Boxes
var highBoxArrayHTF = array.new_box()
var lowBoxArrayHTF = array.new_box()
// Get HTF
= request.security(syminfo.tickerid, htfTF, )
// Pivots
pivotHighHTF = ta.pivothigh(_high, leftBars*tf_multi(htfTF), leftBars+tf_multi(htfTF))
pivotLowHTF = ta.pivotlow(_low, leftBars*tf_multi(htfTF), leftBars+tf_multi(htfTF))
if currentTF
timeExt = time+((time -time )*10)
dis = leftBars+tf_multi(htfTF)
if pivotHighHTF
if displayStyle_liq == "Lines"
array.push(highLineArrayHTF, line.new(_time ,_high ,_time ,_high ,color = highLineColorHTF, style=highLineStyleHTF, xloc=xloc.bar_time, extend=extentionMax?extend.right:extend.none, width = lineWidthHTF))
else
y1 = _high -thold_liq//math.max(_open , _close )
array.push(highBoxArrayHTF, box.new(_time ,_high ,_time ,y1,bgcolor = highLineColorHTF, border_color=highBoxBorderColorHTF, xloc=xloc.bar_time, border_style = highLineStyleHTF, extend=extentionMax?extend.right:extend.none, border_width = lineWidthHTF,text="BUY SIDE $$$",text_halign = text.align_center,text_color = liquidity_text_color,text_size = size.small))
if pivotLowHTF
if displayStyle_liq == "Lines"
array.push(lowLineArrayHTF, line.new(_time ,_low ,_time ,_low ,color = lowLineColorHTF, style=highLineStyleHTF, xloc=xloc.bar_time, extend=extentionMax?extend.right:extend.none, width = lineWidthHTF))
else
y1 = _low +thold_liq//math.min(_open , _close )
array.push(lowBoxArrayHTF, box.new(_time ,_low ,_time ,y1,bgcolor = lowLineColorHTF, border_color=lowBoxBorderColorHTF, xloc=xloc.bar_time, border_style = highLineStyleHTF, extend=extentionMax?extend.right:extend.none, border_width = lineWidthHTF,text="SELL SIDE $$$",text_halign = text.align_center,text_color = liquidity_text_color,text_size = size.small))
// ----------------------------------------------------
// Run Functions
// ----------------------------------------------------
highLineAlertHTF = remove_mitigated_lines(highLineArrayHTF, "High")
lowLineAlertHTF = remove_mitigated_lines(lowLineArrayHTF, "Low")
highBoxAlertHTF = remove_mitigated_boxes(highBoxArrayHTF, "High")
lowBoxAlertHTF = remove_mitigated_boxes(lowBoxArrayHTF, "Low")
extend_line_to_current(highLineArrayHTF)
extend_line_to_current(lowLineArrayHTF)
extend_box_to_current(highBoxArrayHTF)
extend_box_to_current(lowBoxArrayHTF)
// Alerts
alertcondition(pivotHighHTF, "High Liquidity Level", "High Liquidity Level Found Ez-SMC")
alertcondition(pivotLowHTF, "Low Liquidity Level", "Low Liquidity Level Found Ez-SMC")
alertcondition(highLineAlertHTF or highBoxAlertHTF, "High Liquidity Level Break", "High Liquidity Level Broken Ez-SMC")
alertcondition(lowLineAlertHTF or lowBoxAlertHTF, "Low Liquidity Level Break", "Low Liquidity Level Broken Ez-SMC")
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------- Key Levels
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var monday_time = time
var monday_high = high
var monday_low = low
cdailyh_open = request.security(syminfo.tickerid, 'D', high, lookahead=barmerge.lookahead_on)
cdailyl_open = request.security(syminfo.tickerid, 'D', low, lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, 'D', , lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, 'D', [time , high ], lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, 'D', [time , low ], lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, 'W', , lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, 'W', [time , high ], lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, 'W', [time , low ], lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, 'M', , lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, 'M', [time , high ], lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, 'M', [time , low ], lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, '240', , lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, '240', [time , high ], lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, '240', [time , low ], lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, '3M', , lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, '3M', [time , high ], lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, '3M', [time , low ], lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, '12M', , lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, '12M', , lookahead=barmerge.lookahead_on)
= request.security(syminfo.tickerid, '12M', , lookahead=barmerge.lookahead_on)
if weekly_time != weekly_time
untested_monday := false
untested_monday
if Show_Monday_Levels == true and untested_monday == false
untested_monday := true
monday_time := daily_time
monday_high := cdailyh_open
monday_low := cdailyl_open
monday_low
linewidthint = 1
if linesize == 'Small'
linewidthint := 1
linewidthint
if linesize == 'Medium'
linewidthint := 2
linewidthint
if linesize == 'Large'
linewidthint := 3
linewidthint
var linewidth_def = linewidthint
fontsize = size.small
if labelsize == 'Small'
fontsize := size.small
fontsize
if labelsize == 'Medium'
fontsize := size.normal
fontsize
if labelsize == 'Large'
fontsize := size.large
fontsize
linestyles = line.style_solid
if linestyle == 'Dashed'
linestyles := line.style_dashed
linestyles
if linestyle == 'Dotted'
linestyles := line.style_dotted
linestyles
var DEFAULT_LABEL_SIZE = fontsize
var DEFAULT_LABEL_STYLE = label.style_none
var Rigth_Def = distanceright
var arr_price = array.new_float(0)
var arr_label = array.new_label(0)
Combine_Levels(arr_price, arr_label, currentprice, currentlabel, currentcolor) =>
if array.includes(arr_price, currentprice)
whichindex = array.indexof(arr_price, currentprice)
labelhold = array.get(arr_label, whichindex)
whichtext = label.get_text(labelhold)
label.set_text(labelhold, label.get_text(currentlabel) + ' / ' + whichtext)
label.set_text(currentlabel, '')
label.set_textcolor(labelhold, currentcolor)
else
array.push(arr_price, currentprice)
array.push(arr_label, currentlabel)
extend_to_current(bars) =>
timenow + (time - time ) * bars
if barstate.islast
arr_price := array.new_float(0)
arr_label := array.new_label(0)
if Show_4H_Levels
limit_4H_right = extend_to_current(Rigth_Def)
intrah_limit_right = extend_to_current(Rigth_Def)
intral_limit_right = extend_to_current(Rigth_Def)
var line_4H = line.new(x1=intra_time, x2=limit_4H_right, y1=intra_open, y2=intra_open, color=Color_4H_Levels, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Style_4H_Levels))
var label_4H = label.new(x=limit_4H_right, y=intra_open, text=iotext, style=DEFAULT_LABEL_STYLE, textcolor=Color_4H_Levels, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var intrah_line = line.new(x1=intrah_time, x2=intrah_limit_right, y1=intrah_open, y2=intrah_open, color=Color_4H_Levels, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Style_4H_Levels))
var intrah_label = label.new(x=intrah_limit_right, y=intrah_open, text=pihtext, style=DEFAULT_LABEL_STYLE, textcolor=Color_4H_Levels, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var intral_line = line.new(x1=intral_time, x2=intral_limit_right, y1=intral_open, y2=intral_open, color=Color_4H_Levels, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Style_4H_Levels))
var intral_label = label.new(x=intral_limit_right, y=intral_open, text=piltext, style=DEFAULT_LABEL_STYLE, textcolor=Color_4H_Levels, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
label.set_text(label_4H, iotext)
line.set_xy1(line_4H,intra_time,intra_open)
line.set_xy2(line_4H,limit_4H_right,intra_open)
label.set_xy(label_4H,limit_4H_right,intra_open)
line.set_xy1(intrah_line,intrah_time,intrah_open)
line.set_xy2(intrah_line,intrah_limit_right,intrah_open)
label.set_xy(intrah_label,intrah_limit_right,intrah_open)
label.set_text(intrah_label, pihtext)
line.set_x1(intral_line, intral_time)
line.set_x2(intral_line, intral_limit_right)
line.set_y1(intral_line, intral_open)
line.set_y2(intral_line, intral_open)
label.set_x(intral_label, intral_limit_right)
label.set_y(intral_label, intral_open)
label.set_text(intral_label, piltext)
Combine_Levels(arr_price, arr_label, intra_open, label_4H, Color_4H_Levels)
Combine_Levels(arr_price, arr_label, intrah_open, intrah_label, Color_4H_Levels)
Combine_Levels(arr_price, arr_label, intral_open, intral_label, Color_4H_Levels)
if Show_Monday_Levels
monday_limit_right = extend_to_current(Rigth_Def)
mondaym_limit_right = extend_to_current(Rigth_Def)
mondaym_open = (monday_high + monday_low) / 2
var monday_line = line.new(x1=monday_time, x2=monday_limit_right, y1=monday_high, y2=monday_high, color=Color_Monday_Levels, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Style_Monday_Levels))
var monday_label = label.new(x=monday_limit_right, y=monday_high, text=pmonhtext, style=DEFAULT_LABEL_STYLE, textcolor=Color_Monday_Levels, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var mondaym_line = line.new(x1=monday_time, x2=mondaym_limit_right, y1=mondaym_open, y2=mondaym_open, color=Color_Monday_Levels, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Style_Monday_Levels))
var mondaym_label = label.new(x=mondaym_limit_right, y=mondaym_open, text=pmonmtext, style=DEFAULT_LABEL_STYLE, textcolor=Color_Monday_Levels, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var monday_low_line = line.new(x1=monday_time, x2=monday_limit_right, y1=monday_low, y2=monday_low, color=Color_Monday_Levels, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Style_Monday_Levels))
var monday_low_label = label.new(x=monday_limit_right, y=monday_low, text=pmonltext, style=DEFAULT_LABEL_STYLE, textcolor=Color_Monday_Levels, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
line.set_x1(monday_line, monday_time)
line.set_x2(monday_line, monday_limit_right)
line.set_y1(monday_line, monday_high)
line.set_y2(monday_line, monday_high)
label.set_x(monday_label, monday_limit_right)
label.set_y(monday_label, monday_high)
label.set_text(monday_label, pmonhtext)
line.set_x1(monday_low_line, monday_time)
line.set_x2(monday_low_line, monday_limit_right)
line.set_y1(monday_low_line, monday_low)
line.set_y2(monday_low_line, monday_low)
label.set_x(monday_low_label, monday_limit_right)
label.set_y(monday_low_label, monday_low)
label.set_text(monday_low_label, pmonltext)
line.set_x1(mondaym_line, monday_time)
line.set_x2(mondaym_line, mondaym_limit_right)
line.set_y1(mondaym_line, mondaym_open)
line.set_y2(mondaym_line, mondaym_open)
label.set_x(mondaym_label, mondaym_limit_right)
label.set_y(mondaym_label, mondaym_open)
label.set_text(mondaym_label, pmonmtext)
Combine_Levels(arr_price, arr_label, monday_high, monday_label, Color_Monday_Levels)
Combine_Levels(arr_price, arr_label, monday_low, monday_low_label, Color_Monday_Levels)
Combine_Levels(arr_price, arr_label, mondaym_open, mondaym_label, Color_Monday_Levels)
if Show_Daily_Levels
daily_limit_right = extend_to_current(Rigth_Def)
dailyh_limit_right = extend_to_current(Rigth_Def)
dailyl_limit_right = extend_to_current(Rigth_Def)
var daily_line = line.new(x1=daily_time, x2=daily_limit_right, y1=daily_open, y2=daily_open, color=Color_Daily_Levels, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Style_Daily_Levels))
var daily_label = label.new(x=daily_limit_right, y=daily_open, text=dotext, style=DEFAULT_LABEL_STYLE, textcolor=Color_Daily_Levels, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var dailyh_line = line.new(x1=dailyh_time, x2=dailyh_limit_right, y1=dailyh_open, y2=dailyh_open, color=Color_Daily_Levels, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Style_Daily_Levels))
var dailyh_label = label.new(x=dailyh_limit_right, y=dailyh_open, text=pdhtext, style=DEFAULT_LABEL_STYLE, textcolor=Color_Daily_Levels, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var dailyl_line = line.new(x1=dailyl_time, x2=dailyl_limit_right, y1=dailyl_open, y2=dailyl_open, color=Color_Daily_Levels, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Style_Daily_Levels))
var dailyl_label = label.new(x=dailyl_limit_right, y=dailyl_open, text=pdltext, style=DEFAULT_LABEL_STYLE, textcolor=Color_Daily_Levels, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
line.set_x1(daily_line, daily_time)
line.set_x2(daily_line, daily_limit_right)
line.set_y1(daily_line, daily_open)
line.set_y2(daily_line, daily_open)
label.set_x(daily_label, daily_limit_right)
label.set_y(daily_label, daily_open)
label.set_text(daily_label, dotext)
line.set_x1(dailyh_line, dailyh_time)
line.set_x2(dailyh_line, dailyh_limit_right)
line.set_y1(dailyh_line, dailyh_open)
line.set_y2(dailyh_line, dailyh_open)
label.set_x(dailyh_label, dailyh_limit_right)
label.set_y(dailyh_label, dailyh_open)
label.set_text(dailyh_label, pdhtext)
line.set_x1(dailyl_line, dailyl_time)
line.set_x2(dailyl_line, dailyl_limit_right)
line.set_y1(dailyl_line, dailyl_open)
line.set_y2(dailyl_line, dailyl_open)
label.set_x(dailyl_label, dailyl_limit_right)
label.set_y(dailyl_label, dailyl_open)
label.set_text(dailyl_label, pdltext)
Combine_Levels(arr_price, arr_label, daily_open, daily_label, Color_Daily_Levels)
Combine_Levels(arr_price, arr_label, dailyh_open, dailyh_label, Color_Daily_Levels)
Combine_Levels(arr_price, arr_label, dailyl_open, dailyl_label, Color_Daily_Levels)
if Show_Weekly_Levels
weekly_limit_right = extend_to_current(Rigth_Def)
weeklyh_limit_right = extend_to_current(Rigth_Def)
weeklyl_limit_right = extend_to_current(Rigth_Def)
cweekly_time = weekly_time
var weekly_line = line.new(x1=cweekly_time, x2=weekly_limit_right, y1=weekly_open, y2=weekly_open, color=WeeklyColor, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Weekly_style))
var weekly_label = label.new(x=weekly_limit_right, y=weekly_open, text=wotext, style=DEFAULT_LABEL_STYLE, textcolor=WeeklyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var weeklyh_line = line.new(x1=weeklyh_time, x2=weeklyh_limit_right, y1=weeklyh_open, y2=weeklyh_open, color=WeeklyColor, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Weekly_style))
var weeklyh_label = label.new(x=weeklyh_limit_right, y=weeklyh_open, text=pwhtext, style=DEFAULT_LABEL_STYLE, textcolor=WeeklyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var weeklyl_line = line.new(x1=weeklyl_time, x2=weeklyl_limit_right, y1=weekly_open, y2=weekly_open, color=WeeklyColor, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Weekly_style))
var weeklyl_label = label.new(x=weeklyl_limit_right, y=weeklyl_open, text=pwltext, style=DEFAULT_LABEL_STYLE, textcolor=WeeklyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
line.set_x1(weekly_line, cweekly_time)
line.set_x2(weekly_line, weekly_limit_right)
line.set_y1(weekly_line, weekly_open)
line.set_y2(weekly_line, weekly_open)
label.set_x(weekly_label, weekly_limit_right)
label.set_y(weekly_label, weekly_open)
label.set_text(weekly_label, wotext)
line.set_x1(weeklyh_line, weeklyh_time)
line.set_x2(weeklyh_line, weeklyh_limit_right)
line.set_y1(weeklyh_line, weeklyh_open)
line.set_y2(weeklyh_line, weeklyh_open)
label.set_x(weeklyh_label, weeklyh_limit_right)
label.set_y(weeklyh_label, weeklyh_open)
label.set_text(weeklyh_label, pwhtext)
line.set_x1(weeklyl_line, weeklyl_time)
line.set_x2(weeklyl_line, weeklyl_limit_right)
line.set_y1(weeklyl_line, weeklyl_open)
line.set_y2(weeklyl_line, weeklyl_open)
label.set_x(weeklyl_label, weeklyl_limit_right)
label.set_y(weeklyl_label, weeklyl_open)
label.set_text(weeklyl_label, pwltext)
Combine_Levels(arr_price, arr_label, weekly_open, weekly_label, WeeklyColor)
Combine_Levels(arr_price, arr_label, weeklyh_open, weeklyh_label, WeeklyColor)
Combine_Levels(arr_price, arr_label, weeklyl_open, weeklyl_label, WeeklyColor)
if Show_Yearly_Levels
yearlyl_limit_right = extend_to_current(Rigth_Def)
yearlyh_limit_right = extend_to_current(Rigth_Def)
yearly_limit_right = extend_to_current(Rigth_Def)
var yearlyl_line = line.new(x1=yearlyl_time, x2=yearlyl_limit_right, y1=yearlyl_open, y2=yearlyl_open, color=YearlyColor, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Yearly_style))
var yearlyl_label = label.new(x=yearlyl_limit_right, y=yearlyl_open, text=cyltext, style=DEFAULT_LABEL_STYLE, textcolor=YearlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var yearlyh_line = line.new(x1=yearlyh_time, x2=yearlyh_limit_right, y1=yearlyh_open, y2=yearlyh_open, color=YearlyColor, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Yearly_style))
var yearlyh_label = label.new(x=yearlyh_limit_right, y=yearlyh_open, text=cyhtext, style=DEFAULT_LABEL_STYLE, textcolor=YearlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var yearly_line = line.new(x1=yearly_time, x2=yearly_limit_right, y1=yearly_open, y2=yearly_open, color=YearlyColor, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Yearly_style))
var yearly_label = label.new(x=yearly_limit_right, y=yearly_open, text=yotext, style=DEFAULT_LABEL_STYLE, textcolor=YearlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
line.set_x1(yearlyl_line, yearlyl_time)
line.set_x2(yearlyl_line, yearlyl_limit_right)
line.set_y1(yearlyl_line, yearlyl_open)
line.set_y2(yearlyl_line, yearlyl_open)
label.set_x(yearlyl_label, yearlyl_limit_right)
label.set_y(yearlyl_label, yearlyl_open)
label.set_text(yearlyl_label, cyltext)
line.set_x1(yearlyh_line, yearlyh_time)
line.set_x2(yearlyh_line, yearlyh_limit_right)
line.set_y1(yearlyh_line, yearlyh_open)
line.set_y2(yearlyh_line, yearlyh_open)
label.set_x(yearlyh_label, yearlyh_limit_right)
label.set_y(yearlyh_label, yearlyh_open)
label.set_text(yearlyh_label, cyhtext)
line.set_x1(yearly_line, yearly_time)
line.set_x2(yearly_line, yearly_limit_right)
line.set_y1(yearly_line, yearly_open)
line.set_y2(yearly_line, yearly_open)
label.set_x(yearly_label, yearly_limit_right)
label.set_y(yearly_label, yearly_open)
label.set_text(yearly_label, yotext)
Combine_Levels(arr_price, arr_label, yearlyh_open, yearlyh_label, YearlyColor)
Combine_Levels(arr_price, arr_label, yearlyl_open, yearlyl_label, YearlyColor)
Combine_Levels(arr_price, arr_label, yearly_open, yearly_label, YearlyColor)
if Show_Quaterly_Levels
quarterly_limit_right = extend_to_current(Rigth_Def)
quarterlyh_limit_right = extend_to_current(Rigth_Def)
quarterlyl_limit_right = extend_to_current(Rigth_Def)
var quarterly_line = line.new(x1=quarterly_time, x2=quarterly_limit_right, y1=quarterly_open, y2=quarterly_open, color=quarterlyColor, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Quaterly_style))
var quarterly_label = label.new(x=quarterly_limit_right, y=quarterly_open, text=qotext, style=DEFAULT_LABEL_STYLE, textcolor=quarterlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var quarterlyh_line = line.new(x1=quarterlyh_time, x2=quarterlyh_limit_right, y1=quarterlyh_open, y2=quarterlyh_open, color=quarterlyColor, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Quaterly_style))
var quarterlyh_label = label.new(x=quarterlyh_limit_right, y=quarterlyh_open, text=pqhtext, style=DEFAULT_LABEL_STYLE, textcolor=quarterlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
var quarterlyl_line = line.new(x1=quarterlyl_time, x2=quarterlyl_limit_right, y1=quarterlyl_open, y2=quarterlyl_open, color=quarterlyColor, width=linewidth_def, xloc=xloc.bar_time, style=lineStyle(Quaterly_style))
var quarterlyl_label = label.new(x=quarterlyl_limit_right, y=quarterlyl_open, text=pqltext, style=DEFAULT_LABEL_STYLE, textcolor=quarterlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
line.set_x1(quarterly_line, quarterly_time)
line.set_x2(quarterly_line, quarterly_limit_right)
line.set_y1(quarterly_line, quarterly_open)
line.set_y2(quarterly_line, quarterly_open)
label.set_x(quarterly_label, quarterly_limit_right)
label.set_y(quarterly_label, quarterly_open)
label.set_text(quarterly_label, qotext)
line.set_x1(quarterlyh_line, quarterlyh_time)
line.set_x2(quarterlyh_line, quarterlyh_limit_right)
line.set_y1(quarterlyh_line, quarterlyh_open)
line.set_y2(quarterlyh_line, quarterlyh_open)
label.set_x(quarterlyh_label, quarterlyh_limit_right)
label.set_y(quarterlyh_label, quarterlyh_open)
label.set_text(quarterlyh_label, pqhtext)
line.set_x1(quarterlyl_line, quarterlyl_time)
line.set_x2(quarterlyl_line, quarterlyl_limit_right)
line.set_y1(quarterlyl_l
TOTOOLI X11 (by 3DOTS)// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// © 3DOTS
//Usage : Only Wait for an order block confirmation.
//@version=5
indicator("TOTOOLI X11 (by 3DOTS)" , shorttitle = "This is Totooli for professional usage",overlay = false)
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
darkGreenColor = #1B7E02
darkRedColor = #93021F
kpoDeviations = input.float(2.0, "Deviations", group= "Basic Settings") // Kase peak oscillator deviations
kpoShortCycle = input.int(8, "Short Cycle Period", group= "Basic Settings") // Kase peak oscillator short cycle
kpoLongCycle = input.int(65, "Long Cycle Period", group= "Basic Settings") // Kase peak oscillator long cycle
kpoSensitivity = input.float(40, "Sensitivity", group= "Basic Settings") // Kase peak oscillator sensitivity
allPeaksMode = input.bool(true, "Show all peaks?", group= "Basic Settings") // Show all peaks?
colorbars = input.bool(false, "Color bars?", group= "UI Options")
mutebars = input.bool(false, "Mute bars?", group= "UI Options")
lbR = input(title="Pivot Lookback Right", defval=5, group = "Divergences Settings")
lbL = input(title="Pivot Lookback Left", defval=5, group = "Divergences Settings")
rangeUpper = input(title="Max of Lookback Range", defval=60, group = "Divergences Settings")
rangeLower = input(title="Min of Lookback Range", defval=5, group = "Divergences Settings")
plotBull = input(title="Plot Bullish", defval=true, group = "Divergences Settings")
plotHiddenBull = input(title="Plot Hidden Bullish", defval=false, group = "Divergences Settings")
plotBear = input(title="Plot Bearish", defval=true, group = "Divergences Settings")
plotHiddenBear = input(title="Plot Hidden Bearish", defval=false, group = "Divergences Settings")
bearColor = darkRedColor
bullColor = darkGreenColor
hiddenBullColor = color.new(darkGreenColor, 80)
hiddenBearColor = color.new(darkRedColor, 80)
textColor = color.white
noneColor = color.new(color.white, 100)
x1 = 0.
xs = 0.
x1 := nz(x1 )
xs := nz(xs )
ccLog = math.log(close / nz(close ))
ccDev = ta.stdev(ccLog, 9)
avg = ta.sma(ccDev, 30)
max1 = 0.
maxs = 0.
for k = kpoShortCycle to kpoLongCycle - 1
max1 := math.max(math.log(high / nz(low )) / math.sqrt(k), max1)
maxs := math.max(math.log(nz(high ) / low) / math.sqrt(k), maxs)
x1 := max1 / avg
xs := maxs / avg
xp = kpoSensitivity * (ta.sma(x1, 3) - ta.sma(xs, 3))
xpAbs = math.abs(xp)
kppBuffer = 0.
kpoBuffer = xp
kphBuffer = xp
tmpVal = ta.sma(xpAbs, 50) + kpoDeviations * (ta.stdev(xpAbs, 50))
maxVal = math.max(90.0, tmpVal)
minVal = math.min(90.0, tmpVal)
kpdBuffer = 0.
kpmBuffer = 0.
if kpoBuffer > 0.
kpdBuffer := maxVal
kpmBuffer := minVal
else
kpdBuffer := -maxVal
kpmBuffer := -minVal
if (not allPeaksMode)
if (nz(kpoBuffer ) > 0 and nz(kpoBuffer ) > kpoBuffer and nz(kpoBuffer ) >= nz(kpoBuffer ) and nz(kpoBuffer ) >= maxVal)
kppBuffer := kpoBuffer
if (nz(kpoBuffer ) < 0 and nz(kpoBuffer ) < kpoBuffer and nz(kpoBuffer ) <= nz(kpoBuffer ) and nz(kpoBuffer ) <= -maxVal)
kppBuffer := kpoBuffer
else
if (nz(kpoBuffer ) > 0 and nz(kpoBuffer ) > kpoBuffer and nz(kpoBuffer ) >= nz(kpoBuffer ))
kppBuffer := kpoBuffer
if (nz(kpoBuffer ) < 0 and nz(kpoBuffer ) < kpoBuffer and nz(kpoBuffer ) <= nz(kpoBuffer ))
kppBuffer := kpoBuffer
plot(kpoBuffer, "Kase Peak Oscillator", color = color.gray)
plot(kphBuffer, "Kase Peak Oscillator Histogram", color = color.gray, style=plot.style_histogram)
plot(kpdBuffer, "Max Peak Value", color = color.blue, linewidth = 1) //Blue Kpeak-Min line is a maximum of two standard deviations of the PeakOscillator value.
//plot(kpmBuffer, "Min Peak Value", color = color.white, linewidth = 1) //Red PeakOut line is a minimum of two standard deviations of the PeakOscillator value
colorout = kppBuffer ? kppBuffer > 0 ? redcolor : greencolor : mutebars ? color.gray : na
plot(kppBuffer, "Market Extreme", color = kppBuffer ? colorout : na, style = plot.style_histogram, linewidth = 3)
barcolor(colorbars ? colorout : na)
osc = kpoBuffer
plFound = na(ta.pivotlow(osc, lbL, lbR)) ? false : true
phFound = na(ta.pivothigh(osc, lbL, lbR)) ? false : true
_inRange(cond) =>
bars = ta.barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper
//------------------------------------------------------------------------------
// Regular Bullish
// Osc: Higher Low
oscHL = osc > ta.valuewhen(plFound, osc , 1) and _inRange(plFound )
// Price: Lower Low
priceLL = low < ta.valuewhen(plFound, low , 1)
bullCond = plotBull and priceLL and oscHL and plFound
plot(
plFound ? osc : na,
offset=-lbR,
title="Regular Bullish",
linewidth=2,
color=(bullCond ? bullColor : noneColor)
)
plotshape(
bullCond ? osc : na,
offset=-lbR,
title="Regular Bullish Label",
text="R",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor
)
//------------------------------------------------------------------------------
// Hidden Bullish
// Osc: Lower Low
oscLL = osc < ta.valuewhen(plFound, osc , 1) and _inRange(plFound )
// Price: Higher Low
priceHL = low > ta.valuewhen(plFound, low , 1)
hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound
plot(
plFound ? osc : na,
offset=-lbR,
title="Hidden Bullish",
linewidth=2,
color=(hiddenBullCond ? hiddenBullColor : noneColor)
)
plotshape(
hiddenBullCond ? osc : na,
offset=-lbR,
title="Hidden Bullish Label",
text="H",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor
)
//------------------------------------------------------------------------------
// Regular Bearish
// Osc: Lower High
oscLH = osc < ta.valuewhen(phFound, osc , 1) and _inRange(phFound )
// Price: Higher High
priceHH = high > ta.valuewhen(phFound, high , 1)
bearCond = plotBear and priceHH and oscLH and phFound
plot(
phFound ? osc : na,
offset=-lbR,
title="Regular Bearish",
linewidth=2,
color=(bearCond ? bearColor : noneColor)
)
plotshape(
bearCond ? osc : na,
offset=-lbR,
title="Regular Bearish Label",
text="R",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor
)
//------------------------------------------------------------------------------
// Hidden Bearish
// Osc: Higher High
oscHH = osc > ta.valuewhen(phFound, osc , 1) and _inRange(phFound )
// Price: Lower High
priceLH = high < ta.valuewhen(phFound, high , 1)
hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound
plot(
phFound ? osc : na,
offset=-lbR,
title="Hidden Bearish",
linewidth=2,
color=(hiddenBearCond ? hiddenBearColor : noneColor)
)
plotshape(
hiddenBearCond ? osc : na,
offset=-lbR,
title="Hidden Bearish Label",
text="H",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor
)
goLong = kppBuffer < 0
goShort = kppBuffer > 0
alertcondition(goLong, title="Long", message="Kase Peak Oscillator w/ Divergences : Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Kase Peak Oscillator w/ Divergences : Short\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(hiddenBearCond, title="Hidden Bear Divergence", message="Kase Peak Oscillator w/ Divergences : Hidden Bear Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(bearCond, title="Regular Bear Divergence", message="Kase Peak Oscillator w/ Divergences : Regular Bear Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(hiddenBullCond, title="Hidden Bull Divergence", message="Kase Peak Oscillator w/ Divergences : Hidden Bull Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(bullCond, title="Regular Bull Divergence", message="Kase Peak Oscillator w/ Divergences : Regular Bull Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
//********************************
var string GP3 = "Power 3 Visual"
i_label_toggle = input.bool(defval=true, title="", group=GP3, inline="labels")
i_label_text_color = input.color(defval=color.rgb(255, 255, 255, 0), title="Display Labels", group=GP3, inline="labels")
c_tooltip_timeframe = "Switch the Power 3 Visual between the current Day or current Week"
i_timeframe = input.timeframe(defval="W", title="Timeframe", options= , group=GP3, tooltip=c_tooltip_timeframe)
i_daily_start = input.timeframe(defval="Midnight", title="Daily Start", options= , group=GP3, tooltip="Pick either Daily open price or Midnight EST open price")
c_tooltip_move = "The Futures market is open 23/5. It is closed everyday for 1-hour at 5pm EST and closed over the weekends. Because this Intraday Power 3 Visual is drawing in the 'future' on the users TradingView chart, when the visual is close or in a time when the market is closed, the visual doesn't behave properly. This is because TradingView doesn't display times when the Market is closed, thus the drawings cannot be displayed during those times. There is nothing wrong with the script. Please wait until the Market is open and the visual will be drawn normally."
i_right_movement = input.int(defval=5, minval=1, step=1, title="Visual Right Movement", group=GP3, tooltip=c_tooltip_move)
i_line_color = input.color(defval=color.rgb(255, 255, 255, 0), title="Line Color", group=GP3)
i_line_width = input.int(defval=2, minval=1, maxval=20, step=1, title="Line Width", group=GP3)
i_line_style = input.string(defval="solid (-)", title="Line Style", options= , group=GP3)
///////////////////////////////////////////////////////////////////////////////// HELPER FUNCTIONS
// Function the converts string inputs to line style code
line_style_function(input_var) =>
switch input_var
"dotted (?)" => line.style_dotted
"dashed (?)" => line.style_dashed
=> line.style_solid
///////////////////////////////////////////////////////////////////////////////// TIMEFRAME
timeframe_high = request.security(syminfo.tickerid, i_timeframe, high)
timeframe_low = request.security(syminfo.tickerid, i_timeframe, low)
timeframe_open_req = request.security(syminfo.tickerid, i_timeframe, open)
timeframe_close = request.security(syminfo.tickerid, i_timeframe, close)
// Logic for midnight est open or daily open
// Time variables
midnight_window = (hour(time, "America/New_York") == 0) and (minute(time) == 0)
midnight_timespan_est = time(timeframe.period, '0001-1659', "America/New_York")
var float midnight_open = na
var float timeframe_open = na
if i_timeframe == "W"
timeframe_open := timeframe_open_req
else
// Timeframe set to daily
if i_daily_start == "Open"
timeframe_open := timeframe_open_req
else
// Get price at midnight open EST
if midnight_window
midnight_open := open
// If time is after midnight est then use midnight price, if price before midnight price then use daily open price
if midnight_timespan_est
timeframe_open := midnight_open
else
timeframe_open := timeframe_open_req
///////////////////////////////////////////////////////////////////////////////// BULL & BEAR VARIABLES
var float manipulation_value = na
var float distribution_value = na
range_explansion_value = (timeframe_open + timeframe_close) / 2
// Sets values based on whether daily/weekly range is bear or bull direction
if timeframe_open > timeframe_close
// Bearish candle
manipulation_value := (timeframe_open + timeframe_high) / 2
distribution_value := (timeframe_close + timeframe_low) / 2
else
// Bullish candle
manipulation_value := (timeframe_open + timeframe_low) / 2
distribution_value := (timeframe_close + timeframe_high) / 2
///////////////////////////////////////////////////////////////////////////////// POWER 3 VISUAL
// Move timebased labels right
dt = time + i_right_movement * (time - time )
dt_current = time + (i_right_movement * 2) * (time - time )
// Visual line style
line_style_power3 = line_style_function(i_line_style)
// Set defaults for all lines and labels
var line line_vertical = na
var line line_power3_open = na
var line line_power3_current = na
var label label_range_expansion = na
var label label_accumulation = na
var label label_manipulation = na
var label label_distribution = na
// Saves TradingView resources by only drawing the visual once
if timeframe.isintraday and barstate.islast
// Draw Power 3 lines
// Vertical line
line_vertical := line.new(x1=dt, y1=timeframe_high, x2=dt, y2=timeframe_low, xloc=xloc.bar_time, color=i_line_color, style=line_style_power3, width=i_line_width,force_overlay = true)
line.delete(line_vertical )
// Left horizontal line
line_power3_open := line.new(x1=time, y1=timeframe_open, x2=dt, y2=timeframe_open, xloc=xloc.bar_time, color=i_line_color, style=line_style_power3, width=i_line_width,force_overlay = true)
line.delete(line_power3_open )
// Right horizontal line
line_power3_current := line.new(x1=dt, y1=timeframe_close, x2=dt_current, y2=timeframe_close, xloc=xloc.bar_time, color=i_line_color, style=line_style_power3, width=i_line_width,force_overlay = true)
line.delete(line_power3_current )
// Toggle on/off lables
if i_label_toggle
// Place labels
// Range Expanseion label
label_range_expansion := label.new(x=dt, y=range_explansion_value, text="Range Expansion", xloc=xloc.bar_time, style=label.style_none, textcolor=i_label_text_color, textalign=text.align_center, tooltip="Range Expansion is ...",force_overlay = true)
label.delete(label_range_expansion )
// Accumulation label
label_accumulation := label.new(x=dt, y=timeframe_open, text="Accumulation", xloc=xloc.bar_time, style=label.style_none, textcolor=i_label_text_color, textalign=text.align_right, tooltip="Accumulation is ...",force_overlay = true)
label.delete(label_accumulation )
// Manipulation label
label_manipulation := label.new(x=dt, y=manipulation_value, text="Manipulation", xloc=xloc.bar_time, style=label.style_none, textcolor=i_label_text_color, textalign=text.align_center, tooltip="Manipulation is ...",force_overlay = true)
label.delete(label_manipulation )
// Distribution label
label_distribution := label.new(x=dt, y=distribution_value, text="Distribution", xloc=xloc.bar_time, style=label.style_none, textcolor=i_label_text_color, textalign=text.align_center, tooltip="Distribution is ...",force_overlay = true)
label.delete(label_distribution )
// RSI Settings for user
rsiSource = input(title='RSI Source', defval=close)
rsiLength = input(title='RSI Length', defval=7)
rsiOverbought1 = input.int(title='RSI Overbought', defval=70, minval=50, maxval=100)
rsiOvesold = input.int(title='RSI Oversold', defval=30, minval=1, maxval=50)
upcol = input(defval=color.new(color.olive,100), title='Zig Zag 1 Up Color')
dncol = input(defval=color.new(color.fuchsia,100), title='Zig Zag 1 Down Color')
// RSI value based on inbuilt RSI
rsiValue = ta.rsi(rsiSource, rsiLength)
// Get the current state
isOverbought = rsiValue >= rsiOverbought1
isOversold = rsiValue <= rsiOvesold
// State of the last extreme 0 for initialization, 1 = overbought, 2 = oversold
var laststate = 0
// Highest and Lowest prices since the last state change
var hhh = low
var lll = high
// Labels
var label labelll = na
var label labelhh = na
// Swing lines
var line line_up = na
var line line_down = na
// We go from overbought straight to oversold NEW DRAWINGS CREATED HERE
if laststate == 1 and isOversold
lll := low
labelll := label.new(bar_index, high, style=label.style_label_up, color=color.rgb(0,255,0,35), size=size.small,force_overlay = true)
label.set_text( labelll, "Wait for" + "\n" + "Confirmation" + "\n" + "BUY")
labelhh_low = label.get_x(labelhh)
labelhh_pos = label.get_y(labelhh)
line_down := line.new(bar_index, high, labelhh_low, labelhh_pos, width=2, color = dncol,force_overlay = true)
label.set_text(id=labelll, text="Wait for" + "\n" + "Confirmation" + "\n" + "BUY")
// We go from oversold straight to overbought NEW DRAWINGS CREATED HERE
if laststate == 2 and isOverbought
hhh := high
labelhh := label.new(bar_index, high, style=label.style_label_down, color=color.rgb(255,0,98,35), size=size.small,force_overlay = true)
label.set_text( labelhh, "SELL" + "\n" + "Wait for" + "\n" + "Confirmation")
labelll_low = label.get_x(labelll)
labelll_pos = label.get_y(labelll)
line_up := line.new(bar_index, high, labelll_low, labelll_pos, width=2, color = upcol,force_overlay = true)
// If we are overbought
if isOverbought
if high >= hhh
hhh := high
label.set_x(labelhh, bar_index)
label.set_y(labelhh, high)
line.set_x1(line_up, bar_index)
line.set_y1(line_up, high)
laststate := 1
laststate
// If we are oversold
if isOversold
if low <= lll
lll := low
label.set_x(labelll, bar_index)
label.set_y(labelll, low)
line.set_x1(line_down, bar_index)
line.set_y1(line_down, low)
laststate := 2
laststate
// If last state was overbought and we are overbought
if laststate == 1 and isOverbought
if hhh <= high
hhh := high
label.set_x(labelhh, bar_index)
label.set_y(labelhh, high)
line.set_x1(line_up, bar_index)
line.set_y1(line_up, high)
//If we are oversold and the last state was oversold, move the drawings to the lowest price
if laststate == 2 and isOversold
if low <= lll
lll := low
label.set_x(labelll, bar_index)
label.set_y(labelll, low)
line.set_x1(line_down, bar_index)
line.set_y1(line_down, low)
// If last state was overbought
if laststate == 1
if hhh <= high
hhh := high
label.set_x(labelhh, bar_index)
label.set_y(labelhh, high)
line.set_x1(line_up, bar_index)
line.set_y1(line_up, high)
// If last stare was oversold
if laststate == 2
if lll >= low
lll := low
label.set_x(labelll, bar_index)
label.set_y(labelll, low)
line.set_x1(line_down, bar_index)
line.set_y1(line_down, low)
lb = input.int(3, title='Left Bars', minval=1)
rb = input.int(15, title='Right Bars', minval=1)
showsupres = input.bool(true, title='Support/Resistance', inline='srcol')
supcol = input.color(color.white, title='', inline='srcol')
rescol = input.color(color.white, title='', inline='srcol')
srlinestyle = input.string(line.style_dashed, title='Line Style/Width', options= , inline='style')
srlinewidth = input.int(1, title='', minval=1, maxval=5, inline='style')
//changebarcol = input.bool(true, title='Change Bar Color', inline='bcol')
//bcolup = input.color(color.blue, title='', inline='bcol')
//bcoldn = input.color(color.black, title='', inline='bcol')
phh = ta.pivothigh(lb, rb)
pll = ta.pivotlow(lb, rb)
iff_1 = pll ? -1 : na // Trend direction
hl = phh ? 1 : iff_1
iff_2 = pll ? pll : na // similar to zigzag but may have multiple highs/lows
zz = phh ? phh : iff_2
valuewhen_1 = ta.valuewhen(hl, hl, 1)
valuewhen_2 = ta.valuewhen(zz, zz, 1)
zz := pll and hl == -1 and valuewhen_1 == -1 and pll > valuewhen_2 ? na : zz
valuewhen_3 = ta.valuewhen(hl, hl, 1)
valuewhen_4 = ta.valuewhen(zz, zz, 1)
zz := phh and hl == 1 and valuewhen_3 == 1 and phh < valuewhen_4 ? na : zz
valuewhen_5 = ta.valuewhen(hl, hl, 1)
valuewhen_6 = ta.valuewhen(zz, zz, 1)
hl := hl == -1 and valuewhen_5 == 1 and zz > valuewhen_6 ? na : hl
valuewhen_7 = ta.valuewhen(hl, hl, 1)
valuewhen_8 = ta.valuewhen(zz, zz, 1)
hl := hl == 1 and valuewhen_7 == -1 and zz < valuewhen_8 ? na : hl
zz := na(hl) ? na : zz
findprevious() => // finds previous three points (b, c, d, e)
ehl = hl == 1 ? -1 : 1
loc1 = 0.0
loc2 = 0.0
loc3 = 0.0
loc4 = 0.0
xx = 0
for x = 1 to 1000 by 1
if hl == ehl and not na(zz )
loc1 := zz
xx := x + 1
break
ehl := hl
for x = xx to 1000 by 1
if hl == ehl and not na(zz )
loc2 := zz
xx := x + 1
break
ehl := hl == 1 ? -1 : 1
for x = xx to 1000 by 1
if hl == ehl and not na(zz )
loc3 := zz
xx := x + 1
break
ehl := hl
for x = xx to 1000 by 1
if hl == ehl and not na(zz )
loc4 := zz
break
float aa = na
float bb = na
float w = na
float dd = na
float e = na
if not na(hl)
= findprevious()
aa := zz
bb := loc1
w := loc2
dd := loc3
e := loc4
e
_hh = zz and aa > bb and aa > w and w > bb and w > dd
_ll = zz and aa < bb and aa < w and w < bb and w < dd
_hl = zz and (aa >= w and bb > w and bb > dd and dd > w and dd > e or aa < bb and aa > w and bb < dd)
_lh = zz and (aa <= w and bb < w and bb < dd and dd < w and dd < e or aa > bb and aa < w and bb > dd)
plotshape(_hl, text='HL', title='Higher Low', style=shape.labelup, color=color.new(color.white, 0), textcolor=color.new(color.black, 0), location=location.belowbar, offset=-rb,force_overlay = true)
//plotshape(_hh, text='HH', title='Higher High', style=shape.labeldown, color=color.new(color.aqua, 0), textcolor=color.new(color.black, 0), location=location.abovebar, offset=-rb)
//plotshape(_ll, text='LL', title='Lower Low', style=shape.labelup, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), location=location.belowbar, offset=-rb)
plotshape(_lh, text='LH', title='Lower High', style=shape.labeldown, color=color.new(color.white, 0), textcolor=color.new(color.black, 0), location=location.abovebar, offset=-rb,force_overlay = true)
float res1 = na
float sup = na
res1 := _lh ? zz : res1
sup := _hl ? zz : sup
int trend = na
iff_3 = close < sup ? -1 : nz(trend )
trend := close > res1 ? 1 : iff_3
res1 := trend == 1 and _hh or trend == -1 and _lh ? zz : res1
sup := trend == 1 and _hl or trend == -1 and _ll ? zz : sup
rechange = res1 != res1
suchange = sup != sup
var line resline = na
var line supline = na
if showsupres
if rechange
line.set_x2(resline, bar_index)
line.set_extend(resline, extend=extend.none)
resline := line.new(x1=bar_index - rb, y1=res1, x2=bar_index, y2=res1, color=rescol, extend=extend.right, style=srlinestyle, width=srlinewidth,force_overlay = true)
resline
if suchange
line.set_x2(supline, bar_index)
line.set_extend(supline, extend=extend.none)
supline := line.new(x1=bar_index - rb, y1=sup, x2=bar_index, y2=sup, color=supcol, extend=extend.right, style=srlinestyle, width=srlinewidth,force_overlay = true)
supline
//iff_4 = trend == 1 ? bcolup : bcoldn
//
CRAK1 = input.int(13, step=10)
CRAK2 = input.int(17, step=10)
CRAK3 = input.int(110, step=10)
CRAK4 = input.int(109, step=10)
CRAK5 = input.int(103, step=10)
CRAK6 = input.int(1, step=10)
CRAK7 = input.int(1, step=10)
CRAK8 = input.int(9, step=10)
CRAK9 = input.int(11, step=10)
CRAK10 = input.int(120, step=10)
CRAK11 = input.int(200, step=10)
CRAK12 = input.int(200, step=10)
CRAK13 = input.int(110, step=10)
CRAK14 = input.int(11, step=10)
CRAK15 = input.int(12, step=10)
CRAK16 = input.int(2, step=10)
CRAK17 = input.int(1, step=10)
CRAK18 = input.int(2, step=10)
CRAK19 = input.int(1, step=10)
CRAK20 = input.int(2, step=10)
///
DETECT3 = input.int(18, step=10)
PATTERN1 = input(true)
PATTERN10 = input.int(18, step=5, minval=1)
COLORP1 = input(color.rgb(43, 52, 146, 55))
zigzag1Width = 1
zigzag1Style = line.style_dotted
PATTERN2 = input(true)
PATTERN20 = input.int(24, step=5, minval=1)
COLORP2 = input(color.rgb(43, 52, 146, 55))
zigzag2Width = 1
zigzag2Style = line.style_dotted
PATTERN3 = input(true)
PATTERN30 = input.int(32, step=5, minval=1)
COLORP3 = input(color.rgb(43, 52, 146, 55))
zigzag3Width = 1
zigzag3Style = line.style_dotted
PATTERN4 = input(true)
PATTERN40 = input.int(38, step=5, minval=1)
COLORP4 = input(color.rgb(43, 52, 146, 55))
zigzag4Width = 1
zigzag4Style = line.style_dotted
P11 = input(true)
P22 = input(true)
P33 = input(true)
P44 = input(true)
P55 = input(true)
P66 = input(true)
DETECTM = input.int(18, minval=5, step=5, maxval=200)
//
DATAC = input.int(350, step=10)
DATAC2 = input.int(400, step=10)
//
MaxRiskPerReward = input.int(29, title='DETECT/PER', step=10, minval=0)
//
//
E1 = input.int(370, step=10)
E2 = input.int(390, step=10)
showStatTable = false
CANCLE_PATTERNS = input(false)
//
CRAKD90 = input.int(200, step=10)
CRAKFALSE200 = input.int(200, step=10)
CRAKFALSE100 = input.int(300, step=10)
///
BULL_PATTERNS = input(color.silver)
BEAR_PATTERNS = input(color.blue)
err_min = (100 - DETECTM) / 100
err_max = (100 + DETECTM) / 100
var zigzagpivots1 = array.new_float(0)
var zigzagpivotbars1 = array.new_int(0)
var zigzagpivotdirs1 = array.new_int(0)
var zigzagpivots2 = array.new_float(0)
var zigzagpivotbars2 = array.new_int(0)
var zigzagpivotdirs2 = array.new_int(0)
var zigzagpivots3 = array.new_float(0)
var zigzagpivotbars3 = array.new_int(0)
var zigzagpivotdirs3 = array.new_int(0)
var zigzagpivots4 = array.new_float(0)
var zigzagpivotbars4 = array.new_int(0)
var zigzagpivotdirs4 = array.new_int(0)
var wmlines1 = array.new_line(8)
var wmtype1 = array.new_int(2, 1)
var wmLabels1 = array.new_bool(13, false)
var wmLabel1 = array.new_label(1)
var wmlines2 = array.new_line(8)
var wmtype2 = array.new_int(2, 1)
var wmLabels2 = array.new_bool(13, false)
var wmLabel2 = array.new_label(1)
var wmlines3 = array.new_line(8)
var wmtype3 = array.new_int(2, 1)
var wmLabels3 = array.new_bool(13, false)
var wmLabel3 = array.new_label(1)
var wmlines4 = array.new_line(8)
var wmtype4 = array.new_int(2, 1)
var wmLabels4 = array.new_bool(13, false)
var wmLabel4 = array.new_label(1)
pivots(length) =>
float phigh = ta.highestbars(high, length) == 0 ? high : na
float plow = ta.lowestbars(low, length) == 0 ? low : na
dir = 0
iff_1 = plow and na(phigh) ? -1 : dir
dir := phigh and na(plow) ? 1 : iff_1
zigzag(length, zigzagpivots, zigzagpivotbars, zigzagpivotdirs) =>
= pivots(length)
dirchanged = ta.change(dir)
if phigh or plow
value = dir == 1 ? phigh : plow
bar = bar_index
newDir = dir
if not dirchanged and array.size(zigzagpivots) >= 1
pivot = array.shift(zigzagpivots)
pivotbar = array.shift(zigzagpivotbars)
pivotdir = array.shift(zigzagpivotdirs)
useNewValues = value * pivotdir < pivot * pivotdir
value := useNewValues ? pivot : value
bar := useNewValues ? pivotbar : bar
bar
if array.size(zigzagpivots) >= 2
LastPoint = array.get(zigzagpivots, 1)
newDir := dir * value > dir * LastPoint ? dir * 2 : dir
newDir
array.unshift(zigzagpivots, value=value)
array.unshift(zigzagpivotbars, bar)
array.unshift(zigzagpivotdirs, newDir)
if array.size(zigzagpivots) > DETECT3
array.pop(zigzagpivots)
array.pop(zigzagpivotbars)
array.pop(zigzagpivotdirs)
get_harmonic_label(wmLabels, dir, price, bar) =>
isP11 = array.get(wmLabels, 0)
isP22 = array.get(wmLabels, 1)
isP33 = array.get(wmLabels, 2)
isP44 = array.get(wmLabels, 3)
isP55 = array.get(wmLabels, 4)
isP66 = array.get(wmLabels, 5)
labelText = isP11 ? 'Gartley' : ''
labelText := labelText + (isP22 ? (labelText == '' ? '' : '\n') + 'Crab' : '')
labelText := labelText + (isP33 ? (labelText == '' ? '' : '\n') + 'Deep Crab' : '')
labelText := labelText + (isP44 ? (labelText == '' ? '' : '\n') + 'Bat' : '')
labelText := labelText + (isP55 ? (labelText == '' ? '' : '\n') + 'Butterfly' : '')
labelText := labelText + (isP66 ? (labelText == '' ? '' : '\n') + 'Shark' : '')
trendColor = dir > 0 ? BULL_PATTERNS : BEAR_PATTERNS
baseLabel = label.new(x=bar, y=price, text=labelText, yloc=yloc.price, color=trendColor, style=dir < 1 ? label.style_label_down : label.style_label_up, textcolor=color.black, size=size.normal,force_overlay = true)
//baseLabel
detect_harmonic_pattern(zigzagpivots, zigzagpivotbars, zigzagpivotdirs, wmlines, wmlabel, wmtype, wmLabels, zigzagColor, zigzagWidth, zigzagStyle, showZigZag) =>
start = CANCLE_PATTERNS ? 1 : 0
wm_pattern = false
abcd_pattern = false
double_pattern = false
if array.size(zigzagpivots) >= 6 + start and showZigZag
d = array.get(zigzagpivots, start + 0)
dBar = array.get(zigzagpivotbars, start + 0)
dDir = array.get(zigzagpivotdirs, start + 0)
c = array.get(zigzagpivots, start + 1)
cBar = array.get(zigzagpivotbars, start + 1)
cDir = array.get(zigzagpivotdirs, start + 1)
b = array.get(zigzagpivots, start + 2)
bBar = array.get(zigzagpivotbars, start + 2)
bDir = array.get(zigzagpivotdirs, start + 2)
a = array.get(zigzagpivots, start + 3)
aBar = array.get(zigzagpivotbars, start + 3)
aDir = array.get(zigzagpivotdirs, start + 3)
x = array.get(zigzagpivots, start + 4)
xBar = array.get(zigzagpivotbars, start + 4)
xDir = array.get(zigzagpivotdirs, start + 4)
y = array.get(zigzagpivots, start + 5)
yBar = array.get(zigzagpivotbars, start + 5)
yDir = array.get(zigzagpivotdirs, start + 5)
highPoint = math.max(x, a, b, c, d)
lowPoint = math.min(x, a, b, c, d)
dir = c > d ? 1 : -1
xabRatio = math.abs(b - a) / math.abs(x - a)
abcRatio = math.abs(c - b) / math.abs(a - b)
bcdRatio = math.abs(d - c) / math.abs(b - c)
xadRatio = math.abs(d - a) / math.abs(x - a)
yxaRatio = math.abs(a - x) / math.abs(y - x)
abTime = math.abs(aBar - bBar)
cdTime = math.abs(cBar - dBar)
abPrice = math.abs(a - b)
cdPrice = math.abs(c - d)
time_ratio = cdTime / abTime
price_ratio = cdPrice / abPrice
abcdDirection = a < b and a < c and c < b and c < d and a < d and b < d ? 1 : a > b and a > c and c > b and c > d and a > d and b > d ? -1 : 0
risk = math.abs(b - d)
reward = math.abs(c - d)
riskPerReward = risk * 100 / (risk + reward)
if b < highPoint and b > lowPoint
//gartley
if P11 and xabRatio >= 0.588 * err_min and xabRatio <= 0.648 * err_max and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max and xadRatio >= 0.786 * err_min and xadRatio <= 0.886 * err_max
wm_pattern := true
array.set(wmLabels, 0, true)
else
array.set(wmLabels, 0, false)
//Crab
if P22 and xabRatio >= 0.382 * err_min and xabRatio <= 0.618 * err_max and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max and xadRatio >= 1.618 * err_min and xadRatio <= 1.902 * err_max
wm_pattern := true
array.set(wmLabels, 1, true)
else
array.set(wmLabels, 1, false)
//Deep Crab
if P33 and xabRatio >= 0.886 * err_min and xabRatio <= 0.936 * err_max and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max and xadRatio >= 1.618 * err_min and xadRatio <= 1.902 * err_max
wm_pattern := true
array.set(wmLabels, 2, true)
else
array.set(wmLabels, 2, false)
//Bat
if P44 and xabRatio >= 0.382 * err_min and xabRatio <= 0.55 * err_max and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max and xadRatio >= 0.886 * err_min and xadRatio <= 0.886 * err_max
wm_pattern := true
array.set(wmLabels, 3, true)
else
array.set(wmLabels, 3, false)
//Butterfly
if P55 and xabRatio >= 0.755 * err_min and xabRatio <= 0.816 * err_max and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max and xadRatio >= 1.272 * err_min and xadRatio <= 1.272 * err_max
wm_pattern := true
array.set(wmLabels, 4, true)
else
array.set(wmLabels, 4, false)
//Shark
if P66 and xabRatio >= 0.382 * err_min and xabRatio <= 0.618 * err_max and abcRatio >= 1.13 * err_min and abcRatio <= 1.618 * err_max and xadRatio >= 0.886 * err_min and xadRatio <= 1.13 * err_max
wm_pattern := true
array.set(wmLabels, 5, true)
else
array.set(wmLabels, 5, false)
cancelW = false
cancelA = false
cancelD = false
if wm_pattern and x == x and a == a and b == b and c == c
line.delete(array.get(wmlines, 0))
line.delete(array.get(wmlines, 1))
line.delete(array.get(wmlines, 2))
line.delete(array.get(wmlines, 3))
line.delete(array.get(wmlines, 4))
line.delete(array.get(wmlines, 5))
line.delete(array.get(wmlines, 6))
line.delete(array.get(wmlines, 7))
label.delete(array.get(wmlabel, 0))
cancelW := true
cancelW
if abcd_pattern and a == a and b == b and c == c
line.delete(array.get(wmlines, 1))
line.delete(array.get(wmlines, 2))
line.delete(array.get(wmlines, 3))
label.delete(array.get(wmlabel, 0))
cancelA := true
cancelA
if double_pattern and a == a and b == b and c == c
line.delete(array.get(wmlines, 5))
label.delete(array.get(wmlabel, 0))
cancelD := true
cancelD
if wm_pattern
xa = line.new(y1=x, y2=a, x1=xBar, x2=aBar, color=zigzagColor, width=zigzagWidth, style=zigzagStyle,force_overlay = true)
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=zigzagColor, width=zigzagWidth, style=zigzagStyle,force_overlay = true)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=zigzagColor, width=zigzagWidth, style=zigzagStyle,force_overlay = true)
cd = line.new(y1=c, y2=d, x1=cBar, x2=dBar, color=zigzagColor, width=zigzagWidth, style=zigzagStyle,force_overlay = true)
xb = line.new(y1=x, y2=b, x1=xBar, x2=bBar, color=zigzagColor, width=zigzagWidth, style=zigzagStyle,force_overlay = true)
bd = line.new(y1=b, y2=d, x1=bBar, x2=dBar, color=zigzagColor, width=zigzagWidth, style=zigzagStyle,force_overlay = true)
xd = line.new(y1=x, y2=d, x1=xBar, x2=dBar, color=zigzagColor, width=zigzagWidth, style=zigzagStyle,force_overlay = true)
ac = line.new(y1=a, y2=c, x1=aBar, x2=cBar, color=zigzagColor, width=zigzagWidth, style=zigzagStyle,force_overlay = true)
array.set(wmlines, 0, xa)
array.set(wmlines, 1, ab)
array.set(wmlines, 2, bc)
array.set(wmlines, 3, cd)
array.set(wmlines, 4, xb)
array.set(wmlines, 5, bd)
array.set(wmlines, 6, xd)
array.set(wmlines, 7, ac)
array.set(wmtype, 0, dir)
linefill.new(xa, xb, color=color.rgb(44, 93, 136, 94))
linefill.new(bc, bd, color=color.rgb(44, 93, 136, 94))
if abcd_pattern and not wm_pattern
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=zigzagColor, width=zigzagWidth, style=zigzagStyle)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=zigzagColor, width=zigzagWidth, style=zigzagStyle)
cd = line.new(y1=c, y2=d, x1=cBar, x2=dBar, color=zigzagColor, width=zigzagWidth, style=zigzagStyle)
array.set(wmlines, 1, ab)
array.set(wmlines, 2, bc)
array.set(wmlines, 3, cd)
array.set(wmtype, 0, dir)
if double_pattern and not wm_pattern
bd = line.new(y1=b, y2=d, x1=bBar, x2=dBar, color=zigzagColor, width=zigzagWidth, style=zigzagStyle)
array.set(wmlines, 5, bd)
array.set(wmtype, 0, dir)
if wm_pattern or abcd_pattern or double_pattern
array.set(wmlabel, 0, get_harmonic_label(wmLabels, dir, d, dBar))
pattern = wm_pattern and not wm_pattern or abcd_pattern and not abcd_pattern or double_pattern and not double_pattern
pattern
zigzag(PATTERN10, zigzagpivots1, zigzagpivotbars1, zigzagpivotdirs1)
zigzag(PATTERN20, zigzagpivots2, zigzagpivotbars2, zigzagpivotdirs2)
zigzag(PATTERN30, zigzagpivots3, zigzagpivotbars3, zigzagpivotdirs3)
zigzag(PATTERN40, zigzagpivots4, zigzagpivotbars4, zigzagpivotdirs4)
wm_pattern1 = detect_harmonic_pattern(zigzagpivots1, zigzagpivotbars1, zigzagpivotdirs1, wmlines1, wmLabel1, wmtype1, wmLabels1, COLORP1, zigzag1Width, zigzag1Style, PATTERN1)
wm_pattern2 = detect_harmonic_pattern(zigzagpivots2, zigzagpivotbars2, zigzagpivotdirs2, wmlines2, wmLabel2, wmtype2, wmLabels2, COLORP2, zigzag2Width, zigzag2Style, PATTERN2)
wm_pattern3 = detect_harmonic_pattern(zigzagpivots3, zigzagpivotbars3, zigzagpivotdirs3, wmlines3, wmLabel3, wmtype3, wmLabels3, COLORP3, zigzag3Width, zigzag3Style, PATTERN3)
wm_pattern4 = detect_harmonic_pattern(zigzagpivots4, zigzagpivotbars4, zigzagpivotdirs4, wmlines4, wmLabel4, wmtype4, wmLabels4, COLORP4, zigzag4Width, zigzag4Style, PATTERN4)
alertcondition(wm_pattern1 or wm_pattern2 or wm_pattern3 or wm_pattern4, title='Harmonic Alert', message='Harmonic Alert {{ticker}}')
var stats = table.new(position=position.top_right, columns=8, rows=DETECT3 + 2, border_width=1)
if barstate.islast and showStatTable
if PATTERN1
table.cell(table_id=stats, column=0, row=0, text='Zigzag ' + str.tostring(PATTERN10), bgcolor=color.black, text_color=color.white)
table.cell(table_id=stats, column=0, row=1, text='Price', bgcolor=color.black, text_color=color.white)
table.cell(table_id=stats, column=1, row=1, text='BarIndex', bgcolor=color.black, text_color=color.white)
for i = 0 to array.size(zigzagpivots1) - 1 by 1
bgcolor = array.get(zigzagpivotdirs1, i) == 1 ? color.lime : color.orange
table.cell(table_id=stats, column=0, row=i + 2, text=str.tostring(array.get(zigzagpivots1, i)), bgcolor=bgcolor)
table.cell(table_id=stats, column=1, row=i + 2, text=str.tostring(array.get(zigzagpivotbars2, i)), bgcolor=bgcolor)
if PATTERN2
table.cell(table_id=stats, column=2, row=0, text='Zigzag ' + str.tostring(PATTERN20), bgcolor=color.black, text_color=color.white)
table.cell(table_id=stats, column=2, row=1, text='Price', bgcolor=color.black, text_color=color.white)
table.cell(table_id=stats, column=3, row=1, text='BarIndex', bgcolor=color.black, text_color=color.white)
for i = 0 to array.size(zigzagpivots2) - 1 by 1
bgcolor = array.get(zigzagpivotdirs2, i) == 1 ? color.lime : color.orange
table.cell(table_id=stats, column=2, row=i + 2, text=str.tostring(array.get(zigzagpivots2, i)), bgcolor=bgcolor)
table.cell(table_id=stats, column=3, row=i + 2, text=str.tostring(array.get(zigzagpivotbars2, i)), bgcolor=bgcolor)
if PATTERN3
table.cell(table_id=stats, column=4, row=0, text='Zigzag ' + str.tostring(PATTERN30), bgcolor=color.black, text_color=color.white)
table.cell(table_id=stats, column=4, row=1, text='Price', bgcolor=color.black, text_color=color.white)
table.cell(table_id=stats, column=5, row=1, text='BarIndex', bgcolor=color.black, text_color=color.white)
for i = 0 to array.size(zigzagpivots3) - 1 by 1
bgcolor = array.get(zigzagpivotdirs3, i) == 1 ? color.lime : color.orange
table.cell(table_id=stats, column=4, row=i + 2, text=str.tostring(array.get(zigzagpivots3, i)), bgcolor=bgcolor)
table.cell(table_id=stats, column=5, row=i + 2, text=str.tostring(array.get(zigzagpivotbars3, i)), bgcolor=bgcolor)
if PATTERN4
table.cell(table_id=stats, column=6, row=0, text='Zigzag ' + str.tostring(PATTERN40), bgcolor=color.black, text_color=color.white)
table.cell(table_id=stats, column=6, row=1, text='Price', bgcolor=color.black, text_color=color.white)
table.cell(table_id=stats, column=7, row=1, text='BarIndex', bgcolor=color.black, text_color=color.white)
for i = 0 to array.size(zigzagpivots4) - 1 by 1
bgcolor = array.get(zigzagpivotdirs4, i) == 1 ? color.lime : color.orange
table.cell(table_id=stats, column=6, row=i + 2, text=str.tostring(array.get(zigzagpivots4, i)), bgcolor=bgcolor)
table.cell(table_id=stats, column=7, row=i + 2, text=str.tostring(array.get(zigzagpivotbars4, i)), bgcolor=bgcolor)
/////////
// functions
get(arr, index) =>
index < array.size(arr) ? array.get(arr, index) : na
busted(highs, lows, times, bounces) =>
array.shift(highs)
array.shift(lows)
array.shift(times)
array.shift(bounces) or true
bounced(bounces) =>
status = array.get(bounces, 0)
array.set(bounces, 0, true)
status
// A. CORE
ceiling = math.max(high, close , open )
floor = math.min(low, close , open )
buying = close >= open and high != low
selling = close <= open and low != high
green = close > open and close > close
red = close < open and close < close
gapup = open > close
gapdown = open < close
higher = high > high
lowerf = low < low
bullish = green and higher
bearish = red and lowerf
// notable price actions
bullishEngulf = selling and (gapdown or lowerf) and bullish and close > open
bearishEngulf = buying and (gapup or higher) and bearish and close < open
breakHigh = (selling or selling ) and buying and close > ceiling
breakLow = (buying or buying ) and selling and close < floor
whiteSoldiers = bearish and buying and bullish and bullish and close > high
blackCrows = bullish and selling and bearish and bearish and close < low
// pivot setups
soaring = bullishEngulf or breakHigh or whiteSoldiers
tumbling = bearishEngulf or breakLow or blackCrows
reversal = switch
whiteSoldiers => not soaring and not soaring
blackCrows => not tumbling and not tumbling
breakHigh => not soaring and (bearish or bearish )
breakLow => not tumbling and (bullish or bullish )
continuation = switch
breakHigh => bullish and close > high and not bearish
breakLow => bearish and close < low and not bullish
engulfing = (bullishEngulf or bearishEngulf) and (higher or lowerf )
// B. PIVOT ZONES
var buyzoneHigh = array.new_float(0)
var buyzoneLow = array.new_float(0)
var buyzoneTime = array.new_int(0)
var bounceUp = array.new_bool(0)
var sellzoneHigh = array.new_float(0)
var sellzoneLow = array.new_float(0)
var sellzoneTime = array.new_int(0)
var bounceDown = array.new_bool(0)
// 1. Broken Pivot Zones
brokenHigh = while get(sellzoneHigh, 0) < high
busted(sellzoneHigh, sellzoneLow, sellzoneTime, bounceDown)
brokenLow = while get(buyzoneLow, 0) > low
busted(buyzoneHigh, buyzoneLow, buyzoneTime, bounceUp)
// 2. Distribution/Accumulation Bar and Pivot Bar
upturn = soaring and (reversal or continuation or engulfing)
downturn = tumbling and (reversal or continuation or engulfing)
dacbar = switch
upturn => whiteSoldiers ? 3 : (breakHigh and selling ? 2 : 1)
downturn => blackCrows ? 3 : (breakLow and buying ? 2 : 1)
pivotbar = switch
upturn => whiteSoldiers ? 2 : (green ? 1 : 0)
downturn => blackCrows ? 2 : (red ? 1 : 0)
// 3. Pivot Zone Values
pzHigh = float(na)
pzLow = float(na)
switch
upturn =>
// low at wick
pzLow := math.min(low , low , low , low)
// high at wick or open
pzHigh := switch
close > high => high
open > open => open
=> open
downturn =>
// high at wick
pzHigh := math.max(high , high , high , high)
// low at wick or open
pzLow := switch
close < low => low
open < open => open
=> open
// 4. Overlapping Pivot Zones
overlap = switch
upturn => get(buyzoneHigh, 0) >= pzLow
downturn => get(sellzoneLow, 0) <= pzHigh
replace = switch
overlap and upturn => bounced(bounceUp)
overlap and downturn => bounced(bounceDown)
// remove replaced zone or adjust overlapped zone
switch
replace and upturn => busted(buyzoneHigh, buyzoneLow, buyzoneTime, bounceUp)
replace and downturn => busted(sellzoneHigh, sellzoneLow, sellzoneTime, bounceDown)
overlap and upturn => array.set(buyzoneHigh, 0, pzLow)
overlap and downturn => array.set(sellzoneLow, 0, pzHigh)
// 5. Pivot Zones Queue
switch
upturn =>
array.unshift(buyzoneHigh, pzHigh)
array.unshift(buyzoneLow, pzLow)
array.unshift(buyzoneTime, time )
array.unshift(bounceUp, false)
downturn =>
array.unshift(sellzoneHigh, pzHigh)
array.unshift(sellzoneLow, pzLow)
array.unshift(sellzoneTime, time )
array.unshift(bounceDown, false)
// 6. Pivot Zones Markup
maxbox(redraw) => redraw ? 22 : na
newbox(bg) =>
box.new(0, 0, 0, 0, xloc=xloc.bar_time, border_color=color.rgb(127,127,127,50), bgcolor=bg, extend=extend.right,force_overlay = true)
render(boxes, index, highs, lows, times) =>
ibox = get(boxes, index)
top = get(highs, index)
bottom = get(lows, index)
left = get(times, index)
overlapped = if index > 0
lastbox = index - 1
top == get(lows, lastbox) or bottom == get(highs, lastbox)
box.set_lefttop(ibox, left, overlapped ? na : top)
box.set_rightbottom(ibox, time, overlapped ? na : bottom)
textM=""
if int(top-bottom)==0
textM:= str.tostring(top-bottom)
else
textM := str.tostring(int(top-bottom))
box.set_text(ibox,"Strength of Order Block = "+ textM)
box.set_text_color(ibox,color.gray)
box.set_text_halign(ibox,text.align_left)
box.set_text_size(ibox,size.small)
var supply = input.color(color.rgb(253,224,110,50), 'Supply Zones')
var demand = input.color(color.rgb(212,224,255,50), 'Demand Zones')
var buyBox = array.new_box(0)
var sellBox = array.new_box(0)
for i = 0 to maxbox(na(close ))
array.push(buyBox, newbox(demand))
array.push(sellBox, newbox(supply))
for i = 0 to maxbox(upturn or brokenLow)
render(buyBox, i, buyzoneHigh, buyzoneLow, buyzoneTime)
for i = 0 to maxbox(downturn or brokenHigh)
render(sellBox, i, sellzoneHigh, sellzoneLow, sellzoneTime)
// C. ALERTS
if brokenHigh
alert('Breakout', alert.freq_once_per_bar)
if brokenLow
alert('Breakdown', alert.freq_once_per_bar)
if upturn or downturn
setup = switch
whiteSoldiers => 'White Soldiers'
blackCrows => 'Black Crows'
breakHigh => bullishEngulf ? 'Engulf & Break High' : 'Break High'
breakLow => bearishEngulf ? 'Engulf & Break Low' : 'Break Low'
bullishEngulf => 'Bullish Engulf'
bearishEngulf => 'Bearish Engulf'
occurence = replace ? 'Replace' : (overlap ? 'Bounce' : 'Fresh')
message = setup + ' (' + occurence + ')'
alert(message, alert.freq_once_per_bar_close)
// The code ended here TOTOOLI X11
💎 Diamond Algo 💎//@version=5
indicator("💎 Diamond Algo 💎", overlay = true)
// Get user input
// Dashboard
showDashboard = input(true, "Smart Panel", group = 'Dashboard Settings')
locationDashboard = input.string("Bottom Right", "Location", , group = 'Dashboard Settings', inline = 'agfh1')
sizeDashboard = input.string("Small", "Size", , group = 'Dashboard Settings', inline = 'agfh1')
// Signals
nbuysell = input.bool(true, 'Show Signals', inline = "BSNM",group='BUY AND SELL SIGNALS SETTINGS')
nsensitivity = input.float(defval=2, title="Sensitivity", minval=1, maxval=20, group='BUY AND SELL SIGNALS SETTINGS')
smartsignalsonly = input.bool(false, 'Smart Signals Only',group='BUY AND SELL SIGNALS SETTINGS')
barcoloringmode = input.string("Trend", "Bar Coloring", , inline="levels", group = 'BUY AND SELL SIGNALS SETTINGS')
//candlecolor = input.bool(true, 'Buy/Sell Signal', inline = "BSNM",group='BUY/SELL SIGNAL')
ema200con = ta.ema(close,200)
// Risk Management
levels = input.bool(false, "Take Profit/ Stop-Loss Areas" , group = "RISK MANAGEMENT SETTINGS" , inline = "MMDB2")
lvlLines = true
linesStyle = "DASHED"
lvlDistance = input.int(20, "Distance", 1, inline="levels2", group = "RISK MANAGEMENT SETTINGS")
lvlDecimals = input.int(2, " Decimals", 1, 8, inline="levels2", group = "RISK MANAGEMENT SETTINGS")
atrRisk = input.int(1, "Risk % ", 1, group = "RISK MANAGEMENT SETTINGS" , inline="levels3")
atrLen = input.int(14, " ATR Length", 1, group = "RISK MANAGEMENT SETTINGS" , inline="levels3")
decimals = lvlDecimals == 1 ? "#.#" : lvlDecimals == 2 ? "#.##" : lvlDecimals == 3 ? "#.###" : lvlDecimals == 4 ? "#.####" : lvlDecimals == 5 ? "#.#####" : lvlDecimals == 6 ? "#.######" : lvlDecimals == 7 ? "#.#######" : "#.########"
// Trend Features
LongTrendAverage = input(false, 'Trend Cloud', group='INDICATOR OVERLAY', inline = '1')
TrendFollower = input(false, 'Trend Follower', group='INDICATOR OVERLAY', inline = '1')
ShowComulus = input(false, 'Comulus Cloud', group='INDICATOR OVERLAY', inline = '2')
CirrusCloud = input(false, 'Cirrus Cloud', group='INDICATOR OVERLAY', inline = '2')
ShowSmartTrail = input(false,'Smart Trail', group='INDICATOR OVERLAY', inline = '3')
Showtrendlines = input(false,'Trend Lines', group='INDICATOR OVERLAY', inline = '3')
showsr = input(false, title="Support & Resistance", group = 'INDICATOR OVERLAY', inline = '4')
// Input settings
history_of_demand_to_keep = 20
show_zigzag = false
show_price_action_labels = false
swing_length = 8
box_width = 4
box_extend_option = "Both"
res = ''
s1 = request.security(syminfo.tickerid, res, showsr, gaps=barmerge.gaps_on)
demand_color = #0395ff4d
supply_color = #ff00024d
// Signal Generation
supertrend(_close, factor, atrLen) =>
atr = ta.atr(atrLen)
upperBand = _close + factor * atr
lowerBand = _close - factor * atr
prevLowerBand = nz(lowerBand )
prevUpperBand = nz(upperBand )
lowerBand := lowerBand > prevLowerBand or close < prevLowerBand ? lowerBand : prevLowerBand
upperBand := upperBand < prevUpperBand or close > prevUpperBand ? upperBand : prevUpperBand
int direction = na
float superTrend = na
prevSuperTrend = superTrend
if na(atr )
direction := 1
else if prevSuperTrend == prevUpperBand
direction := close > upperBand ? -1 : 1
else
direction := close < lowerBand ? 1 : -1
superTrend := direction == -1 ? lowerBand : upperBand
// SMA
ocAvg = math.avg(open, close)
sma4 = ta.sma(close, 50)
sma5 = ta.sma(close, 200)
sma9 = ta.sma(close, 13)
psar = ta.sar(0.02, 0.02, 0.2)
//*in Easy Words Super Trend + SMA = Signals
= supertrend(close, nsensitivity*2, 11)
source = close, period = 150
// Colors
green = #0395ff, green2 = #0395ff
red = #ff0002, red2 = #ff0002
adxlen = 15
dilen = 15
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : up > down and up > 0 ? up : 0
minusDM = na(down) ? na : down > up and down > 0 ? down : 0
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
adx(dilen, adxlen) =>
= dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
adx
sig = adx(dilen, adxlen)
// range ADX threshold
sidewaysThreshold = 15
// boolean expression to see if the ADX is below tehe sideways threshold
bool isSideways = sig < sidewaysThreshold
// adding the option to color the bars when in a trading range
useBarColor = true
bColor = isSideways ? color.new(#4b148d, 0) : na
//barcolor(isSideways and barcoloringmode == "Trend" ? bColor : na)
trendbarcolor = isSideways and barcoloringmode == "Trend" ? color.new(#4b148d, 0) : close > supertrend ? #0395ff : #ff0002
barcolor(trendbarcolor)
// High Lows
y1 = low - (ta.atr(30) * 2), y1B = low - ta.atr(30)
y2 = high + (ta.atr(30) * 2), y2B = high + ta.atr(30)
bull = ta.crossover(close, supertrend) and close >= sma9
bear = ta.crossunder(close, supertrend) and close <= sma9
// Plots
windowsize = 100
offset = 0.9
sigma = 6
//plot(ta.alma(source, windowsize, offset, sigma))
windowsize2 = 310
offset2 = 0.85
sigma2 = 32
//plot(ta.alma(source, windowsize2, offset2, sigma2))
// Chart Features
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x ), t)
smoothrng = ta.ema(avrng, wper) * m
smoothrng
smrng = smoothrng(close, 22, 6)
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt ) ? x - r < nz(rngfilt ) ? nz(rngfilt ) : x - r : x + r > nz(rngfilt ) ? nz(rngfilt ) : x + r
rngfilt
filt = rngfilt(close, smrng)
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
upward = 0.0
upward := filt > filt ? nz(upward ) + 1 : filt < filt ? 0 : nz(upward )
downward = 0.0
downward := filt < filt ? nz(downward ) + 1 : filt > filt ? 0 : nz(downward )
filtcolor = upward > 0 ? color.new(#00e2ff, 50) : downward > 0 ? color.new(#fe0100, 50) : color.new(#56328f, 0)
plot(TrendFollower ? filt : na, color=filtcolor, linewidth=1, title='Trend Tracer')
// Trend Cloud
tclength = 600
hullma = ta.wma(2*ta.wma(close, tclength/2)-ta.wma(close, tclength), math.floor(math.sqrt(tclength)))
plot(LongTrendAverage ? hullma : na, 'Trend Cloud', linewidth=4, color=close > hullma ? color.new(#00e2ff, 65) : color.new(#fe0100, 65))
// Comulus Cloud
candle = ta.alma(source, windowsize2, offset2, sigma2)
reach = ta.alma(source, windowsize, offset, sigma)
candlep = plot(ShowComulus ? candle : na, color=color.new(color.white, 100))
reachp = plot(ShowComulus ? reach : na, color=color.new(color.white, 100))
fill(reachp, candlep, color= candle > reach ? color.new(#fe0100, 85) : color.new(#00e2ff, 85))
// Chart Features
x1 = 22
x2 = 9
x3 = 15
x4 = 5
smoothrngX1(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x ), t)
smoothrngX1 = ta.ema(avrng, wper) * m
smoothrngX1
smrngx1x = smoothrngX1(close, x1, x2)
smrngx1x2 = smoothrngX1(close, x3, x4)
rngfiltx1x1(x, r) =>
rngfiltx1x1 = x
rngfiltx1x1 := x > nz(rngfiltx1x1 ) ? x - r < nz(rngfiltx1x1 ) ? nz(rngfiltx1x1 ) : x - r : x + r > nz(rngfiltx1x1 ) ? nz(rngfiltx1x1 ) : x + r
rngfiltx1x1
filtx1 = rngfiltx1x1(close, smrngx1x)
filtx12 = rngfiltx1x1(close, smrngx1x2)
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
upwardx1 = 0.0
upwardx1 := filtx1 > filtx1 ? nz(upwardx1 ) + 1 : filtx1 < filtx1 ? 0 : nz(upwardx1 )
downwardx1 = 0.0
downwardx1 := filtx1 < filtx1 ? nz(downwardx1 ) + 1 : filtx1 > filtx1 ? 0 : nz(downwardx1 )
filtx1colorx1 = color.rgb(0, 187, 212, 100)
xxx1 = plot(CirrusCloud ? filtx1 : na, color=filtx1colorx1, linewidth=1, title='Trend Tracer', editable = false)
xxx2 = plot(CirrusCloud ? filtx12 : na, color=filtx1colorx1, linewidth=1, title='Trend Tracer', editable = false)
fill(xxx1, xxx2, color= filtx1 > filtx12 ? color.new(#fd0205, 65) : color.new(#0395fc, 65))
buy = bull and nbuysell and smartsignalsonly == false ? label.new(bar_index, y1, close > ema200con ? "Smart\nBuy" : "Buy", xloc.bar_index, yloc.price, #0395fc, label.style_label_up, color.white, size.normal) : na
sell = bear and nbuysell and smartsignalsonly == false ? label.new(bar_index, y2, close < ema200con ? "Smart\nSell" : "Sell", xloc.bar_index, yloc.price, #fd0205, label.style_label_down, color.white, size.normal) : na
SmartBuy = bull and nbuysell and close > ema200con and smartsignalsonly == true ? label.new(bar_index, y1, close > ema200con ? "Smart\nBuy" : "Buy", xloc.bar_index, yloc.price, #0395fc, label.style_label_up, color.white, size.normal) : na
SmartSell = bear and nbuysell and close < ema200con and smartsignalsonly == true ? label.new(bar_index, y2, close < ema200con ? "Smart\nSell" : "Sell", xloc.bar_index, yloc.price, #fd0205, label.style_label_down, color.white, size.normal) : na
// Other initializations
avg_volume = ta.sma(volume, 20)
very_weak_multiplier = 0.5
weak_multiplier = 1
strong_multiplier = 1.5
// Rejection handling
var int demandRejections = array.new_int(history_of_demand_to_keep, 0)
var int supplyRejections = array.new_int(history_of_demand_to_keep, 0)
var int demandCreationBars = array.new_int(history_of_demand_to_keep, na)
var int supplyCreationBars = array.new_int(history_of_demand_to_keep, na)
var box current_demand_box = array.new_box(history_of_demand_to_keep, na)
var box current_supply_box = array.new_box(history_of_demand_to_keep, na)
f_check_demand_rejections() =>
for i = 0 to history_of_demand_to_keep - 1
if not na(array.get(demandCreationBars, i))
if bar_index - array.get(demandCreationBars, i) > 15 and bar_index - array.get(demandCreationBars, i) % 15 == 0
label.new(bar_index, high, "Checking demand rejection", color=#fd0205)
dBox = array.get(current_demand_box, i)
if (na(dBox))
continue
withinBox = (high >= box.get_bottom(dBox) and high <= box.get_top(dBox)) or (close >= box.get_bottom(dBox) and close <= box.get_top(dBox))
bearishCandlesCount = math.sum(close < open ? 1 : 0, 15)
if withinBox and bearishCandlesCount >= 7
label.new(bar_index, low, "Bearish count > 7", color=#0395fc)
array.set(demandRejections, i, array.get(demandRejections, i) + 1)
f_check_supply_rejections() =>
for i = 0 to history_of_demand_to_keep - 1
if not na(array.get(supplyCreationBars, i))
if bar_index - array.get(supplyCreationBars, i) > 15 and bar_index - array.get(supplyCreationBars, i) % 15 == 0
label.new(bar_index, low, "Checking supply rejection", color=#fd0205)
sBox = array.get(current_supply_box, i)
if (na(sBox))
continue
withinBox = (low <= box.get_top(sBox) and low >= box.get_bottom(sBox)) or (close <= box.get_top(sBox) and close >= box.get_bottom(sBox))
bullishCandlesCount = math.sum(close > open ? 1 : 0, 15)
if withinBox and bullishCandlesCount >= 7
label.new(bar_index, high, "Bullish count > 7", color=#0395fc)
array.set(supplyRejections, i, array.get(supplyRejections, i) + 1)
f_array_add_pop(array, new_value_to_add) =>
array.unshift(array, new_value_to_add)
array.pop(array)
f_sh_sl_labels(array, swing_type) =>
var string label_text = na
if swing_type == 1
if array.get(array, 0) >= array.get(array, 1)
label_text := 'HH'
else
label_text := 'LH'
label.new(bar_index - swing_length, array.get(array,0), text = label_text, style=label.style_label_down, textcolor = color.white, color = color.new(color.white, 100), size = size.tiny)
else if swing_type == -1
if array.get(array, 0) >= array.get(array, 1)
label_text := 'HL'
else
label_text := 'LL'
label.new(bar_index - swing_length, array.get(array,0), text = label_text, style=label.style_label_up, textcolor = color.white, color = color.new(color.white, 100), size = size.tiny)
f_check_overlapping(new_poi, box_array, atr) =>
atr_threshold = atr * 2
okay_to_draw = true
for i = 0 to array.size(box_array) - 1
top = box.get_top(array.get(box_array, i))
bottom = box.get_bottom(array.get(box_array, i))
poi = (top + bottom) / 2
upper_boundary = poi + atr_threshold
lower_boundary = poi - atr_threshold
if new_poi >= lower_boundary and new_poi <= upper_boundary
okay_to_draw := false
break
else
okay_to_draw := true
okay_to_draw
f_supply_demand(value_array, bn_array, box_array, label_array, box_type, atr) =>
atr_buffer = atr * (box_width / 10)
box_left = array.get(bn_array, 0)
box_right = bar_index + 20
var float box_top = 0.00
var float box_bottom = 0.00
var float poi = 0.00
if box_type == 1
box_top := array.get(value_array, 0)
box_bottom := box_top - atr_buffer
poi := (box_top + box_bottom) / 2
else if box_type == -1
box_bottom := array.get(value_array, 0)
box_top := box_bottom + atr_buffer
poi := (box_top + box_bottom) / 2
okay_to_draw = f_check_overlapping(poi, box_array, atr)
swing_volume = volume
var string strength_text = ""
highest_volume_last_20 = ta.highest(volume, 20)
volume_percentage = math.round(swing_volume / highest_volume_last_20 * 100)
volume_percentage := math.min(volume_percentage, 100) // Cap the volume percentage to 100
var extend_option = extend.right
if box_extend_option == "Right"
extend_option := extend.right
else if box_extend_option == "Both"
extend_option := extend.both
if box_type == 1 and okay_to_draw and s1
box.delete( array.get(box_array, array.size(box_array) - 5) )
f_array_add_pop(box_array, box.new( left = box_left, top = box_top, right = box_right, bottom = box_bottom, border_color = #fd020580, border_width=1,
bgcolor = supply_color, extend = extend_option, text = strength_text, text_halign = text.align_right, text_valign = text.align_center, text_color = color.white, text_size = size.small, xloc = xloc.bar_index))
box.delete( array.get(label_array, array.size(label_array) - 5) )
f_array_add_pop(label_array, box.new( left = box_left, top = poi, right = box_right, bottom = poi, border_color = #fd020580, border_width=1, border_style=line.style_dotted,
bgcolor = color.new(color.black,100), extend = extend_option, text = '', text_halign = text.align_left, text_valign = text.align_center, text_color = color.white, text_size = size.small, xloc = xloc.bar_index))
else if box_type == -1 and okay_to_draw and s1
box.delete( array.get(box_array, array.size(box_array) - 5) )
f_array_add_pop(box_array, box.new( left = box_left, top = box_top, right = box_right, bottom = box_bottom, border_color = #0395fc80, border_width=1,
bgcolor = demand_color, extend = extend_option, text = strength_text, text_halign = text.align_right, text_valign = text.align_center, text_color = color.white, text_size = size.small, xloc = xloc.bar_index))
box.delete( array.get(label_array, array.size(label_array) - 5) )
f_array_add_pop(label_array, box.new( left = box_left, top = poi, right = box_right, bottom = poi, border_color = #0395fc80, border_width=1, border_style=line.style_dotted,
bgcolor = color.new(color.black,100), extend = extend_option, text = '', text_halign = text.align_left, text_valign = text.align_center, text_color = color.white, text_size = size.small, xloc = xloc.bar_index))
f_sd_to_bos(box_array, bos_array, label_array, zone_type) =>
if zone_type == 1
for i = 0 to array.size(box_array) - 1
level_to_break = box.get_top(array.get(box_array,i))
if close >= level_to_break
box.delete(array.get(box_array, i))
box.delete(array.get(label_array, i))
if zone_type == -1
for i = 0 to array.size(box_array) - 1
level_to_break = box.get_bottom(array.get(box_array,i))
if close <= level_to_break
box.delete(array.get(box_array, i))
box.delete(array.get(label_array, i))
f_extend_box_endpoint(box_array) =>
for i = 0 to array.size(box_array) - 1
box.set_right(array.get(box_array, i), bar_index + 30) // Extend only 20 bars
atr567 = ta.atr(50)
swing_high = ta.pivothigh(high, swing_length, swing_length)
swing_low = ta.pivotlow(low, swing_length, swing_length)
var swing_high_values = array.new_float(5,0.00)
var swing_low_values = array.new_float(5,0.00)
var swing_high_bns = array.new_int(5,0)
var swing_low_bns = array.new_int(5,0)
var current_supply_poi = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi = array.new_box(history_of_demand_to_keep, na)
var supply_bos = array.new_box(5, na)
var demand_bos = array.new_box(5, na)
if not na(swing_high)
f_array_add_pop(swing_high_values, swing_high)
f_array_add_pop(swing_high_bns, bar_index )
if show_price_action_labels
f_sh_sl_labels(swing_high_values, 1)
f_supply_demand(swing_high_values, swing_high_bns, current_supply_box, current_supply_poi, 1, atr567)
else if not na(swing_low)
f_array_add_pop(swing_low_values, swing_low)
f_array_add_pop(swing_low_bns, bar_index )
if show_price_action_labels
f_sh_sl_labels(swing_low_values, -1)
f_supply_demand(swing_low_values, swing_low_bns, current_demand_box, current_demand_poi, -1, atr567)
f_sd_to_bos(current_supply_box, supply_bos, current_supply_poi, 1)
f_sd_to_bos(current_demand_box, demand_bos, current_demand_poi, -1)
f_extend_box_endpoint(current_supply_box)
f_extend_box_endpoint(current_demand_box)
// Inside the main execution, after the box is drawn, check for rejections
if not na(swing_low)
f_array_add_pop(swing_low_values, swing_low)
f_array_add_pop(swing_low_bns, bar_index )
if show_price_action_labels
f_sh_sl_labels(swing_low_values, -1)
f_supply_demand(swing_low_values, swing_low_bns, current_demand_box, current_demand_poi, -1, atr567)
f_check_demand_rejections()
if not na(swing_high)
f_array_add_pop(swing_high_values, swing_high)
f_array_add_pop(swing_high_bns, bar_index )
if show_price_action_labels
f_sh_sl_labels(swing_high_values, 1)
f_supply_demand(swing_high_values, swing_high_bns, current_supply_box, current_supply_poi, 1, atr567)
f_check_supply_rejections()
trigger2 = bull ? 1 : 0
countBull = ta.barssince(bull)
countBear = ta.barssince(bear)
trigger = nz(countBull, bar_index) < nz(countBear, bar_index) ? 1 : 0
atrBand = ta.atr(atrLen) * atrRisk
atrStop = trigger == 1 ? low - atrBand : high + atrBand
currentposition = countBull > countBear ? 'Sell' : 'Buy'
lastTrade(close) => ta.valuewhen(bull or bear , close, 0)
entry = levels ? label.new(time, close, "ENTRY " + str.tostring(lastTrade(close), decimals), xloc.bar_time, yloc.price, color.orange, label.style_label_left, color.white, size.normal) : na
label.set_x(entry, label.get_x(entry) + math.round(ta.change(time) * lvlDistance))
label.set_y(entry, lastTrade(close))
label.delete(entry )
stop_y = lastTrade(atrStop)
stop = levels ? label.new(time, close, "SL " + str.tostring(stop_y, decimals), xloc.bar_time, yloc.price, red2, label.style_label_left, color.white, size.normal) : na
label.set_x(stop, label.get_x(stop) + math.round(ta.change(time) * lvlDistance))
label.set_y(stop, stop_y)
label.delete(stop )
tp1Rl_y = (lastTrade(close)-lastTrade(atrStop))*1 + lastTrade(close)
tp1Rl = levels ? label.new(time, close, "1:1 TP " + str.tostring(tp1Rl_y, decimals), xloc.bar_time, yloc.price, green2, label.style_label_left, color.white, size.normal ) : na
label.set_x(tp1Rl, label.get_x(tp1Rl) + math.round(ta.change(time) * lvlDistance))
label.set_y(tp1Rl, tp1Rl_y)
label.delete(tp1Rl )
tp2RL_y = (lastTrade(close)-lastTrade(atrStop))*2 + lastTrade(close)
tp2RL = levels ? label.new(time, close, "2:1 TP " + str.tostring(tp2RL_y, decimals), xloc.bar_time, yloc.price, green2, label.style_label_left, color.white, size.normal) : na
label.set_x(tp2RL, label.get_x(tp2RL) + math.round(ta.change(time) * lvlDistance))
label.set_y(tp2RL, tp2RL_y)
label.delete(tp2RL )
tp3RL_y = (lastTrade(close)-lastTrade(atrStop))*3 + lastTrade(close)
tp3RL = levels ? label.new(time, close, "3:1 TP " + str.tostring(tp3RL_y, decimals), xloc.bar_time, yloc.price, green2, label.style_label_left, color.white, size.normal) : na
label.set_x(tp3RL, label.get_x(tp3RL) + math.round(ta.change(time) * lvlDistance))
label.set_y(tp3RL, tp3RL_y)
label.delete(tp3RL )
style = linesStyle == "SOLID" ? line.style_solid : linesStyle == "DASHED" ? line.style_dashed : line.style_dotted
lineEntry = levels and lvlLines ? line.new(bar_index - (trigger == 0 ? countBull : countBear), lastTrade(close), bar_index + lvlDistance, lastTrade(close), xloc.bar_index, extend.none, color.orange, style, 2) : na, line.delete(lineEntry )
lineStop = levels and lvlLines ? line.new(bar_index - (trigger == 0 ? countBull : countBear), stop_y, bar_index + lvlDistance, stop_y, xloc.bar_index, extend.none, #fe0100, style, 2) : na, line.delete(lineStop )
lineTp1Rl = levels and lvlLines ? line.new(bar_index - (trigger == 0 ? countBull : countBear), tp1Rl_y, bar_index + lvlDistance, tp1Rl_y, xloc.bar_index, extend.none, green2, style, 2) : na, line.delete(lineTp1Rl )
lineTp2RL = levels and lvlLines ? line.new(bar_index - (trigger == 0 ? countBull : countBear), tp2RL_y, bar_index + lvlDistance, tp2RL_y, xloc.bar_index, extend.none, green2, style, 2) : na, line.delete(lineTp2RL )
lineTp3RL = levels and lvlLines ? line.new(bar_index - (trigger == 0 ? countBull : countBear), tp3RL_y, bar_index + lvlDistance, tp3RL_y, xloc.bar_index, extend.none, green2, style, 2) : na, line.delete(lineTp3RL )
alertcondition(bull, title='Buy Signal', message = "BUY")
alertcondition(bear, title='Buy Signal', message = "BUY")
//import protradingart/pta_plot/6 as pp
//pp.peakprofit(bull, bear)
//
////////////////////////////////////////////////////////////////////////////////////////////////
// Functions
// Functions
f_chartTfInMinutes() =>
float _resInMinutes = 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)
// Get components
vosc = ta.obv - ta.ema(ta.obv, 20)
bs = ta.ema(nz(math.abs((open - close) / (high - low) * 100)), 3)
ema = ta.ema(close, 200)
emaBull = close > ema
equal_tf(res) => str.tonumber(res) == f_chartTfInMinutes()
higher_tf(res) => str.tonumber(res) > f_chartTfInMinutes()
too_small_tf(res) => (timeframe.isweekly and res=="1") or (timeframe.ismonthly and str.tonumber(res) < 10)
securityNoRep(sym, res, src) =>
bool bull = na
bull := equal_tf(res) ? src : bull
bull := higher_tf(res) ? request.security(sym, res, src, barmerge.gaps_off, barmerge.lookahead_on) : bull
bull_array = request.security_lower_tf(syminfo.tickerid, higher_tf(res) ? str.tostring(f_chartTfInMinutes()) : too_small_tf(res) ? (timeframe.isweekly ? "3" : "10") : res, src)
if array.size(bull_array) > 1 and not equal_tf(res) and not higher_tf(res)
bull := array.pop(bull_array)
array.clear(bull_array)
bull
TF1Bull = securityNoRep(syminfo.tickerid, "1" , emaBull)
//TF3Bull = securityNoRep(syminfo.tickerid, "3" , emaBull)
TF5Bull = securityNoRep(syminfo.tickerid, "5" , emaBull)
//TF10Bull = securityNoRep(syminfo.tickerid, "10" , emaBull)
TF15Bull = securityNoRep(syminfo.tickerid, "15" , emaBull)
TF30Bull = securityNoRep(syminfo.tickerid, "30" , emaBull)
TF60Bull = securityNoRep(syminfo.tickerid, "60" , emaBull)
//TF120Bull = securityNoRep(syminfo.tickerid, "120" , emaBull)
TF240Bull = securityNoRep(syminfo.tickerid, "240" , emaBull)
//TF720Bull = securityNoRep(syminfo.tickerid, "720" , emaBull)
TFDBull = securityNoRep(syminfo.tickerid, "1440", emaBull)
indicatorTF = "Chart"
// Functions
sqz(bbLen, bbMult, kcLen, kcMult, source) =>
upperBB = ta.sma(source, bbLen) + ta.stdev(source, bbLen) * bbMult
lowerBB = ta.sma(source, bbLen) - ta.stdev(source, bbLen) * bbMult
upperKC = ta.sma(source, kcLen) + ta.sma(ta.tr, kcLen) * kcMult
lowerKC = ta.sma(source, kcLen) - ta.sma(ta.tr, kcLen) * kcMult
sqzOn = lowerBB > lowerKC and upperBB < upperKC
sqzOff = lowerBB < lowerKC and upperBB > upperKC
qqe(rsiLen, rsiSmooth, factor, source, bbLen, bbMult) =>
rsiMa = ta.ema(ta.rsi(source, rsiLen), rsiSmooth)
delta = ta.ema(ta.ema(math.abs(ta.mom(rsiMa, 1)), rsiLen * 2 - 1), rsiLen * 2 - 1) * factor
longBand = 0.0, longBand := rsiMa > longBand and rsiMa > longBand ? math.max(longBand , rsiMa - delta) : rsiMa - delta
shortBand = 0.0, shortBand := rsiMa < shortBand and rsiMa < shortBand ? math.min(shortBand , rsiMa + delta) : rsiMa + delta
cross1 = ta.cross(rsiMa, shortBand )
cross2 = ta.cross(rsiMa, longBand )
trend = 0.0, trend := cross1 ? 1 : cross2 ? -1 : nz(trend , 1)
fastDelta = trend == 1 ? longBand : shortBand
_hist = rsiMa - 50
_line = fastDelta - 50
= ta.bb(_line, bbLen, bbMult)
// Get components
cond(_offset) =>
top = ta.highest(high, 10)
bot = ta.lowest(low, 10)
osc = ta.ema(hlc3, 5) - ta.ema(ohlc4, 20)
oscRis = osc > osc
oscFal = osc < osc
oscA0 = osc > 0
oscB0 = osc < 0
oscTop = oscFal and oscRis
oscBot = oscRis and oscFal
bullR = oscB0 and oscBot and ((osc > ta.valuewhen(oscB0 and oscBot, osc, 1) and bot < ta.valuewhen(oscB0 and oscBot, bot, 1)))
bearR = oscA0 and oscTop and ((osc < ta.valuewhen(oscA0 and oscTop, osc, 1) and top > ta.valuewhen(oscA0 and oscTop, top, 1)))
bullH = oscB0 and oscBot and ((osc < ta.valuewhen(oscB0 and oscBot, osc, 1) and bot > ta.valuewhen(oscB0 and oscBot, bot, 1)))
bearH = oscA0 and oscTop and ((osc > ta.valuewhen(oscA0 and oscTop, osc, 1) and top < ta.valuewhen(oscA0 and oscTop, top, 1)))
= sqz(20, 2, 20, 2, close)
= qqe(6, 6, 3, close, 50, 0.001)
= qqe(6, 5, 1.618, close, 50, 1)
= ta.dmi(14, 14)
[osc , oscRis , oscFal , oscA0 , oscB0 , oscTop , oscBot , bullR , bearR , bullH , bearH , sqzOn , sqzOff , _hist1 , upper1 , lower1 , _hist2 , _line2 , tvr ]
tf = indicatorTF == "Chart" ? timeframe.period : indicatorTF == "1 minute" ? "1" : indicatorTF == "3 minutes" ? "3" : indicatorTF == "5 minutes" ? "5" : indicatorTF == "10 minutes" ? "10" : indicatorTF == "15 minutes" ? "15" : indicatorTF == "30 minutes" ? "30" : indicatorTF == "45 minutes" ? "45" : indicatorTF == "1 hour" ? "60" : indicatorTF == "2 hours" ? "120" : indicatorTF == "3 hours" ? "180" : indicatorTF == "4 hours" ? "240" : indicatorTF == "12 hours" ? "720" : indicatorTF == "1 day" ? "1D" : indicatorTF == "1 week" ? "1W" : indicatorTF == "1 month" ? "1M" : na
= request.security(syminfo.tickerid, tf, cond(indicatorTF != "Chart" and barstate.isrealtime ? 1 : 0))
//colorTVR = tvr < 15 ? #F6525F : tvr > 15 and tvr < 25 ? #B2B5BE : #66BB6A
// Plots
//plot(Presets == "Money Moves TrendVR" ? tvr : na, "", colorTVR, editable=false)
TrendText = "Trending"
if tvr < 15 and tvr < 25
TrendText := "No trend"
if tvr > 15 and tvr < 25
TrendText := "Ranging"
//------------------------------------------------------------------------------------------------------- Volatitiry
//Calculates Volatility for Dashboard
atrr = 3 * ta.atr(10)
stdAtr = 2 * ta.stdev(atrr, 20)
smaAtr = ta.sma(atrr, 20)
topAtrDev = smaAtr + stdAtr
bottomAtrDev = smaAtr - stdAtr
calcDev = (atrr - bottomAtrDev) / (topAtrDev - bottomAtrDev)
percentVol = 40 * calcDev + 30
AvrLength = 21
PercentFilter = 144
xAavrVolume = ta.rma(volume, AvrLength)
nResLess = volume * 100 / xAavrVolume < PercentFilter ? 0 : volume
nRes = nResLess
clr = close < open ? #b2b5be : #00dbff
//plot(nRes, color=clr, style=plot.style_columns, title='Volume Filter', transp=20)
VolitiText = "Inactive"
if nRes
VolitiText := "Active"
//////////////////////////////////////////
ema69 = ta.ema(close, 9)
totalSentTxt = ema69 > ema69 ? 'Bullish' : ema69 < ema69 ? 'Bearish' : 'Flat'
// INputs
//Timezones
tz_incr = 0
use_exchange = false
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
//Session A
NYSes = true
NYTxt = 'New York'
NYTime = '1300-2200'
//Session B
LDSes = true
sesb_txt = 'London'
sesb_ses = '0700-1600'
//Session C
show_sesc = true
sesc_txt = 'Tokyo'
sesc_ses = '0000-0900'
//Session D
show_sesd = true
sesd_txt = 'Sydney'
sesd_ses = '2100-0600'
//-----------------------------------------------------------------------------}
//Sessions
//-----------------------------------------------------------------------------{
tff = timeframe.period
var tz = use_exchange ? syminfo.timezone :
str.format('UTC{0}{1}', tz_incr >= 0 ? '+' : '-', math.abs(tz_incr))
is_sesa = math.sign(nz(time(tff, NYTime, tz)))
is_sesb = math.sign(nz(time(tff, sesb_ses, tz)))
is_sesc = math.sign(nz(time(tff, sesc_ses, tz)))
is_sesd = math.sign(nz(time(tff, sesd_ses, tz)))
////////////////////////////////////////////
SessionText = "Default"
if is_sesd
SessionText := sesd_txt
if is_sesc
SessionText := sesc_txt
if is_sesb
SessionText := sesb_txt
if is_sesa
SessionText := NYTxt
if is_sesd and is_sesc
SessionText := "Sydney/Tokyo"
if is_sesb and is_sesc
SessionText := "Tokyo/London"
if is_sesb and is_sesa
SessionText := "London/Newyork"
if is_sesa and is_sesd
SessionText := "Newyork/Sydney"
//-----------------------------------------------------------------------------}
//Overlays color.green : color.red
//
var dashboard_loc = locationDashboard == "Top Right" ? position.top_right : locationDashboard == "Middle Right" ? position.middle_right : locationDashboard == "Bottom Right" ? position.bottom_right : locationDashboard == "Top Center" ? position.top_center : locationDashboard == "Middle Center" ? position.middle_center : locationDashboard == "Bottom Center" ? position.bottom_center : locationDashboard == "Top Left" ? position.top_left : locationDashboard == "Middle Left" ? position.middle_left : position.bottom_left
var dashboard_size = sizeDashboard == "Large" ? size.large : sizeDashboard == "Normal" ? size.normal : sizeDashboard == "Small" ? size.small : size.tiny
var dashboard = showDashboard ? table.new(dashboard_loc, 3, 8, color.rgb(30, 34, 45 , 60), #3d384300, 2, color.rgb(30, 34, 45 , 60), 1) : na
dashboard_cell(column, row, txt, signal=false) => table.cell(dashboard, column, row, txt, 0, 0, signal ? #000000 : color.white, text_size=dashboard_size)
dashboard_cell_bg(column, row, col) => table.cell_set_bgcolor(dashboard, column, row, col)
if barstate.islast and showDashboard
// MTF Trend
dashboard_cell(0, 0 , "MTF")
dashboard_cell(0, 1 , "M1") , dashboard_cell_bg(0, 1 , TF1Bull ? #0395fc : #fd0205)
dashboard_cell(0, 2 , "M5") , dashboard_cell_bg(0, 2 , TF5Bull ? #0395fc : #fd0205)
dashboard_cell(0, 3 , "M15") , dashboard_cell_bg(0, 3 , TF15Bull ? #0395fc : #fd0205)
dashboard_cell(0, 4 , "M30") , dashboard_cell_bg(0, 4 , TF30Bull ? #0395fc : #fd0205)
dashboard_cell(0, 5 , "1H") , dashboard_cell_bg(0, 5 , TF60Bull ? #0395fc : #fd0205)
dashboard_cell(0, 6 , "4H") , dashboard_cell_bg(0, 6 , TF240Bull ? #0395fc : #fd0205)
dashboard_cell(0, 7 , "D1") , dashboard_cell_bg(0, 7 , TFDBull ? #0395fc : #fd0205)
// Middel part
dashboard_cell(1, 0 , "💎 Diamond Algo 💎")
dashboard_cell(1, 1 , "👉 Current Position ")
dashboard_cell(1, 2 , "🔎 Current Sensitivity ")
dashboard_cell(1, 3 , "🔥 Market State ")
dashboard_cell(1, 4 , "⚠️ Volatility ")
dashboard_cell(1, 5 , "🏦 Institutional Activity ")
dashboard_cell(1, 6 , "🕒 Current Session (UTC) ")
dashboard_cell(1, 7 , "🌊 Trend Pressure ")
// End part
dashboard_cell(2, 0 , "AlgoPoint")
dashboard_cell(2, 1 , str.tostring(currentposition))
dashboard_cell(2, 2 , str.tostring(nsensitivity))
dashboard_cell(2, 3 , TrendText)
dashboard_cell(2, 4 , str.tostring(percentVol, '##.##') + '%')
dashboard_cell(2, 5 , VolitiText)
dashboard_cell(2, 6 , SessionText)
dashboard_cell(2, 7 , totalSentTxt)
// Other Features
// inputs //
//{
trailType = 'modified'
ATRPeriod = 14
ATRFactor = 6
smoothing = 8
norm_o = request.security(ticker.new(syminfo.prefix, syminfo.ticker), timeframe.period, open)
norm_h = request.security(ticker.new(syminfo.prefix, syminfo.ticker), timeframe.period, high)
norm_l = request.security(ticker.new(syminfo.prefix, syminfo.ticker), timeframe.period, low)
norm_c = request.security(ticker.new(syminfo.prefix, syminfo.ticker), timeframe.period, close)
//}
//////// FUNCTIONS //////////////
//{
// Wilders ma //
Wild_ma(_src, _malength) =>
_wild = 0.0
_wild := nz(_wild ) + (_src - nz(_wild )) / _malength
_wild
/////////// TRUE RANGE CALCULATIONS /////////////////
HiLo = math.min(norm_h - norm_l, 1.5 * nz(ta.sma(norm_h - norm_l, ATRPeriod)))
HRef = norm_l <= norm_h ? norm_h - norm_c : norm_h - norm_c - 0.5 * (norm_l - norm_h )
LRef = norm_h >= norm_l ? norm_c - norm_l : norm_c - norm_l - 0.5 * (norm_l - norm_h)
trueRange = trailType == 'modified' ? math.max(HiLo, HRef, LRef) : math.max(norm_h - norm_l, math.abs(norm_h - norm_c ), math.abs(norm_l - norm_c ))
//}
/////////// TRADE LOGIC ////////////////////////
//{
loss = ATRFactor * Wild_ma(trueRange, ATRPeriod)
Up = norm_c - loss
Dn = norm_c + loss
TrendUp = Up
TrendDown = Dn
Trend = 1
TrendUp := norm_c > TrendUp ? math.max(Up, TrendUp ) : Up
TrendDown := norm_c < TrendDown ? math.min(Dn, TrendDown ) : Dn
Trend := norm_c > TrendDown ? 1 : norm_c < TrendUp ? -1 : nz(Trend , 1)
trail = Trend == 1 ? TrendUp : TrendDown
ex = 0.0
ex := ta.crossover(Trend, 0) ? norm_h : ta.crossunder(Trend, 0) ? norm_l : Trend == 1 ? math.max(ex , norm_h) : Trend == -1 ? math.min(ex , norm_l) : ex
//}
// //////// PLOT TP and SL /////////////
////// FIBONACCI LEVELS ///////////
//{
state = Trend == 1 ? 'long' : 'short'
fib1Level = 61.8
fib2Level = 78.6
fib3Level = 88.6
f1 = ex + (trail - ex) * fib1Level / 100
f2 = ex + (trail - ex) * fib2Level / 100
f3 = ex + (trail - ex) * fib3Level / 100
l100 = trail + 0
fill(plot(ShowSmartTrail ? (ta.sma(trail, smoothing)) : na, 'Trailingstop', style=plot.style_line, color=Trend == 1 ? color.new(#2157f9, 0) : Trend == -1 ? color.new(#ff1100, 0) : na),
plot( ShowSmartTrail ? (ta.sma(f2, smoothing)) : na, 'Fib 2', style=plot.style_line, display=display.none),
color=state == 'long' ? color.new(#2157f9, 80) : state == 'short' ? color.new(#ff1100, 80) : na)
//}
// Trend Lines
shortPeriod = 30
longPeriod = 100
if barstate.islast
float lowest_y2 = 60000
float lowest_x2 = 0
float highest_y2 = 0
float highest_x2 = 0
for i = 1 to shortPeriod by 1
if low < lowest_y2
lowest_y2 := low
lowest_x2 := i
lowest_x2
if high > highest_y2
highest_y2 := high
highest_x2 := i
highest_x2
float lowest_y1 = 60000
float lowest_x1 = 0
float highest_y1 = 0
float highest_x1 = 0
for j = shortPeriod + 1 to longPeriod by 1
if low < lowest_y1
lowest_y1 := low
lowest_x1 := j
lowest_x1
if high > highest_y1
highest_y1 := high
highest_x1 := j
highest_x1
sup = Showtrendlines == true ? line.new(x1=bar_index , y1=lowest_y1, x2=bar_index , y2=lowest_y2, extend=extend.right, width=2, color=#0598ff) : na
res = Showtrendlines == true ? line.new(x1=bar_index , y1=highest_y1, x2=bar_index , y2=highest_y2, extend=extend.right, width=2, color=#fe0101) : na
line.delete(sup )
line.delete(res )
if ta.crossunder(close, line.get_price(sup, bar_index ))
alert('break down trendline', freq=alert.freq_once_per_bar_close)
if ta.crossover(close, line.get_price(res, bar_index ))
alert('break upper trendline', freq=alert.freq_once_per_bar_close)
// Alerts
buyalert = input(true, "Buy Alert", group = 'Alerts')
sellalert = input(true, "Sell Alert", group = 'Alerts')
if bull and buyalert
alert("Buy Alert",alert.freq_once_per_bar_close)
if bear and sellalert
alert("Sell Alert",alert.freq_once_per_bar_close)
TREND - ALSAT// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// ©alpergunger
//@version=5
indicator('TREND - ALSAT', overlay=true)
// Variables
var ok = 0
var countBuy = 0
var countSell = 0
src = input(close, title='OHLC Type')
i_fastEMA = input(12, title='Fast EMA')
i_slowEMA = input(25, title='Slow EMA')
i_defEMA = input(25, title='Consolidated EMA')
// Allow the option to show single or double EMA
i_bothEMAs = input(title='Show Both EMAs', defval=true)
// Define EMAs
v_fastEMA = ta.ema(src, i_fastEMA)
v_slowEMA = ta.ema(src, i_slowEMA)
v_biasEMA = ta.ema(src, i_defEMA)
// Color the EMAs
emaColor = v_fastEMA > v_slowEMA ? color.green : v_fastEMA < v_slowEMA ? color.red : #FF530D
// Plot EMAs
plot(i_bothEMAs ? na : v_biasEMA, color=emaColor, linewidth=5, title='Consolidated EMA')
plot(i_bothEMAs ? v_fastEMA : na, title='Fast EMA', color=emaColor,linewidth = 3)
plot(i_bothEMAs ? v_slowEMA : na, title='Slow EMA', color=emaColor,linewidth = 3)
// Colour the bars
buy = v_fastEMA > v_slowEMA
sell = v_fastEMA < v_slowEMA
if buy
countBuy += 1
countBuy
if buy
countSell := 0
countSell
if sell
countSell += 1
countSell
if sell
countBuy := 0
countBuy
buysignal = countBuy < 2 and countBuy > 0 and countSell < 1 and buy and not buy
sellsignal = countSell > 0 and countSell < 2 and countBuy < 1 and sell and not sell
barcolor(buysignal ? #044ffd : na)
barcolor(sellsignal ? color.rgb(0, 0, 0) : na)
// Plot Bull/Bear
plotshape(buysignal, title='Bull', text='AL', style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.rgb(25, 27, 25), size=size.tiny)
plotshape(sellsignal, title='Bear', text='SAT', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.rgb(27, 25, 25), size=size.tiny)
bull = countBuy > 1
bear = countSell > 1
barcolor(bull ? #2fff00 : na)
barcolor(bear ? #f42d8d : na)
// Set Alerts
alertcondition(ta.crossover(v_fastEMA, v_slowEMA), title='Bullish EMA Cross', message='Bullish EMA crossover')
alertcondition(ta.crossunder(v_fastEMA, v_slowEMA), title='Bearish EMA Cross', message='Bearish EMA Crossover')
// Stoch RSI code
smoothK = input.int(3, 'K', minval=1)
smoothD = input.int(3, 'D', minval=1)
lengthRSI = input.int(14, 'RSI Length', minval=1)
lengthStoch = input.int(14, 'Stochastic Length', minval=1)
rsi1 = ta.rsi(src, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ta.sma(k, smoothD)
bandno0 = input.int(80, minval=1, title='Upper Band', group='Bands (change this instead of length in Style for Stoch RSI colour to work properly)')
bandno2 = input.int(50, minval=1, title='Middle Band', group='Bands (change this instead of length in Style for Stoch RSI colour to work properly)')
bandno1 = input.int(20, minval=1, title='Lower Band', group='Bands (change this instead of length in Style for Stoch RSI colour to work properly)')
// Alerts
crossoverAlertBgColourMidOnOff = input.bool(title='Crossover Alert Background Colour (Middle Level) ', group='Crossover Alerts', defval=false)
crossoverAlertBgColourOBOSOnOff = input.bool(title='Crossover Alert Background Colour (OB/OS Level) ', group='Crossover Alerts', defval=false)
crossoverAlertBgColourGreaterThanOnOff = input.bool(title='Crossover Alert >input ', group='Crossover Alerts', defval=false)
crossoverAlertBgColourLessThanOnOff = input.bool(title='Crossover Alert maValue and maTypeChoice != 'None'
crossdownCHECK = maTypeChoice == 'None' or open < maValue and maTypeChoice != 'None'
crossupalert = crossupCHECK and ta.crossover(k, d) and (k < bandno2 or d < bandno2)
crossdownalert = crossdownCHECK and ta.crossunder(k, d) and (k > bandno2 or d > bandno2)
crossupOSalert = crossupCHECK and ta.crossover(k, d) and (k < bandno1 or d < bandno1)
crossdownOBalert = crossdownCHECK and ta.crossunder(k, d) and (k > bandno0 or d > bandno0)
aboveBandalert = ta.crossunder(k, bandno0)
belowBandalert = ta.crossover(k, bandno1)
bgcolor(color=crossupalert and crossoverAlertBgColourMidOnOff ? #4CAF50 : crossdownalert and crossoverAlertBgColourMidOnOff ? #FF0000 : na, title='Crossover Alert Background Colour (Middle Level)', transp=70)
bgcolor(color=crossupOSalert and crossoverAlertBgColourOBOSOnOff ? #fbc02d : crossdownOBalert and crossoverAlertBgColourOBOSOnOff ? #000000 : na, title='Crossover Alert Background Colour (OB/OS Level)', transp=70)
bgcolor(color=aboveBandalert and crossoverAlertBgColourGreaterThanOnOff ? #ff0014 : crossdownalert and crossoverAlertBgColourMidOnOff ? #FF0000 : na, title='Crossover Alert - K > Upper level', transp=70)
bgcolor(color=belowBandalert and crossoverAlertBgColourLessThanOnOff ? #4CAF50 : crossdownalert and crossoverAlertBgColourMidOnOff ? #FF0000 : na, title='Crossover Alert - K < Lower level', transp=70)
alertcondition(crossupalert or crossdownalert, title='Stoch RSI Crossover', message='STOCH RSI CROSSOVER')
////////////////////////////////////////////////////////////7/////
gurupSec = input.string(defval='1', options= , group='Taraması yapılacak 40\'arlı gruplardan birini seçin', title='Grup seç')
per = input.timeframe(defval='', title='TimeFrame (Default hali grafikte seçili olan)',group = "Tarama yapmak istediğiniz TimeFrame'ı seçin")
loc = input.int(defval=1, title='Konum Ayarı', minval = -100,maxval = 100 , step = 5, group='Tablonun konumunu belirleyin')
////////////////////////////////////////////////////////////
cro= buysignal
cru= sellsignal
direction = 0
direction := cro ? 1 : cru ? -1 : direction
string gr_sc = 'TARAYICI'
string gr_sy = 'SIMGE'
string t00 = 'KISA-VADE SİNYALLERİ'
color c00 = #686868
lb_sh = input.bool(title='Etiket Göster', defval=true, group=gr_sc)
lb_sz = input.string(title='Etiket Boyu', options= , defval='Normal', group=gr_sc)
lb_xa = input.int(title='Yatay Eksen', defval=20, group=gr_sc, tooltip='X Ekseni Etiket Yerleşimi')
lb_ya = input.int(title='Dikey Eksen', defval=1, group=gr_sc, tooltip='Y Ekseni Etiket Yerleşimi')
lb_cl = input.color(title='Renkler', defval=#00bb00, group=gr_sc, inline='0')
lb_cs = input.color(title='', defval=#ff0000, group=gr_sc, inline='0')
sh01 = input.bool(title='01', defval=true, group=gr_sy, inline="01")
sh02 = input.bool(title='02', defval=true, group=gr_sy, inline="02")
sh03 = input.bool(title='03', defval=true, group=gr_sy, inline="03")
sh04 = input.bool(title='04', defval=true, group=gr_sy, inline="04")
sh05 = input.bool(title='05', defval=true, group=gr_sy, inline="05")
sh06 = input.bool(title='06', defval=true, group=gr_sy, inline="06")
sh07 = input.bool(title='07', defval=true, group=gr_sy, inline="07")
sh08 = input.bool(title='08', defval=true, group=gr_sy, inline="08")
sh09 = input.bool(title='09', defval=true, group=gr_sy, inline="09")
sh10 = input.bool(title='10', defval=true, group=gr_sy, inline="10")
sh11 = input.bool(title='11', defval=true, group=gr_sy, inline="11")
sh12 = input.bool(title='12', defval=true, group=gr_sy, inline="12")
sh13 = input.bool(title='13', defval=true, group=gr_sy, inline="13")
sh14 = input.bool(title='14', defval=true, group=gr_sy, inline="14")
sh15 = input.bool(title='15', defval=true, group=gr_sy, inline="15")
sh16 = input.bool(title='16', defval=true, group=gr_sy, inline="16")
sh17 = input.bool(title='17', defval=true, group=gr_sy, inline="17")
sh18 = input.bool(title='18', defval=true, group=gr_sy, inline="18")
sh19 = input.bool(title='19', defval=true, group=gr_sy, inline="19")
sh20 = input.bool(title='20', defval=true, group=gr_sy, inline="20")
//
sh21 = input.bool(title='21', defval=true, group=gr_sy, inline="21")
sh22 = input.bool(title='22', defval=true, group=gr_sy, inline="22")
sh23 = input.bool(title='23', defval=true, group=gr_sy, inline="23")
sh24 = input.bool(title='24', defval=true, group=gr_sy, inline="24")
sh25 = input.bool(title='25', defval=true, group=gr_sy, inline="25")
sh26 = input.bool(title='26', defval=true, group=gr_sy, inline="26")
sh27 = input.bool(title='27', defval=true, group=gr_sy, inline="27")
sh28 = input.bool(title='28', defval=true, group=gr_sy, inline="28")
sh29 = input.bool(title='29', defval=true, group=gr_sy, inline="29")
sh30 = input.bool(title='30', defval=true, group=gr_sy, inline="30")
sh31 = input.bool(title='31', defval=true, group=gr_sy, inline="31")
sh32 = input.bool(title='32', defval=true, group=gr_sy, inline="32")
sh33 = input.bool(title='33', defval=true, group=gr_sy, inline="33")
sh34 = input.bool(title='34', defval=true, group=gr_sy, inline="34")
sh35 = input.bool(title='35', defval=true, group=gr_sy, inline="35")
sh36 = input.bool(title='36', defval=true, group=gr_sy, inline="36")
sh37 = input.bool(title='37', defval=true, group=gr_sy, inline="37")
sh38 = input.bool(title='38', defval=true, group=gr_sy, inline="38")
sh39 = input.bool(title='39', defval=true, group=gr_sy, inline="39")
sh40 = input.bool(title='40', defval=true, group=gr_sy, inline="40")
//
tf01 = input.timeframe(title='', defval='', group=gr_sy, inline="01")
tf02 = input.timeframe(title='', defval='', group=gr_sy, inline="02")
tf03 = input.timeframe(title='', defval='', group=gr_sy, inline="03")
tf04 = input.timeframe(title='', defval='', group=gr_sy, inline="04")
tf05 = input.timeframe(title='', defval='', group=gr_sy, inline="05")
tf06 = input.timeframe(title='', defval='', group=gr_sy, inline="06")
tf07 = input.timeframe(title='', defval='', group=gr_sy, inline="07")
tf08 = input.timeframe(title='', defval='', group=gr_sy, inline="08")
tf09 = input.timeframe(title='', defval='', group=gr_sy, inline="09")
tf10 = input.timeframe(title='', defval='', group=gr_sy, inline="10")
tf11 = input.timeframe(title='', defval='', group=gr_sy, inline="11")
tf12 = input.timeframe(title='', defval='', group=gr_sy, inline="12")
tf13 = input.timeframe(title='', defval='', group=gr_sy, inline="13")
tf14 = input.timeframe(title='', defval='', group=gr_sy, inline="14")
tf15 = input.timeframe(title='', defval='', group=gr_sy, inline="15")
tf16 = input.timeframe(title='', defval='', group=gr_sy, inline="16")
tf17 = input.timeframe(title='', defval='', group=gr_sy, inline="17")
tf18 = input.timeframe(title='', defval='', group=gr_sy, inline="18")
tf19 = input.timeframe(title='', defval='', group=gr_sy, inline="19")
tf20 = input.timeframe(title='', defval='', group=gr_sy, inline="20")
//
tf21 = input.timeframe(title='', defval='', group=gr_sy, inline="21")
tf22 = input.timeframe(title='', defval='', group=gr_sy, inline="22")
tf23 = input.timeframe(title='', defval='', group=gr_sy, inline="23")
tf24 = input.timeframe(title='', defval='', group=gr_sy, inline="24")
tf25 = input.timeframe(title='', defval='', group=gr_sy, inline="25")
tf26 = input.timeframe(title='', defval='', group=gr_sy, inline="26")
tf27 = input.timeframe(title='', defval='', group=gr_sy, inline="27")
tf28 = input.timeframe(title='', defval='', group=gr_sy, inline="28")
tf29 = input.timeframe(title='', defval='', group=gr_sy, inline="29")
tf30 = input.timeframe(title='', defval='', group=gr_sy, inline="30")
tf31 = input.timeframe(title='', defval='', group=gr_sy, inline="31")
tf32 = input.timeframe(title='', defval='', group=gr_sy, inline="32")
tf33 = input.timeframe(title='', defval='', group=gr_sy, inline="33")
tf34 = input.timeframe(title='', defval='', group=gr_sy, inline="34")
tf35 = input.timeframe(title='', defval='', group=gr_sy, inline="35")
tf36 = input.timeframe(title='', defval='', group=gr_sy, inline="36")
tf37 = input.timeframe(title='', defval='', group=gr_sy, inline="37")
tf38 = input.timeframe(title='', defval='', group=gr_sy, inline="38")
tf39 = input.timeframe(title='', defval='', group=gr_sy, inline="39")
tf40 = input.timeframe(title='', defval='', group=gr_sy, inline="40")
//
s01 = input.symbol(title='', group=gr_sy, inline='01', defval='BIST:DOHOL')
s02 = input.symbol(title='', group=gr_sy, inline='02', defval='BIST:DOAS')
s03 = input.symbol(title='', group=gr_sy, inline='03', defval='BIST:FROTO')
s04 = input.symbol(title='', group=gr_sy, inline='04', defval='BIST:GUBRF')
s05 = input.symbol(title='', group=gr_sy, inline='05', defval='BIST:KCHOL')
s06 = input.symbol(title='', group=gr_sy, inline='06', defval='BIST:TOASO')
s07 = input.symbol(title='', group=gr_sy, inline='07', defval='BIST:TTRAK')
s08 = input.symbol(title='', group=gr_sy, inline='08', defval='BIST:THYAO')
s09 = input.symbol(title='', group=gr_sy, inline='09', defval='BIST:TUPRS')
s10 = input.symbol(title='', group=gr_sy, inline='10', defval='BIST:YKBNK')
s11 = input.symbol(title='', group=gr_sy, inline='11', defval='BIST:BIMAS')
s12 = input.symbol(title='', group=gr_sy, inline='12', defval='BIST:MGROS')
s13 = input.symbol(title='', group=gr_sy, inline='13', defval='BIST:AKSEN')
s14 = input.symbol(title='', group=gr_sy, inline='14', defval='BIST:SAHOL')
s15 = input.symbol(title='', group=gr_sy, inline='15', defval='BIST:EREGL')
s16 = input.symbol(title='', group=gr_sy, inline='16', defval='BIST:AKBNK')
s17 = input.symbol(title='', group=gr_sy, inline='17', defval='BIST:ASELS')
s18 = input.symbol(title='', group=gr_sy, inline='18', defval='BIST:SISE')
s19 = input.symbol(title='', group=gr_sy, inline='19', defval='BIST:TTKOM')
s20 = input.symbol(title='', group=gr_sy, inline='20', defval='BIST:AKSA')
//
s21 = input.symbol(title='', group=gr_sy, inline='21', defval='BIST:CCOLA')
s22 = input.symbol(title='', group=gr_sy, inline='22', defval='BIST:KOZAL')
s23 = input.symbol(title='', group=gr_sy, inline='23', defval='BIST:KOZAA')
s24 = input.symbol(title='', group=gr_sy, inline='24', defval='BIST:GARAN')
s25 = input.symbol(title='', group=gr_sy, inline='25', defval='BIST:ALARK')
s26 = input.symbol(title='', group=gr_sy, inline='26', defval='BIST:TAVHL')
s27 = input.symbol(title='', group=gr_sy, inline='27', defval='BIST:MAVI')
s28 = input.symbol(title='', group=gr_sy, inline='28', defval='BIST:ODAS')
s29 = input.symbol(title='', group=gr_sy, inline='29', defval='BIST:KORDS')
s30 = input.symbol(title='', group=gr_sy, inline='30', defval='BIST:KAREL')
s31 = input.symbol(title='', group=gr_sy, inline='31', defval='BIST:GWIND')
s32 = input.symbol(title='', group=gr_sy, inline='32', defval='BIST:NATEN')
s33 = input.symbol(title='', group=gr_sy, inline='33', defval='BIST:PGSUS')
s34 = input.symbol(title='', group=gr_sy, inline='34', defval='BIST:AGHOL')
s35 = input.symbol(title='', group=gr_sy, inline='35', defval='BIST:ISDMR')
s36 = input.symbol(title='', group=gr_sy, inline='36', defval='BIST:GOLTS')
s37 = input.symbol(title='', group=gr_sy, inline='37', defval='BIST:AKCNS')
s38 = input.symbol(title='', group=gr_sy, inline='38', defval='BIST:NUHCM')
s39 = input.symbol(title='', group=gr_sy, inline='39', defval='BIST:QUAGR')
s40 = input.symbol(title='', group=gr_sy, inline='40', defval='BIST:KLKIM')
//
f_screener(s) =>
int x = na
int y = na
z = color(na)
if s
x := direction
y := ta.barssince(x != x )
z := x == 1 ? lb_cl : x == -1 ? lb_cs : c00
//
f_bars(x) =>
r = ' '
//
f_size(x) =>
x == 'Minik' ? size.tiny :
x == 'Küçük' ? size.small :
x == 'Normal' ? size.normal :
x == 'Büyük' ? size.large :
x == 'EnBüyük' ? size.huge : size.auto
//
f_label(l, t, c) =>
r = string(na)
for i = l*2 to 0
r += '\n\n'
r += t
var label lb = na
label.delete(lb)
fix_allign = ta.highest(200)
lb := lb_sh ? label.new(
x=bar_index + lb_xa,
y=bar_index > 200 ? fix_allign * (1 + lb_ya / 1000) : hl2 * (1 + lb_ya / 1000),
text=r, textcolor=c, textalign=text.align_right,
style=label.style_label_left, size=f_size(lb_sz), color=#00000000) : na
= request.security(s01, tf01, f_screener(sh01))
= request.security(s02, tf02, f_screener(sh02))
= request.security(s03, tf03, f_screener(sh03))
= request.security(s04, tf04, f_screener(sh04))
= request.security(s05, tf05, f_screener(sh05))
= request.security(s06, tf06, f_screener(sh06))
= request.security(s07, tf07, f_screener(sh07))
= request.security(s08, tf08, f_screener(sh08))
= request.security(s09, tf09, f_screener(sh09))
= request.security(s10, tf10, f_screener(sh10))
= request.security(s11, tf11, f_screener(sh11))
= request.security(s12, tf12, f_screener(sh12))
= request.security(s13, tf13, f_screener(sh13))
= request.security(s14, tf14, f_screener(sh14))
= request.security(s15, tf15, f_screener(sh15))
= request.security(s16, tf16, f_screener(sh16))
= request.security(s17, tf17, f_screener(sh17))
= request.security(s18, tf18, f_screener(sh18))
= request.security(s19, tf19, f_screener(sh19))
= request.security(s20, tf20, f_screener(sh20))
= request.security(s21, tf21, f_screener(sh21))
= request.security(s22, tf22, f_screener(sh22))
= request.security(s23, tf23, f_screener(sh23))
= request.security(s24, tf24, f_screener(sh24))
= request.security(s25, tf25, f_screener(sh25))
= request.security(s26, tf26, f_screener(sh26))
= request.security(s27, tf27, f_screener(sh27))
= request.security(s28, tf28, f_screener(sh28))
= request.security(s29, tf29, f_screener(sh29))
= request.security(s30, tf30, f_screener(sh30))
= request.security(s31, tf31, f_screener(sh31))
= request.security(s32, tf32, f_screener(sh32))
= request.security(s33, tf33, f_screener(sh33))
= request.security(s34, tf34, f_screener(sh34))
= request.security(s35, tf35, f_screener(sh35))
= request.security(s36, tf36, f_screener(sh36))
= request.security(s37, tf37, f_screener(sh37))
= request.security(s38, tf38, f_screener(sh38))
= request.security(s39, tf39, f_screener(sh39))
= request.security(s40, tf40, f_screener(sh40))
t01 = a01 == 1 ? '▲' + f_bars(b01) + s01 : a01 == -1 ? '▼' + f_bars(b01) + s01 : '■' + f_bars(b01) + s01
t02 = a02 == 1 ? '▲' + f_bars(b02) + s02 : a02 == -1 ? '▼' + f_bars(b02) + s02 : '■' + f_bars(b02) + s02
t03 = a03 == 1 ? '▲' + f_bars(b03) + s03 : a03 == -1 ? '▼' + f_bars(b03) + s03 : '■' + f_bars(b03) + s03
t04 = a04 == 1 ? '▲' + f_bars(b04) + s04 : a04 == -1 ? '▼' + f_bars(b04) + s04 : '■' + f_bars(b04) + s04
t05 = a05 == 1 ? '▲' + f_bars(b05) + s05 : a05 == -1 ? '▼' + f_bars(b05) + s05 : '■' + f_bars(b05) + s05
t06 = a06 == 1 ? '▲' + f_bars(b06) + s06 : a06 == -1 ? '▼' + f_bars(b06) + s06 : '■' + f_bars(b06) + s06
t07 = a07 == 1 ? '▲' + f_bars(b07) + s07 : a07 == -1 ? '▼' + f_bars(b07) + s07 : '■' + f_bars(b07) + s07
t08 = a08 == 1 ? '▲' + f_bars(b08) + s08 : a08 == -1 ? '▼' + f_bars(b08) + s08 : '■' + f_bars(b08) + s08
t09 = a09 == 1 ? '▲' + f_bars(b09) + s09 : a09 == -1 ? '▼' + f_bars(b09) + s09 : '■' + f_bars(b09) + s09
t10 = a10 == 1 ? '▲' + f_bars(b10) + s10 : a10 == -1 ? '▼' + f_bars(b10) + s10 : '■' + f_bars(b10) + s10
t11 = a11 == 1 ? '▲' + f_bars(b11) + s11 : a11 == -1 ? '▼' + f_bars(b11) + s11 : '■' + f_bars(b11) + s11
t12 = a12 == 1 ? '▲' + f_bars(b12) + s12 : a12 == -1 ? '▼' + f_bars(b12) + s12 : '■' + f_bars(b12) + s12
t13 = a13 == 1 ? '▲' + f_bars(b13) + s13 : a13 == -1 ? '▼' + f_bars(b13) + s13 : '■' + f_bars(b13) + s13
t14 = a14 == 1 ? '▲' + f_bars(b14) + s14 : a14 == -1 ? '▼' + f_bars(b14) + s14 : '■' + f_bars(b14) + s14
t15 = a15 == 1 ? '▲' + f_bars(b15) + s15 : a15 == -1 ? '▼' + f_bars(b15) + s15 : '■' + f_bars(b15) + s15
t16 = a16 == 1 ? '▲' + f_bars(b16) + s16 : a16 == -1 ? '▼' + f_bars(b16) + s16 : '■' + f_bars(b16) + s16
t17 = a17 == 1 ? '▲' + f_bars(b17) + s17 : a17 == -1 ? '▼' + f_bars(b17) + s17 : '■' + f_bars(b17) + s17
t18 = a18 == 1 ? '▲' + f_bars(b18) + s18 : a18 == -1 ? '▼' + f_bars(b18) + s18 : '■' + f_bars(b18) + s18
t19 = a19 == 1 ? '▲' + f_bars(b19) + s19 : a19 == -1 ? '▼' + f_bars(b19) + s19 : '■' + f_bars(b19) + s19
t20 = a20 == 1 ? '▲' + f_bars(b20) + s20 : a20 == -1 ? '▼' + f_bars(b20) + s20 : '■' + f_bars(b20) + s20
t21 = a21 == 1 ? '▲' + f_bars(b21) + s21 : a21 == -1 ? '▼' + f_bars(b21) + s21 : '■' + f_bars(b21) + s21
t22 = a22 == 1 ? '▲' + f_bars(b22) + s22 : a22 == -1 ? '▼' + f_bars(b22) + s22 : '■' + f_bars(b22) + s22
t23 = a23 == 1 ? '▲' + f_bars(b23) + s23 : a23 == -1 ? '▼' + f_bars(b23) + s23 : '■' + f_bars(b23) + s23
t24 = a24 == 1 ? '▲' + f_bars(b24) + s24 : a24 == -1 ? '▼' + f_bars(b24) + s24 : '■' + f_bars(b24) + s24
t25 = a25 == 1 ? '▲' + f_bars(b25) + s25 : a25 == -1 ? '▼' + f_bars(b25) + s25 : '■' + f_bars(b25) + s25
t26 = a26 == 1 ? '▲' + f_bars(b26) + s26 : a26 == -1 ? '▼' + f_bars(b26) + s26 : '■' + f_bars(b26) + s26
t27 = a27 == 1 ? '▲' + f_bars(b27) + s27 : a27 == -1 ? '▼' + f_bars(b27) + s27 : '■' + f_bars(b27) + s27
t28 = a28 == 1 ? '▲' + f_bars(b28) + s28 : a28 == -1 ? '▼' + f_bars(b28) + s28 : '■' + f_bars(b28) + s28
t29 = a29 == 1 ? '▲' + f_bars(b29) + s29 : a29 == -1 ? '▼' + f_bars(b29) + s29 : '■' + f_bars(b29) + s29
t30 = a30 == 1 ? '▲' + f_bars(b30) + s30 : a30 == -1 ? '▼' + f_bars(b30) + s30 : '■' + f_bars(b30) + s30
t31 = a31 == 1 ? '▲' + f_bars(b31) + s31 : a31 == -1 ? '▼' + f_bars(b31) + s31 : '■' + f_bars(b31) + s31
t32 = a32 == 1 ? '▲' + f_bars(b32) + s32 : a32 == -1 ? '▼' + f_bars(b32) + s32 : '■' + f_bars(b32) + s32
t33 = a33 == 1 ? '▲' + f_bars(b33) + s33 : a33 == -1 ? '▼' + f_bars(b33) + s33 : '■' + f_bars(b33) + s33
t34 = a34 == 1 ? '▲' + f_bars(b34) + s34 : a34 == -1 ? '▼' + f_bars(b34) + s34 : '■' + f_bars(b34) + s34
t35 = a35 == 1 ? '▲' + f_bars(b35) + s35 : a35 == -1 ? '▼' + f_bars(b35) + s35 : '■' + f_bars(b35) + s35
t36 = a36 == 1 ? '▲' + f_bars(b36) + s36 : a36 == -1 ? '▼' + f_bars(b36) + s36 : '■' + f_bars(b36) + s36
t37 = a37 == 1 ? '▲' + f_bars(b37) + s37 : a37 == -1 ? '▼' + f_bars(b37) + s37 : '■' + f_bars(b37) + s37
t38 = a38 == 1 ? '▲' + f_bars(b38) + s38 : a38 == -1 ? '▼' + f_bars(b38) + s38 : '■' + f_bars(b38) + s38
t39 = a39 == 1 ? '▲' + f_bars(b39) + s39 : a39 == -1 ? '▼' + f_bars(b39) + s39 : '■' + f_bars(b39) + s39
t40 = a40 == 1 ? '▲' + f_bars(b40) + s40 : a40 == -1 ? '▼' + f_bars(b40) + s40 : '■' + f_bars(b40) + s40
f_label(0, t00, c00)
f_label(1, t01, c01)
f_label(2, t02, c02)
f_label(3, t03, c03)
f_label(4, t04, c04)
f_label(5, t05, c05)
f_label(6, t06, c06)
f_label(7, t07, c07)
f_label(8, t08, c08)
f_label(9, t09, c09)
f_label(10, t10, c10)
f_label(11, t11, c11)
f_label(12, t12, c12)
f_label(13, t13, c13)
f_label(14, t14, c14)
f_label(15, t15, c15)
f_label(16, t16, c16)
f_label(17, t17, c17)
f_label(18, t18, c18)
f_label(19, t19, c19)
f_label(20, t20, c20)
f_label(21, t21, c21)
f_label(22, t22, c22)
f_label(23, t23, c23)
f_label(24, t24, c24)
f_label(25, t25, c25)
f_label(26, t26, c26)
f_label(27, t27, c27)
f_label(28, t28, c28)
f_label(29, t29, c29)
f_label(30, t30, c30)
f_label(31, t31, c31)
f_label(32, t32, c32)
f_label(33, t33, c33)
f_label(34, t34, c34)
f_label(35, t35, c35)
f_label(36, t36, c36)
f_label(37, t37, c37)
f_label(38, t38, c38)
f_label(39, t39, c39)
f_label(40, t40, c40)
MTF MACD 4-Color Momentum System🎯 Overview
The MTF MACD 4-Color Momentum System is an advanced MACD indicator that provides crystal-clear momentum visualization through an innovative 4-color state system. Unlike traditional MACD indicators that only show positive/negative values, this indicator identifies four distinct market states to help traders make more informed decisions.
📊 Key Features
1. Four-State Color System:
🟢 Lime: Above zero + Rising (Strong Bullish Momentum)
🟢 Dark Green: Above zero + Falling (Weakening Bullish Momentum)
🔴 Red: Below zero + Falling (Strong Bearish Momentum)
🔴 Maroon: Below zero + Rising (Weakening Bearish Momentum)
2. Multi-Timeframe Analysis:
View higher timeframe MACD on lower timeframe charts
Confirm trends across multiple timeframes
Reduce false signals with multi-timeframe confluence
3. Flexible Display Options:
Three visualization styles: Histogram, Columns, or Line
Toggle individual color states on/off
Customizable colors and line widths
4. Advanced Features:
Optional histogram smoothing to reduce noise
Zero-cross alerts with visual markers
Color state change alerts
Real-time value display
Customizable signal line overlay
💡 How to Use
1. Momentum Identification:
Lime bars indicate strong upward momentum - ideal for long entries
Dark green suggests momentum is slowing - consider taking profits
Red bars show strong downward momentum - ideal for short entries
Maroon indicates potential reversal brewing - prepare for direction change
2. Zero Line Crosses:
Blue triangles mark bullish crosses above zero
Pink triangles mark bearish crosses below zero
Use these as confirmation signals with other indicators
3. Multi-Timeframe Confirmation:
Set to higher timeframe (e.g., 4H on 15m chart)
Look for alignment between timeframes before entering trades
Avoid trades against higher timeframe momentum
⚙️ Settings Guide
MACD Parameters:
Fast EMA: 12 (default) - Adjust for more/less sensitivity
Slow EMA: 26 (default) - Standard MACD setting
Signal: 9 (default) - Smoothing period
Display Customization:
Choose between Histogram, Columns, or Line display
Enable/disable specific color states
Adjust visual properties to match your chart theme
Alerts:
Zero cross alerts for trend changes
Color state alerts for momentum shifts
📈 Trading Strategies
1. Momentum Continuation:
Enter longs when MACD turns lime (above zero + rising)
Enter shorts when MACD turns red (below zero + falling)
Exit when color shifts to "weakening" state
2. Reversal Trading:
Watch for maroon in downtrends (potential bottom)
Watch for dark green in uptrends (potential top)
Confirm with price action and support/resistance
3. Multi-Timeframe Confluence:
Use daily MACD on 1H chart for trend direction
Enter on lower timeframe signals in direction of higher timeframe
Avoid counter-trend trades when higher timeframe shows strong momentum
🎓 Pro Tips
Combine with volume indicators for confirmation
Use with support/resistance levels for better entries
Enable smoothing in choppy markets to reduce false signals
Pay attention to divergences between price and MACD
⚠️ Risk Disclaimer
This indicator is for educational purposes only. Always use proper risk management and combine with other analysis methods. Past performance does not guarantee future results.
Hull Moving Average RibbonGradient Wave HMA - Multi-Ribbon Hull Moving Average System
Overview
The Gradient Wave HMA is an advanced technical indicator that transforms Alan Hull's Hull Moving Average (HMA) into a dynamic multi-layered ribbon system. Unlike traditional moving average ribbons that use simple or exponential calculations, this indicator applies Hull's innovative lag-reduction formula across 12 different timeframes simultaneously, creating a visually striking gradient effect that flows with market momentum.
Technical Foundation
This indicator is built upon the Hull Moving Average, developed by Alan Hull in 2005. The HMA uses a weighted moving average calculation designed to almost eliminate lag while maintaining curve smoothness:
HMA = WMA(2*WMA(n/2) − WMA(n), sqrt(n))
Credit: Alan Hull (www.alanhull.com)
Key Features
Multi-Period Ribbon Structure
12 individual HMA lines with customizable periods
Preset configurations for different trading styles:
Fast: 3-30 period range (scalping/intraday)
Swing: 8-55 period range (swing trading)
Position: 20-100 period range (position trading)
Custom: User-defined periods
2. Neon Gradient Visualization
Bullish Gradient: Transitions from blue-purple to hot purple
Bearish Gradient: Flows from hot pink to purple-pink
Each line has a unique color in the spectrum
Gradient fills between lines create depth and visual flow
3. Advanced Alert System
Trend Reversal Alerts: Notifies when ribbon changes direction
Price Breakout Alerts: Triggers when price crosses the ribbon
Compression Alerts: Signals potential breakouts during consolidation
Expansion Alerts: Confirms strong trending conditions
Momentum Surge Alerts: Catches explosive moves early
How It Works
The indicator calculates 12 Hull Moving Averages, each with a different period length. The trend direction is determined by the middle HMA (6th line), which triggers the color change across the entire ribbon. When trending up, the ribbon displays a purple gradient; when trending down, it shifts to a pink gradient.
Trading Applications
1. Trend Identification
Ribbon color indicates overall trend direction
All lines moving in sync confirms strong trend
Mixed signals suggest choppy or transitioning markets
2. Dynamic Support/Resistance
In uptrends, the ribbon acts as moving support
In downtrends, it provides resistance levels
Multiple layers offer various strength levels
3. Momentum Analysis
Expanding ribbon = Increasing momentum
Contracting ribbon = Decreasing momentum/consolidation
Ribbon angle indicates trend strength
4. Trading Example
Advantages Over Traditional MAs
Reduced Lag: Hull's formula provides faster response than SMA/EMA ribbons
Visual Clarity: Gradient effect makes trend changes immediately visible
Multiple Timeframes: 12 periods provide comprehensive market view
Flexibility: Presets adapt to different trading styles
Best Practices
Use higher timeframes (4H, Daily) for position trading
Combine with volume indicators for confirmation
Watch for ribbon compression before major moves
Consider overall market conditions when interpreting signals
Customization Options
Adjust individual HMA periods
Fine-tune transparency for different backgrounds
Choose between WMA and EMA base calculations
The Gradient Wave HMA combines Alan Hull's breakthrough moving average formula with modern visualization techniques to create a powerful trend-following tool that's both technically sophisticated and visually intuitive.
Quad-Based Asset OverlayHere's a Pine Script v5 TradingView overlay that visualizes a few core tickers based on a Hedgeye-style trend framework. It includes:
Ticker symbol
Current price (auto-updated)
LETR (Buy), TETR (Sell) levels
Calculated Upside and Downside (%)
Trend coloring (Bullish = Green, Bearish = Red, Neutral = Gray)