0% found this document useful (0 votes)
115 views2 pages

Current Week & Previous Day High/Low

Uploaded by

CMR C
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views2 pages

Current Week & Previous Day High/Low

Uploaded by

CMR C
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
  • Setup and Configuration
  • Calculation Logic

//@version=5

indicator("Current Week High/Low, Previous Day High/Low, Daily Open with Bollinger Bands",
shorttitle="Current Week High/Low & Prev HL & Daily Open", overlay=true)

// Current Week High and Low


currentWeekHigh = [Link]([Link], "W", high, lookahead=barmerge.lookahead_on)
currentWeekLow = [Link]([Link], "W", low, lookahead=barmerge.lookahead_on)

// Previous Day High and Low


prevDayHigh = [Link]([Link], "D", high[1], lookahead=barmerge.lookahead_on)
prevDayLow = [Link]([Link], "D", low[1], lookahead=barmerge.lookahead_on)

// Daily Open
dailyOpen = [Link]([Link], "D", open, lookahead=barmerge.lookahead_on)

// EMA
emaLength = [Link](20, minval=1, title="EMA Length")
ema = [Link](close, emaLength)

// Bollinger Bands
length = [Link](20, minval=1, title="Bollinger Bands Length")
src = close
mult = [Link](2.0, minval=0.001, maxval=50, title="Bollinger Bands StdDev")
basis = [Link](src, length)
dev = mult * [Link](src, length)
upper = basis + dev
lower = basis - dev

// Determine bullish or bearish tilt


bullishTilt = basis > basis[1]
bearishTilt = basis < basis[1]

// Determine breakout conditions for previous day's high and low


breakoutConditionHigh = close > prevDayHigh
breakoutConditionLow = close < prevDayLow

// Change color based on breakout conditions


prevHighColor = breakoutConditionHigh ? [Link] : [Link]
prevLowColor = breakoutConditionLow ? [Link] : [Link]

// Determine color based on daily open's relationship with Bollinger Bands


openColor = dailyOpen > upper ? [Link] : dailyOpen < lower ? [Link] : [Link]

// Determine color for EMA price coiling


coilingColor = [Link](close, ema) ? [Link] : [Link](close, ema) ? [Link] : [Link]

// Plotting
plot(currentWeekHigh, color=[Link], style=plot.style_stepline, linewidth=2, title="Current Week High")
plot(currentWeekLow, color=[Link], style=plot.style_stepline, linewidth=2, title="Current Week Low")
plot(prevDayHigh, color=prevHighColor, style=plot.style_stepline, linewidth=2, title="Previous Day High")
plot(prevDayLow, color=prevLowColor, style=plot.style_stepline, linewidth=2, title="Previous Day Low")
plot(dailyOpen, color=openColor, style=plot.style_stepline, linewidth=2, title="Daily Open")
plot(upper, color=bullishTilt ? [Link] : [Link], linewidth=2, title="Upper Bollinger Band")
plot(lower, color=bearishTilt ? [Link] : [Link], linewidth=2, title="Lower Bollinger Band")
plot(basis, color=[Link], linewidth=2, title="Bollinger Band Basis")
plot(ema, color=coilingColor, style=plot.style_line, linewidth=2, title="EMA Price Coiling")

t = time("1440", [Link]) // 1440=60*24 is the number of minutes in a whole day. You may use "0930-
1600" as second session parameter
//plot(t, style=linebr) // debug
is_first = na(t[1]) and not na(t) or t[1] < t
plotshape(is_first, color=[Link], style=[Link])

var float day_high = na


var float day_low = na

if (is_first and [Link])


day_high := high
day_low := low
else
day_high := day_high[1]
day_low := day_low[1]

if (high > day_high)


day_high := high

if (low < day_low)


day_low := low

plot(day_high, color=[Link])
plot(day_low, color=[Link])

Common questions

Powered by AI

Color coding in the trading system serves as a quick and intuitive visual aid that improves a trader's efficiency by reducing the cognitive load needed to interpret complex data. Different colors represent various conditions, such as green for bullish breakouts and red for bearish breakouts, based on Bollinger Bands and price position relative to EMA. This allows traders to quickly assess the market conditions without delving deeply into numerical analysis, thereby speeding up decision-making processes and potentially improving trade performance due to the faster interpretation of market conditions .

