Strategy · Pine Script v4 · On the chart

Ichimoku Cloud - Kijun-Sen - RSI - SuperTrend

by myn

This strategy overlays Ichimoku Cloud components alongside SuperTrend and RSI indicators directly on the price chart.

View on GitHub

GitHub stars4on the repository
Pine versionv4older, still runs
Lines of code511
Settings40inputs
LicenceApache-2.0
Last update6 years ago15 Apr 2020

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

511 lines of Pine Script v4 from Strategies/Ichimoku Cloud - Kijun-Sen - RSI - SuperTrend VPT.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

Ichimoku Cloud - Kijun-Sen - RSI - SuperTrend VPT.pine
//@version=4
strategy("Ichimoku Cloud - Kijun-Sen - RSI - SuperTrend", precision=6, overlay=true, pyramiding=0, initial_capital=20000, currency="USD", default_qty_type=strategy.percent_of_equity, default_qty_value=100.0, commission_value=0.075)
// study("StrategyNameHere [Study] - BuildABot-DRR", overlay=true)


/////////////////////////////////////
//* Put your strategy logic below *//
/////////////////////////////////////


ichiCloud_offset   = input(false, title="Standard Ichimoku Cloud")                  // with the visual offset
ichiCloud_noOffset = input(true,  title="Ichimoku Cloud - no offset - no repaint")  // without the visual offset

conversion_prd = input(14, minval=1, title="Conversion Line Period - Tenkan-Sen")
baseline_prd   = input(26, minval=1, title="Base Line Period - Kijun-Sen")
baselineA_prd  = input(52, minval=1, title="Base Line Period - Kijun-Sen (auxiliary)")
leadingSpan_2prd = input(200, minval=1, title="Lagging Span 2 Periods - Senkou Span B")
displacement = input(46, minval=0, title="Displacement: (-) Chikou Span; (+) Senkou Span A")
extra_bars = input(1, minval=0, title="Displacement: additional bars")
laggingSpan_src = input(close, title="Lagging Span price source - Chikou-Span")

donchian(len) => avg(lowest(len), highest(len))
displ = displacement-extra_bars
// ------------------------------------------------------------------------------
// OFFSET:
conversion = donchian(conversion_prd)   // Conversion Line - Tenkan-Sen (9 Period)
baseline  = donchian(baseline_prd)      // Base Line - Kijun-Sen (26 Period)
baselineA = donchian(baselineA_prd)     // Base Line Period - Kijun-Sen (auxiliary)
leadingSpanA = avg(conversion, baseline)
leadingSpanB = donchian(leadingSpan_2prd)
laggingSpan = laggingSpan_src

// Color - bullish, bearish
col_cloud = leadingSpanA>=leadingSpanB ? color.green : color.red

// Cloud Lines
spanA = plot(ichiCloud_offset? leadingSpanA : na, offset=displ, title="Offset: Lead Line 1 - Senkou Span A cloud", color=color.green)
spanB = plot(ichiCloud_offset? leadingSpanB : na, offset=displ, title="Offset: Lead Line 2 - Senkou Span B cloud", color=color.red)
fill(spanA, spanB, color=col_cloud, transp=80, title="Offset: Ichimoku Cloud - Leading Span 1 & 2 based coloring")

