Skip to main content
//@version=4 study("EasyLevels", shorttitle="ESL", overlay=true) length = input(title="ATR Period", type=input.integer, defval=22) mult = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0) showLabels = input(title="Show Buy/Sell Labels?", type=input.bool, defval=true) useClose = input(title="Use Close Price for Extremums?", type=input.bool, defval=true) highlightState = input(title="Highlight State?", type=input.bool, defval=true) atr = mult * atr(length) longStop = (useClose ? highest(close, length) : highest(length)) - atr longStopPrev = nz(longStop[1], longStop) longStop := close[1] > longStopPrev ? max(longStop, longStopPrev) : longStop shortStop = (useClose ? lowest(close, length) : lowest(length)) + atr shortStopPrev = nz(shortStop[1], shortStop) shortStop := close[1] < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop var int dir = 1 dir := close > shortStopPrev ? 1 : close < longStopPrev ? -1 : dir var color longColor = color.new(color.green, 0) var color shortColor = color.new(color.red, 0) longStopPlot = plot(dir == 1 ? longStop : na, title="Long Stop", style=plot.style_linebr, linewidth=2, color=longColor) buySignal = dir == 1 and dir[1] == -1 plotshape(buySignal ? longStop : na, title="Long Stop Start", location=location.absolute, style=shape.circle, size=size.tiny, color=longColor) plotshape(buySignal and showLabels ? longStop : na, title="Buy Label", text="Buy", location=location.absolute, style=shape.labelup, size=size.large, color=longColor) shortStopPlot = plot(dir == 1 ? na : shortStop, title="Short Stop", style=plot.style_linebr, linewidth=2, color=shortColor) sellSignal = dir == -1 and dir[1] == 1 plotshape(sellSignal ? shortStop : na, title="Short Stop Start", location=location.absolute, style=shape.circle, size=size.tiny, color=shortColor) plotshape(sellSignal and showLabels ? shortStop : na, title="Sell Label", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=shortColor, textcolor=color.new(color.white, 0)) midPricePlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0, display=display.none, editable=false) longFillColor = highlightState ? (dir == 1 ? longColor : na) : na shortFillColor = highlightState ? (dir == -1 ? shortColor : na) : na fill(midPricePlot, longStopPlot, title="Long State Filling", color=longFillColor) fill(midPricePlot, shortStopPlot, title="Short State Filling", color=shortFillColor) changeCond = dir != dir[1] alertcondition(changeCond, title="Alert: ESL Direction Change", message="Easy Levels has changed direction!") alertcondition(buySignal, title="Alert: ESL Buy", message="Easy Levels Buy!") alertcondition(sellSignal, title="Alert: ESL Sell", message="Easy Levels Exit Sell!") //@version=5 indicator("EasyLevels", shorttitle="ESL", overlay=true) length = input.int(title="ATR Period", defval=22) mult = input.float(title="ATR Multiplier", defval=3.0, step=0.1) showLabels = input.bool(title="Show Buy/Sell Labels?", defval=true) useClose = input.bool(title="Use Close Price for Extremums?", defval=true) highlightState = input.bool(title="Highlight State?", defval=true) atr = mult * ta.atr(length) longStop = (useClose ? ta.highest(close, length) : ta.highest(length)) - atr longStopPrev = ta.na(longStop[1]) ? longStop : longStopPrev[1] longStop := close[1] > longStopPrev ? max(longStop, longStopPrev) : longStop shortStop = (useClose ? ta.lowest(close, length) : ta.lowest(length)) + atr shortStopPrev = ta.na(shortStop[1]) ? shortStop : shortStopPrev[1] shortStop := close[1] < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop var int dir = 1 dir := close > shortStopPrev ? 1 : close < longStopPrev ? -1 : dir var color longColor = color.new(color.green, 0) var color shortColor = color.new(color.red, 0) longStopPlot = plot(dir == 1 ? longStop : na, title="Long Stop", style=plot.style_linebr, linewidth=2, color=longColor) buySignal = dir == 1 and dir[1] == -1 plotshape(buySignal ? longStop : na, title="Long Stop Start", location=location.absolute, style=shape.circle, size=size.tiny, color=longColor) plotshape(buySignal and showLabels ? longStop : na, title="Buy Label", text="Buy", location=location.absolute, style=shape.labelup, size=size.large, color=longColor) shortStopPlot = plot(dir == 1 ? na : shortStop, title="Short Stop", style=plot.style_linebr, linewidth=2, color=shortColor) sellSignal = dir == -1 and dir[1] == 1 plotshape(sellSignal ? shortStop : na, title="Short Stop Start", location=location.absolute, style=shape.circle, size=size.tiny, color=shortColor) plotshape(sellSignal and showLabels ? shortStop : na, title="Sell Label", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=shortColor, textcolor=color.new(color.white, 0)) midPricePlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0, display=display.none, editable=false) longFillColor = highlightState ? (dir == 1 ? longColor : na) : na shortFillColor = highlightState ? (dir == -1 ? shortColor : na) : na fill(midPricePlot, longStopPlot, title="Long State Filling", color=longFillColor) fill(midPricePlot, shortStopPlot, title="Short State Filling", color=shortFillColor) changeCond = dir != dir[1] alertcondition(changeCond, title="Alert: ESL Direction Change", message="Easy Levels has changed direction!") alertcondition(buySignal, title="Alert: ESL Buy", message="Easy Levels Buy!") alertcondition(sellSignal, title="Alert: ESL Sell", message="Easy Levels Exit Sell!")

Comments

Popular posts from this blog

AI ARTICAL WRITING TOOL

Article Writing Tool Article Writing Tool Category Lifestyle Technology Travel Food Personal Finance Health & Wellness Personal Development Entrepreneurship Art & Design Music Photography Education Environment Politics Social Issues Default (English) Assamese Bengali Gujarati Hindi Kannada Kashmiri Konkani Malayalam Marathi Nepali Odia Punjabi Sanskrit Sindhi Tamil Telugu Urdu Generate Article Thinking... Thinking...

"Exploring the Potential Uses and Implications of Blockchain Technology"

                        What are the potential uses and implications of blockchain technology?

Heikin-Ashi Color Change with RSI Scalping Strategy

  // @version=5 strategy ( "Heikin-Ashi Color Change with RSI Scalping Strategy" , overlay = false ) // Calculate Heikin-Ashi open and close prices haOpen = ( open [ 1 ] + close [ 1 ]) / 2 haClose = ( open + high + low + close ) / 4 isColorChange = ta.change ( haClose ) > 0 // RSI rsiLength = input ( 14 , title = "RSI Length" ) rsi = ta.rsi ( close , rsiLength ) // Variables to track buy/sell conditions var bool shouldBuy = na var bool shouldSell = na // Strategy conditions shouldBuy := isColorChange and haOpen < haClose and rsi > 50 shouldSell := isColorChange and haOpen > haClose and rsi < 50 // Buy and sell orders if shouldBuy     strategy.entry ( "Buy" , strategy.long ) if shouldSell     strategy.entry ( "Sell" , strategy.short ) // Plotting Heikin-Ashi colors for visualization plotshape ( shouldBuy , title = "Buy Signal" , color = color.green , style = shape.t...