Using multiple technical indicators like EMA and Bollinger Bands together provides a comprehensive view of market conditions by leveraging different aspects of price data. EMA helps identify the market trend direction, while Bollinger Bands measure market volatility and potential price extremes. Combining these indicators allows traders to confirm signals and reduce false positives. For example, an EMA crossover can be used for trend confirmation, while interactions with Bollinger Bands can identify potential entry or exit points. This layered approach enhances the robustness of trading strategies and improves the accuracy of predictions and decision-making .

The daily open is used to influence trading signals by its position relative to the Bollinger Bands. If the daily open is above the upper band, it indicates a bullish signal denoted by a green color, suggesting overbought conditions and potential for a bullish breakout. Conversely, if it is below the lower band, it signifies a bearish signal highlighted in red, pointing to oversold conditions and potential for a bearish breakout. This utilization helps traders make informed decisions at the market open, when volatility and trading opportunities often peak .

Breakout conditions are determined by comparing the closing price with the previous day's high and low prices. A breakout above the previous day's high, indicated by a color change to green, suggests a bullish signal and implies a potential upward shift in price momentum. This can encourage traders to enter long positions. Conversely, a breakout below the previous day's low, marked by a red color, suggests a bearish signal, prompting traders to potentially short sell or exit long positions. Recognizing these conditions provides critical insights into market sentiment and can significantly influence trading strategies and risk management .

The Exponential Moving Average (EMA) in the trading strategy serves as a tool to smooth out price data and capture the trend direction more responsively than a simple moving average. By calculating the average of past prices with more emphasis on recent data, the EMA helps traders identify potential trend reversals. In the strategy, if the closing price crosses over the EMA, it is indicated by a purple color, suggesting a potential bullish signal. Conversely, if the closing price crosses under the EMA, it is indicated by a yellow color, suggesting a potential bearish signal. This differentiation helps traders make informed decisions whether to enter or exit positions based on the detected market trend .

The EMA plot color is adjusted based on price movement crossing above or below the EMA line: purple for a crossover (bullish signal) indicates an upward trend, while yellow for a crossunder (bearish signal) indicates a downward trend. This color coding aids in trend analysis by providing a clear, visual signal of trend reversals or continuations, allowing traders to quickly identify and act upon significant market shifts, enhancing their ability to anticipate potential profits or safeguard against losses .

The script determines the bullish or bearish tilt in the Bollinger Bands by comparing the basis line of the current period with the previous one. If the basis line is higher than the previous line, a bullish tilt is indicated (green color); if lower, a bearish tilt is indicated (red color). These tilts provide traders with insights into underlying market sentiment and potential direction. A bullish tilt suggests building upward momentum, encouraging traders towards long positions, while a bearish tilt suggests downward momentum, advising caution or consideration of short positions. Accurate assessment of these tilts enhances strategic planning in volatile markets .

Bollinger Bands contribute to identifying potential breakout conditions by plotting upper and lower lines around a simple moving average based on standard deviation, which reflects market volatility. In this strategy, if the daily open price sits above the upper Bollinger Band, it is indicated with a green color, signaling a potential bullish breakout. Conversely, if it is below the lower Bollinger Band, a red color indicates a potential bearish breakout. This visual cue helps traders quickly identify potential breakout conditions and manage their trades accordingly .

The 'Current Week High' and 'Low', along with the 'Previous Day High' and 'Low', are critical for identifying key support and resistance levels in trading. These levels often represent psychological barriers where traders expect price reversals, breakouts, or increased trading activity. By plotting these highs and lows, traders can predict potential price targets or reversals. For instance, if the price breaks above a ‘Previous Day High’, it may indicate strength and a bullish continuation, whereas a breakdown below a ‘Previous Day Low’ might signal weakness and a bearish continuation. Thus, utilizing these levels helps in planning entry and exit points and managing risk .

The script incorporates time-based conditions to set 'day_high' and 'day_low' by resetting these values whenever a new trading day begins (indicated by the 'is_first' condition and 'barstate.isnew' check). These metrics dynamically adjust based on intraday price movements, which are critical for strategies relying on daily price extremes to define support and resistance levels. This approach ensures that traders have up-to-date and accurate reference points throughout the trading day, enhancing their capability to react swiftly to changes in market conditions, capitalize on emerging trends, and adjust their strategies in real-time .

//@version=5
indicator("Current Week High/Low, Previous Day High/Low, Daily Open with Bollinger Bands", 
shorttitle="Current
plot(dailyOpen, color=openColor, style=plot.style_stepline, linewidth=2, title="Daily Open")
plot(upper, color=bullishTilt ?

You might also like