// Other Lines
conversion_p = plot(ichiCloud_offset? conversion : na, title="Offset: Conversion Line - Tenkan-Sen", color=#0496ff)
standard_p = plot(ichiCloud_offset? baseline : na, title="Offset: Base Line - Kijun-Sen", color=#991515)
standardA_p = plot(ichiCloud_offset? baselineA : na, title="Offset: Base Line - Kijun-Sen (auxiliary)", color=color.teal)
lagging_Span_p = plot(ichiCloud_offset? laggingSpan : na, offset=-displ, title="Offset: Chikou Span (Lagging Span)", color=#459915)

// ------------------------------------------------------------------------------
// NO OFFSET:
conversion_noOffset = conversion[displ] // Conversion Line - Tenkan-Sen (9 Period)
baseline_noOffset  = baseline[displ]    // Base Line - Kijun-Sen (26 Period)
baselineA_noOffset = baselineA[displ]   // Base Line Period - Kijun-Sen (auxiliary)
leadingSpanA_noOffset = leadingSpanA[displ*2]
leadingSpanB_noOffset = leadingSpanB[displ*2]
laggingSpan_noOffset = laggingSpan[0]

// Color - bullish, bearish
col_cloud_noOffset = leadingSpanA_noOffset>=leadingSpanB_noOffset ? color.green : color.red

// Cloud Lines
spanA_noOffset = plot(ichiCloud_noOffset? leadingSpanA_noOffset : na, title="No offset: Lead Line 1 - Senkou Span A cloud", color=color.green, transp=0)
spanB_noOffset = plot(ichiCloud_noOffset? leadingSpanB_noOffset : na, title="No offset: Lead Line 2 - Senkou Span B cloud", color=color.red, transp=0)
fill(spanA_noOffset, spanB_noOffset, color=col_cloud_noOffset, transp=80, title="No offset: Ichimoku Cloud - Leading Span 1 & 2 based coloring")

// Other Lines
conversion_p_noOffset = plot(ichiCloud_noOffset? conversion_noOffset : na, title="No offset: Conversion Line - Tenkan-Sen", color=#0496ff, transp=0)
baseline_p_noOffset = plot(ichiCloud_noOffset? baseline_noOffset : na, title="No offset: Base Line - Kijun-Sen", color=#991515, transp=0)
baselineA_p_noOffset = plot(ichiCloud_noOffset? baselineA_noOffset : na, title="No offset: Base Line - Kijun-Sen (auxiliary)", color=color.teal, transp=0)
laggingSpan_p_noOffset = plot(ichiCloud_noOffset? laggingSpan_noOffset : na, title="No offset: Chikou Span (Lagging Span)", color=#459915, transp=0)

// ==============================================================================
// Conditions & Alerts (based on the lines without offset)

maxC = max(leadingSpanA_noOffset,leadingSpanB_noOffset)
minC = min(leadingSpanA_noOffset,leadingSpanB_noOffset)

// Trend start signals: crosses between Chikou Span (Lagging Span) and the Cloud (Senkou Span A, Senkou Span B)
uptrend_start   = crossover(laggingSpan_noOffset,maxC)
downtrend_start = crossunder(laggingSpan_noOffset,minC)

// Trends
uptrend   = laggingSpan_noOffset>maxC // Above Cloud
downtrend = laggingSpan_noOffset<minC // Below Cloud

// No trend: choppy trading - the price is in transition
notrend = maxC>=laggingSpan_noOffset and laggingSpan_noOffset>=minC

// Confirmations
uptrend_confirm   = crossover(leadingSpanA_noOffset,leadingSpanB_noOffset)
downtrend_confirm = crossunder(leadingSpanA_noOffset,leadingSpanB_noOffset)

// Signals - crosses between Conversion Line (Tenkan-Sen) and Base Line (Kijun-Sen)
bullish_signal = crossover(conversion_noOffset,baseline_noOffset)
bearish_signal = crossunder(conversion_noOffset,baseline_noOffset)

// Various alerts
//alertcondition(uptrend_start,   title="Uptrend Started",   message="Uptrend Started")
//alertcondition(downtrend_start, title="Downtrend Started", message="Downtrend Started")

//alertcondition(uptrend_confirm,   title="Uptrend Confirmed",   message="Uptrend Confirmed")
//alertcondition(downtrend_confirm, title="Downtrend Confirmed", message="Downtrend Confirmed")

//alertcondition(bullish_signal, title="Buy Signal",  message="Buy Signal")
//alertcondition(bearish_signal, title="Sell Signal", message="Sell Signal")

rsi_OBlevel = input(40, title="RSI Filter: Overbought level (0 = off)")
rsi_OSlevel = input(40,title="RSI Filter: Oversold level (100 = off)")
rsi_len = input(11,title="RSI Length")
rsi_src = input(close,title="RSI Price source")
rsi = rsi(rsi_src,rsi_len)

// Strategy -------------------------------
long_signal  = bullish_signal and uptrend   and rsi<=rsi_OSlevel // breakout filtered by the rsi
exit_long    = bearish_signal and uptrend
short_signal = bearish_signal and downtrend and rsi>=rsi_OBlevel // breakout filtered by the rsi
exit_short   = bullish_signal and downtrend

// Strategy alerts
//alertcondition(long_signal, title="Long Signal - Uptrend",      message="Long Signal - Uptrend")
//alertcondition(exit_long,   title="Long Exit Signal - Uptrend", message="Long Exit Signal - Uptrend")

//alertcondition(short_signal, title="Long Signal - Downtrend",       message="Long Signal - Downtrend")
//alertcondition(exit_short,   title="Short Exit Signal - Downtrend", message="Short Exit Signal - Downtrend")

// Plot areas for trend and transition
color_trend = uptrend? #00FF00 : downtrend? #FF0000 : notrend? color.new(#FFFFFF, 50) : na
fill(spanA_noOffset, spanB_noOffset, color=color_trend, transp=90, title="No offset: Ichimoku Cloud - Lagging Span & Cloud based coloring")

plotshape(ichiCloud_noOffset?uptrend_start:na, title="No offset: Uptrend Started", color=color.green, style=shape.circle, location=location.belowbar, size=size.tiny, text="Up")
plotshape(ichiCloud_noOffset?downtrend_start:na, title="No offset: Downtrend Started", color=color.red, style=shape.circle,location=location.abovebar, size=size.tiny, text="Down")

plotshape(ichiCloud_noOffset?uptrend_confirm:na, title="No offset: Uptrend Confirmed", color=color.green, style=shape.circle, location=location.belowbar, size=size.small, text="Confirm Up")
plotshape(ichiCloud_noOffset?downtrend_confirm:na, title="No offset: Downtrend Confirmed", color=color.red, style=shape.circle, location=location.abovebar, size=size.small, text="Confirm Down")

plotshape(ichiCloud_noOffset?long_signal:na, title="No offset: Long Signal", color=#00FF00, style=shape.triangleup, location=location.belowbar, size=size.small, text="Long")
plotshape(ichiCloud_noOffset?exit_long:na, title="No offset: Exit Long Signal", color=color.fuchsia, style=shape.triangledown, location=location.abovebar, size=size.small, text="Exit long")

plotshape(ichiCloud_noOffset?short_signal:na, title="No offset: Short Signal", color=#FF0000, style=shape.triangledown, location=location.abovebar, size=size.small, text="Short")
plotshape(ichiCloud_noOffset?exit_short:na, title="No offset: Exit Short Signal", color=color.fuchsia, style=shape.triangleup, location=location.belowbar, size=size.small, text="Exit short")


//study(title="Super trend VPT", shorttitle="STVPT", overlay=true)
//The volume price trend ( VPT ) indicator helps determine a security’s price direction and strength of price change. The indicator consists of a cumulative volume line that adds or subtracts a multiple of the percentage change in a share price’s trend and current volume , depending upon the security’s upward or downward movements. 
//https://www.tradingview.com/script/i8FO3CyP-VPT-v4/
source = close
hilow = ((high - low)*100)
openclose = ((close - open)*100)
vol = (volume / hilow)
spreadvol = (openclose * vol)
VPT = spreadvol + cum(spreadvol)
window_len = 28

v_len = 14
price_spread = stdev(high-low, window_len)

v =  spreadvol + cum(spreadvol)
smooth = sma(v, v_len)
v_spread = stdev(v - smooth, window_len)
shadow = (v - smooth) / v_spread * price_spread

out = shadow > 0 ? high + shadow : low + shadow

//plot(out, style=line,linewidth=3, color=color)
len=input(9)
vpt=ema(out,len)
//lineColor = vpt > vpt[1] ? color.green : color.red
//plot(vpt, linewidth=3, color=lineColor)
//x=crossover(vpt , vpt[1]) and vpt > vpt[1]
//z=crossunder(vpt , vpt[1]) and vpt <vpt[1]
//plotshape(crossover(vpt , vpt[1]) and vpt > vpt[1], "up arrow", shape.triangleup, location.belowbar, color.green,size=size.tiny)
//plotshape(crossunder(vpt , vpt[1]) and vpt <vpt[1] , "down arrow", shape.triangledown, location.abovebar, color.red,size=size.tiny)
//

// INPUTS //
st_mult   = input(4,   title = 'SuperTrend Multiplier', minval = 0, maxval = 100, step = 0.01)
st_period = input(9, title = 'SuperTrend Period',     minval = 1)

// CALCULATIONS //
up_lev = vpt - (st_mult * atr(st_period))
dn_lev = vpt + (st_mult * atr(st_period))

up_trend   = 0.0
up_trend   := close[1] > up_trend[1]   ? max(up_lev, up_trend[1])   : up_lev

down_trend = 0.0
down_trend := close[1] < down_trend[1] ? min(dn_lev, down_trend[1]) : dn_lev

// Calculate trend var
st_trend = 0
st_trend := close > down_trend[1] ? 1: close < up_trend[1] ? -1 : nz(st_trend[1], 1)

// Calculate SuperTrend Line
st_line = st_trend ==1 ? up_trend : down_trend

// Plotting
plot(st_line[1], color = st_trend == 1 ? color.green : color.red , style = plot.style_cross, linewidth = 2, title = "SuperTrend")
buy_signal=crossover( close, st_line)
sell_signal=crossunder(close, st_line)
//plotshape(crossover( close, st_line), location = location.belowbar, color = color.green,size=size.tiny)
//plotshape(crossunder(close, st_line), location = location.abovebar, color = color.red,size=size.tiny)
plotshape(buy_signal,title="Buy", color=color.blue, style=shape.arrowup,location=location.belowbar, text="Buy")
plotshape(sell_signal,title="Sell", color=color.black, style=shape.arrowdown,text="Sell")
/////// Alerts /////
//alertcondition(buy_signal,title="buy")
//alertcondition(sell_signal,title="sell")


long_signal := long_signal or buy_signal
short_signal := short_signal or sell_signal
// ============================================================================== Strategy Component - uncomment to activate
//if (long_signal)
//    strategy.entry("Long",strategy.long)
//if (exit_long)
//    strategy.close("Long")
//if (short_signal)
//    strategy.entry("Short",strategy.short)
//if (exit_short)
//   strategy.close("Short")
// ==============================================================================
//////////////////////////////////////
//* Put your strategy rules below *//
/////////////////////////////////////

longLogic = long_signal 
shortLogic = short_signal

longCondClose = exit_long
shortCondClose = exit_short

///////////////////////////////////////////////
//* Backtesting Period Selector | Component *//
///////////////////////////////////////////////

//* https://www.tradingview.com/script/eCC1cvxQ-Backtesting-Period-Selector-Component *//
//* https://www.tradingview.com/u/pbergden/ *//
//* Modifications made *//
timePeriodDivider = input(false,"░░░░░░░░░░░░░░░░░░░░░░░░░")
testStartYear = input(2019, "Backtest Start Year") 
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)

testStopYear = input(77777777, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(31, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)

testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false


//////////////////////////
//* Strategy Component *//
//////////////////////////
longShortFlipDivider = input(false, "░░░░░░░░░░░░░░░░░░░░░░░░░")
isLong = input(false, "Longs Only")
isShort = input(false, "Shorts Only")
isFlip = input(false, "Flip the Opens")

long = longLogic
short = shortLogic

if isFlip
    long := shortLogic
    short := longLogic
    short
else
    long := longLogic
    short := shortLogic
    short

if isLong
    long := long
    short := na
    short

if isShort
    long := na
    short := short
    short

////////////////////////////////
//======[ Signal Count ]======//
////////////////////////////////

sectionLongs = 0
sectionLongs := nz(sectionLongs[1])
sectionShorts = 0
sectionShorts := nz(sectionShorts[1])

if long
    sectionLongs := sectionLongs + 1
    sectionShorts := 0
    sectionShorts

if short
    sectionLongs := 0
    sectionShorts := sectionShorts + 1
    sectionShorts

//////////////////////////////
//======[ Pyramiding ]======//
//////////////////////////////
pyramidingDivider = input(false, "░░░░░░░░░░░░░░░░░░░░░░░░░")
pyrl = input(1, "Pyramiding less than")  // If your count is less than this number
pyre = input(0, "Pyramiding equal to")  // If your count is equal to this number
pyrg = input(1000000, "Pyramiding greater than")  // If your count is greater than this number

longCondition = long and sectionLongs <= pyrl or long and sectionLongs >= pyrg or 
   long and sectionLongs == pyre ? 1 : 0
shortCondition = short and sectionShorts <= pyrl or short and sectionShorts >= pyrg or 
   short and sectionShorts == pyre ? 1 : 0

////////////////////////////////
//======[ Entry Prices ]======//
////////////////////////////////

last_open_longCondition = float(na)
last_open_shortCondition = float(na)
last_open_longCondition := longCondition ? close : nz(last_open_longCondition[1])
last_open_shortCondition := shortCondition ? close : nz(last_open_shortCondition[1])

////////////////////////////////////
//======[ Open Order Count ]======//
////////////////////////////////////

sectionLongConditions = 0
sectionLongConditions := nz(sectionLongConditions[1])
sectionShortConditions = 0
sectionShortConditions := nz(sectionShortConditions[1])

if longCondition
    sectionLongConditions := sectionLongConditions + 1
    sectionShortConditions := 0
    sectionShortConditions

if shortCondition
    sectionLongConditions := 0
    sectionShortConditions := sectionShortConditions + 1
    sectionShortConditions

///////////////////////////////////////////////
//======[ Position Check (long/short) ]======//
///////////////////////////////////////////////

last_longCondition = float(na)
last_shortCondition = float(na)
last_longCondition := longCondition ? time : nz(last_longCondition[1])
last_shortCondition := shortCondition ? time : nz(last_shortCondition[1])

in_longCondition = last_longCondition > last_shortCondition
in_shortCondition = last_shortCondition > last_longCondition

/////////////////////////////////////
//======[ Position Averages ]======//
/////////////////////////////////////

totalLongs = 0.0
totalLongs := nz(totalLongs[1])
totalShorts = 0.0
totalShorts := nz(totalShorts[1])
averageLongs = 0.0
averageLongs := nz(averageLongs[1])
averageShorts = 0.0
averageShorts := nz(averageShorts[1])

if longCondition
    totalLongs := totalLongs + last_open_longCondition
    totalShorts := 0.0
    totalShorts

if shortCondition
    totalLongs := 0.0
    totalShorts := totalShorts + last_open_shortCondition
    totalShorts

averageLongs := totalLongs / sectionLongConditions
averageShorts := totalShorts / sectionShortConditions

/////////////////////////////////
//======[ Trailing Stop ]======//
/////////////////////////////////

trailingStopDivider = input(false, "░░░░░░░░░░░░░░░░░░░░░░░░░")
isTS = input(false, "Trailing Stop")
tsi = input(1, "Activate Trailing Stop Price (%)", type=input.float, step=0.10)
ts = input(1, "Trailing Stop (%)", type=input.float, step=0.10)

last_high = float(na)
last_low = float(na)
last_high_short = float(na)
last_low_short = float(na)
last_high := not in_longCondition ? na : 
   in_longCondition and (na(last_high[1]) or high > nz(last_high[1])) ? high : 
   nz(last_high[1])
last_high_short := not in_shortCondition ? na : 
   in_shortCondition and (na(last_high[1]) or high > nz(last_high[1])) ? high : 
   nz(last_high[1])
last_low := not in_shortCondition ? na : 
   in_shortCondition and (na(last_low[1]) or low < nz(last_low[1])) ? low : 
   nz(last_low[1])
last_low_short := not in_longCondition ? na : 
   in_longCondition and (na(last_low[1]) or low < nz(last_low[1])) ? low : 
   nz(last_low[1])

long_ts = isTS and not na(last_high) and low <= last_high - last_high / 100 * ts and 
   longCondition == 0 and last_high >= averageLongs + averageLongs / 100 * tsi
short_ts = isTS and not na(last_low) and high >= last_low + last_low / 100 * ts and 
   shortCondition == 0 and last_low <= averageShorts - averageShorts / 100 * tsi

///////////////////////////////
//======[ Take Profit ]======//
///////////////////////////////

takeProfitDivider = input(false, "░░░░░░░░░░░░░░░░░░░░░░░░░")
isTP = input(false, "Take Profit")
tp = input(6, "Take Profit (%)", type=input.float, step=0.10)
long_tp = isTP and close > averageLongs + averageLongs / 100 * tp and not longCondition
short_tp = isTP and close < averageShorts - averageShorts / 100 * tp and not shortCondition

/////////////////////////////
//======[ Stop Loss ]======//
/////////////////////////////

stopLossDivider = input(false, "░░░░░░░░░░░░░░░░░░░░░░░░░")
isSL = input(true, "Stop Loss")
sl = input(6, "Stop Loss (%)", type=input.float, step=0.10)
long_sl = isSL and close < averageLongs - averageLongs / 100 * sl and longCondition == 0
short_sl = isSL and close > averageShorts + averageShorts / 100 * sl and 
   shortCondition == 0

//////////////////////////////////////
//======[ Conditional Closes ]======//
/////////////////////////////////////
conditionalClosesDivider = input(false, "░░░░░░░░░░░░░░░░░░░░░░░░░")
isCLl = input(false, "Close Condition Long")
isCLs = input(false, "Close Condition Short")
long_cl = isCLl and longCondClose and in_longCondition == 1
short_cl = isCLs and shortCondClose and in_shortCondition == 1


/////////////////////////////////
//======[ Close Signals ]======//
/////////////////////////////////

longClose = long_tp or long_sl or long_ts or long_cl ? 1 : 0
shortClose = short_tp or short_sl or short_ts or short_cl ? 1 : 0

///////////////////////////////
//======[ Plot Colors ]======//
///////////////////////////////

longCloseCol = color(na)
shortCloseCol = color(na)
longCloseCol := long_tp ? color.purple : 
   long_sl ? color.maroon : long_ts ? color.blue : longCloseCol[1]
shortCloseCol := short_tp ? color.purple : 
   short_sl ? color.maroon : short_ts ? color.blue : shortCloseCol[1]
tpColor = isTP and in_longCondition ? color.purple : 
   isTP and in_shortCondition ? color.purple : color.white
slColor = isSL and in_longCondition ? color.red : 
   isSL and in_shortCondition ? color.red : color.white

//////////////////////////////////
//======[ Strategy Plots ]======//
//////////////////////////////////

plot(isTS and in_longCondition ? averageLongs + averageLongs / 100 * tsi : na, "Long Trailing Activate", color.blue, style=3, linewidth=2)
plot(isTS and in_longCondition and last_high >= averageLongs + averageLongs / 100 * tsi ? last_high - last_high / 100 * ts : na, "Long Trailing", color.fuchsia, style=2, linewidth=3)
plot(isTS and in_shortCondition ? averageShorts - averageShorts / 100 * tsi : na, "Short Trailing Activate", color.blue, style=3, linewidth=2)
plot(isTS and in_shortCondition and last_low <= averageShorts - averageShorts / 100 * tsi ? last_low + last_low / 100 * ts : na, "Short Trailing", color.fuchsia, style=2, linewidth=3)
plot(isTP and in_longCondition and last_high < averageLongs + averageLongs / 100 * tp ? averageLongs + averageLongs / 100 * tp : na, "Long TP", tpColor, style=3, linewidth=2)
plot(isTP and in_shortCondition and last_low > averageShorts - averageShorts / 100 * tp ? averageShorts - averageShorts / 100 * tp : na, "Short TP", tpColor, style=3, linewidth=2)
plot(isSL and in_longCondition and last_low_short > averageLongs - averageLongs / 100 * sl ? averageLongs - averageLongs / 100 * sl : na, "Long SL", slColor, style=3, linewidth=2)
plot(isSL and in_shortCondition and last_high_short < averageShorts + averageShorts / 100 * sl ? averageShorts + averageShorts / 100 * sl : na, "Short SL", slColor, style=3, linewidth=2)

///////////////////////////////
//======[ Alert Plots ]======//
///////////////////////////////

// plot(longCondition, "Long", green)
// plot(shortCondition, "Short", red)
// plot(longClose, "Long Close", longCloseCol)
// plot(shortClose, "Short Close", shortCloseCol)

///////////////////////////////////
//======[ Reset Variables ]======//
///////////////////////////////////

if longClose or not in_longCondition
    averageLongs := 0
    totalLongs := 0.0
    sectionLongs := 0
    sectionLongConditions := 0
    sectionLongConditions

if shortClose or not in_shortCondition
    averageShorts := 0
    totalShorts := 0.0
    sectionShorts := 0
    sectionShortConditions := 0
    sectionShortConditions

////////////////////////////////////////////
//======[ Strategy Entry and Exits ]======//
////////////////////////////////////////////

if testPeriod()
    strategy.entry("Long", 1, when=longCondition)
    strategy.entry("Short", 0, when=shortCondition)
    strategy.close("Long", when=longClose)
    strategy.close("Short", when=shortClose)

Overview

Ichimoku Cloud - Kijun-Sen - RSI - SuperTrend evaluates trend conditions using Tenkan-Sen, Kijun-Sen, and cloud spans, combining them with SuperTrend signals and RSI momentum boundaries to execute long or short trades. The strategy allocates one hundred percent of available equity per trade by default. Key settings adjust indicator periods, displacement offset toggles, RSI thresholds, SuperTrend parameters, and backtest date ranges. By default, the script operates without an explicit stop loss or predefined take profit target.

Details

Published by

myn on GitHub

Type

Strategy, Pine Script v4

Draws

On the price chart

Category

Trend, Oscillators & momentum, Volatility & bands

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Standard Ichimoku CloudboolfalseichiCloud_offset
Ichimoku Cloud - no offset - no repaintbooltrueichiCloud_noOffset
Conversion Line Period - Tenkan-Senint14conversion_prd
Base Line Period - Kijun-Senint26baseline_prd
Base Line Period - Kijun-Sen (auxiliary)int52baselineA_prd
Lagging Span 2 Periods - Senkou Span Bint200leadingSpan_2prd
Displacement: (-) Chikou Span; (+) Senkou Span Aint46displacement
Displacement: additional barsint1extra_bars
Lagging Span price source - Chikou-SpansourcecloselaggingSpan_src
RSI Filter: Overbought level (0 = off)int40rsi_OBlevel
RSI Filter: Oversold level (100 = off)int40rsi_OSlevel
RSI Lengthint11rsi_len
Show all 40 settings
SettingTypeDefaultVariable
RSI Price sourcesourceclosersi_src
lenint9len
SuperTrend Multiplierint4st_mult
SuperTrend Periodint9st_period
░░░░░░░░░░░░░░░░░░░░░░░░░boolfalsetimePeriodDivider
Backtest Start Yearint2019testStartYear
Backtest Start Monthint1testStartMonth
Backtest Start Dayint1testStartDay
Backtest Stop Yearint77777777testStopYear
Backtest Stop Monthint12testStopMonth
Backtest Stop Dayint31testStopDay
░░░░░░░░░░░░░░░░░░░░░░░░░boolfalselongShortFlipDivider
Longs OnlyboolfalseisLong
Shorts OnlyboolfalseisShort
Flip the OpensboolfalseisFlip
░░░░░░░░░░░░░░░░░░░░░░░░░boolfalsepyramidingDivider
Pyramiding less thanint1pyrl
Pyramiding equal toint0pyre
Pyramiding greater thanint1000000pyrg
░░░░░░░░░░░░░░░░░░░░░░░░░boolfalsetrailingStopDivider
Trailing StopboolfalseisTS
Activate Trailing Stop Price (%)float1tsi
Trailing Stop (%)float1ts
░░░░░░░░░░░░░░░░░░░░░░░░░boolfalsetakeProfitDivider
Take ProfitboolfalseisTP
Take Profit (%)float6tp
░░░░░░░░░░░░░░░░░░░░░░░░░boolfalsestopLossDivider
Stop LossbooltrueisSL
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

106 stars

This trading strategy combines three Exponential Moving Averages (8, 14, and 50 periods by default) with Stochastic RSI and Average True Range (ATR). It enters a long position when EMA 1 is above EMA 2, EMA 2 is above EMA 3, and the Stochastic RSI %K line cros

Strategy v4 TrendOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 3 x EMA + Stochastic RSI + ATR

Momentum Rider DAILY FINAL

by greenpeas007
58 stars

This strategy combines exponential moving averages (EMA 9, 21, 50), RSI, MACD, and Supertrend indicators to enter long positions. It triggers trades using six dynamic setups based on momentum breakouts, EMA crossovers, and pullbacks. Position sizing is compute

Strategy v6 TrendOscillators & momentum Repaints
Updated 4 months ago · Custom licence GitHub repository of Momentum Rider DAILY FINAL
57 stars

This strategy identifies trend reversals through market structure changes (CHoCH) filtered by MACD momentum. It initiates long positions on bullish structure breaks when MACD is positive and above its signal line, and short positions on bearish breaks when MAC

Strategy v6 SMC / ICT / price actionOscillators & momentum Repaints
Updated 1 year ago · Apache-2.0 GitHub repository of Market Structure MACD 4H + Trailing

CombinedBinHAndClucV6

by viktors1982
36 stars

CombinedBinHAndClucV6 is a trading strategy based on the popular BinHV45 and ClucMay72018 algorithms. It calculates dual Bollinger Bands, Exponential Moving Averages, Relative Strength Index, Average True Range, and volume metrics across primary and one-hour h

Strategy v4 Volatility & bandsOscillators & momentum Repaints
Updated 2 years ago · None stated GitHub repository of CombinedBinHAndClucV6
27 stars

LuxAlgo Hybrid Gold Scalper is a price-chart strategy aimed at gold. It stacks a fast, slow, trend and 200-period bias EMA to mark trend direction, then filters strength with RSI, ADX and an intraday VWAP. Swing highs and lows are marked from pivot length. Set

Strategy v5 TrendOscillators & momentum
Updated 5 months ago · None stated GitHub repository of LuxAlgo Hybrid Gold Scalper

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers