Skip to content

Instantly share code, notes, and snippets.

@e-fu
Last active November 13, 2019 08:03
Show Gist options
  • Save e-fu/1fe5ebda8493ab139f2ae7f54e6f5cb9 to your computer and use it in GitHub Desktop.
Save e-fu/1fe5ebda8493ab139f2ae7f54e6f5cb9 to your computer and use it in GitHub Desktop.
//@version=4
persistent_bull = 0.0
persistent_bull := nz(persistent_bull[1],0)
persistent_bear = 0.0
persistent_bear := nz(persistent_bear[1],0)
// https://medium.com/@coinpocalypse/a-simple-start-80fe92c92b15
strategy(title = "Strategy for Crypto, Forex, Shares, Futures, Options", shorttitle = "$$$$$$", overlay = true,
pyramiding = 0,
initial_capital = 100000,
currency = currency.USD,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
// default_qty_type = strategy.cash, default_qty_value = 100,
commission_type = strategy.commission.percent,
commission_value = 0.075,
calc_on_every_tick=false)
// === BACKTEST RANGE ===
FromMonth = input(defval = 1, title = "From Month", minval = 1)
FromDay = input(defval = 1, title = "From Day", minval = 1)
FromYear = input(defval = 2019, title = "From Year", minval = 2014)
ToMonth = input(defval = 1, title = "To Month", minval = 1)
ToDay = input(defval = 1, title = "To Day", minval = 1)
ToYear = input(defval = 9999, title = "To Year", minval = 2014)
testPeriod() =>
(time > timestamp(FromYear, FromMonth, FromDay, 00, 00)) and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))
// study(title="Indicator for Crypto, Forex, Shares, Futures, Options", shorttitle="$", overlay=true)
// ****************************************Inputs***************************************************************
buySellSignal = input(true, "Show the buy sell signals?")
cogRegionFillTransp = input(false, "Display COG & ATR Starc+/-?")
showFibCOG=input(false, "Display COG FIB based S(upport) and R(esistance)?")
inputIndividualSiganlPlot = true
sp = input (false, "Display Parabolic SAR - SAR?")
spLines = sp ? true : false
sCloud = input(false, "Display Ichimoku - Ichimoku?")
sL = input (false, "Display Leledec Exhausion - Leledc?")
sTD = false
sRMO = input(false, "Display Rahul Mohindar Oscillator - RMO?")
inputAma = input(false, title="Display Kaufman AMA wave - AMA?")
tm = input (false, "Display Trend Magic signals - TMI?")
wtoLB = input (false, "Display WaveTrend Oscillator - WTO?")
vfiLB = input (false, "Display Volume Flow Indicator - VFI?")
maj=input(true,title="Display Major Leledc Exhausion Bar signal - Leledec")
inputNeutralMinorSignals = input (false, title="Display the minor / not strong signals from Ichimoku")
min=input(false,title="Display Minor Leledc Exhausion Bar signal - Leledec")
tenkanPeriods = input(10, minval=9, title="Tenkan Period - Ichimoku [(normal)9 or (forex)10 or (crypto)20]")
kijunPeriods = input(30, minval=26, title="Kijun Period - Ichimoku [(normal)26 or (forex)30 or (crypto)60]")
chikouPeriods = input(60, minval=52, title="Chikou - Ichimoku [(normal)52 or (forex)60 or (crypto)120]")
displacement = input(30, minval=26, title="Displacement - Ichimoku [(normal/forex)26 or (crypto)30]")
// ****************************************General Color Variables***************************************************************
colorLime = #006400 // Warning sign for long trade
colorBuy= #2DFF03 // Good sign for long trade
colorSell = #733629 // Good sign for short trade
colorMaroon =#8b0000 // Warning sign for short trade
colorBlue =#0000ff // No clear sign
colorGray = #a9a9a9 // Gray Color (For Squeeze momentum indicator)
colorBlack = #000000 // Black
colorWhite = #ffffff // White
colorTenkanViolet = #800000 // Tenkan-sen line color
colorKijun = #0000A6 // Kijun-sen line color
// TD Sequential bar colors
tdSell = #ff6666
tdSellOvershoot = #ff1a1a
tdSellOvershoot1 = #cc0000
tdSellOverShoot2 = #990000
tdSellOverShoot3 = #732626
tdBuy = #80ff80
tdBuyOverShoot = #33ff33
tdBuyOvershoot1 = #00cc00
tdBuyOverShoot2 = #008000
tdBuyOvershoot3 = #004d00
barBuy = #006a4e
barSell = #c91f37
// ****************************************Icons***************************************************************
upSign = '↑' // indicates the indicator shows uptrend
downSign = '↓' // incicates the indicator showing downtrend
exitSign ='x' //indicates the indicator uptrend/downtrend ending
// diamond signals weakBullishSignal or weakBearishsignal
// flag signals neutralBullishSignal or neutralBearishSignal
// ****************************************Parabolic SAR code***************************************************************
start = 2
increment = 2
maximum = 2
sus = true
sds = true
disc = false
startCalc = start * .01
incrementCalc = increment * .01
maximumCalc = maximum * .10
sarUp = sar(startCalc, incrementCalc, maximumCalc)
sarDown = sar(startCalc, incrementCalc, maximumCalc)
colUp = spLines and close >= sarDown ? colorLime : na
colDown = spLines and close <= sarUp ? colorSell : na
plot(sp and sus and sarUp ? sarUp : na, title="↓ SAR", style=plot.style_cross, linewidth=3,color=colUp)
plot(sp and sds and sarDown ? sarDown : na, title="↑ SAR", style=plot.style_circles, linewidth=3,color=colDown)
startSAR = 0.02
incrementSAR = 0.02
maximumSAR = 0.2
psar = sar(startSAR, incrementSAR, maximumSAR)
bullishPSAR = psar < high and psar[1] > low
bearishPSAR= psar > low and psar[1] < high
//***********************Leledc Exhausion Bar***********************************************
leledcSrc=input(close, "Major Leledec Exhausion Bar :: Source")
maj_qual=input(6, "Major Leledec Exhausion Bar :: Bar count no")
maj_len=input(30, "Major Leledec Exhausion Bar :: Highest / Lowest")
min_qual=input(5, "Minor Leledec Exhausion Bar :: Bar count no")
min_len=input(5, "Minor Leledec Exhausion Bar :: Bar count no")
lele(qual,len)=>
bindex = 0.0
sindex = 0.0
bindex:=nz(bindex[1],0)
sindex:=nz(sindex[1],0)
ret=0
if (leledcSrc>leledcSrc[4])
bindex:=bindex + 1
if(leledcSrc<leledcSrc[4])
sindex:=sindex + 1
if (bindex>qual) and (leledcSrc<open) and high>=highest(high,len)
bindex:=0
ret:=-1
if ((sindex>qual) and (leledcSrc>open) and (low<= lowest(low,len)))
sindex:=0
ret:=1
return=ret
major=lele(maj_qual,maj_len)
minor=lele(min_qual,min_len)
leledecMajorBullish = maj ? (major==1?low:na) : na
leledecMajorBearish = maj ? (major==-1?high:na) : na
//****************Ichimoku ************************************
donchian(len) => avg(lowest(len), highest(len))
tenkan = donchian(tenkanPeriods)
kijun = donchian(kijunPeriods)
senkouA = avg(tenkan, kijun)
senkouB = donchian(chikouPeriods)
displacedSenkouA = senkouA[displacement]
displacedSenkouB = senkouB[displacement]
bullishSignal = crossover(tenkan, kijun)
bearishSignal = crossunder(tenkan, kijun)
bullishSignalValues = iff(bullishSignal, tenkan, na)
bearishSignalValues = iff(bearishSignal, tenkan, na)
strongBullishSignal = crossover(tenkan, kijun) and bullishSignalValues > displacedSenkouA and bullishSignalValues > displacedSenkouB and low > tenkan and displacedSenkouA > displacedSenkouB
strongBearishSignal = bearishSignalValues < displacedSenkouA and bearishSignalValues < displacedSenkouB and high < tenkan and displacedSenkouA < displacedSenkouB
neutralBullishSignal = (bullishSignalValues > displacedSenkouA and bullishSignalValues < displacedSenkouB) or (bullishSignalValues < displacedSenkouA and bullishSignalValues > displacedSenkouB)
weakBullishSignal = bullishSignalValues < displacedSenkouA and bullishSignalValues < displacedSenkouB
neutralBearishSignal = (bearishSignalValues > displacedSenkouA and bearishSignalValues < displacedSenkouB) or (bearishSignalValues < displacedSenkouA and bearishSignalValues > displacedSenkouB)
weakBearishSignal = bearishSignalValues > displacedSenkouA and bearishSignalValues > displacedSenkouB
//*********************Kaufman AMA wave*********************//
srcAMA=input(close, "Kaufman AMA wave :: Source")
lengthAMA=input(20, "Kaufman AMA wave :: Length")
filterp = input(10, "Kaufman AMA wave :: Efficiency Ratio")
d=abs(srcAMA-srcAMA[1])
s=abs(srcAMA-srcAMA[lengthAMA])
noise=sum(d, lengthAMA)
efratio=s/noise
fastsc=input(0.6022, "Kaufman AMA wave :: Fastsc")
slowsc=input(0.0645, "Kaufman AMA wave :: Slowsc")
smooth=pow(efratio*fastsc+slowsc, 2)
ama = 0.0
ama:=nz(ama[1], srcAMA)+smooth*(srcAMA-nz(ama[1], srcAMA ))
filter=filterp/100 * stdev(ama-nz(ama), lengthAMA)
amalow = 0.0
amalow := ama < nz(ama[1]) ? ama : nz(amalow[1])
amahigh = 0.0
amahigh :=ama > nz(ama[1]) ? ama : nz(amahigh[1])
bw = 0.0
bw := (ama-amalow) > filter ? 1 : (amahigh-ama > filter ? -1 : 0)
s_color = bw > 0 ? colorBuy : (bw < 0) ? colorSell : colorBlue
amaLongConditionEntry = s_color==colorBuy and s_color[1]!=colorBuy
amaShortConditionEntry = s_color==colorSell and s_color[1]!=colorSell
//***********************Rahul Mohindar Oscillator ******************************//
AMASRC=input(close, "Rahul Mohindar Oscillator :: Source")
cm2(x) => sma(x,2)
ma1=cm2(AMASRC)
ma2=cm2(ma1)
ma3=cm2(ma2)
ma4=cm2(ma3)
ma5=cm2(ma4)
ma6=cm2(ma5)
ma7=cm2(ma6)
ma8=cm2(ma7)
ma9=cm2(ma8)
ma10=cm2(ma9)
SwingTrd1 = 100 * (AMASRC - (ma1+ma2+ma3+ma4+ma5+ma6+ma7+ma8+ma9+ma10)/10)/(highest(AMASRC,10)-lowest(AMASRC,10))
SwingTrd2=ema(SwingTrd1,30)
SwingTrd3=ema(SwingTrd2,30)
RMO= ema(SwingTrd1,81)
Buy=cross(SwingTrd2,SwingTrd3)
Sell=cross(SwingTrd3,SwingTrd2)
Bull_Trend=ema(SwingTrd1,81)>0
Bear_Trend=ema(SwingTrd1,81)<0
Ribbon_kol=Bull_Trend ? colorBuy : (Bear_Trend ? colorSell : colorBlue)
Impulse_UP= SwingTrd2 > 0
Impulse_Down= RMO < 0
bar_kol=Impulse_UP ? colorBuy : (Impulse_Down ? colorSell : (Bull_Trend ? colorBuy : colorBlue))
rahulMohindarOscilllatorLongEntry = Ribbon_kol==colorBuy and Ribbon_kol[1]!=colorBuy and Ribbon_kol[1]==colorSell and bar_kol==colorBuy
rahulMohindarOscilllatorShortEntry = Ribbon_kol==colorSell and Ribbon_kol[1]!=colorSell and Ribbon_kol[1]==colorBuy and bar_kol==colorSell
//***********************TD Sequential code ******************************//
transp=0
Numbers=false
SR=false
Barcolor=true
TD = 0.0
TS = 0.0
TD := close > close[4] ?nz(TD[1])+1:0
TS := close < close[4] ?nz(TS[1])+1:0
TDUp = TD - valuewhen(TD < TD[1], TD , 1 )
TDDn = TS - valuewhen(TS < TS[1], TS , 1 )
priceflip = barssince(close<close[4])
sellsetup = close>close[4] and priceflip
sell = sellsetup and barssince(priceflip!=9)
sellovershoot = sellsetup and barssince(priceflip!=13)
sellovershoot1 = sellsetup and barssince(priceflip!=14)
sellovershoot2 = sellsetup and barssince(priceflip!=15)
sellovershoot3 = sellsetup and barssince(priceflip!=16)
priceflip1 = barssince(close>close[4])
buysetup = close<close[4] and priceflip1
buy = buysetup and barssince(priceflip1!=9)
buyovershoot = barssince(priceflip1!=13) and buysetup
buyovershoot1 = barssince(priceflip1!=14) and buysetup
buyovershoot2 = barssince(priceflip1!=15) and buysetup
buyovershoot3 = barssince(priceflip1!=16) and buysetup
TDbuyh = valuewhen(buy,high,0)
TDbuyl = valuewhen(buy,low,0)
TDsellh = valuewhen(sell,high,0)
TDselll = valuewhen(sell,low,0)
//***********************Volume Flow Indicator [LazyBear] ******************************//
lengthVFI = input(130, title="Volume Flow Indicator :: length")
coefVFI = input(0.2, title="Volume Flow Indicator :: Coef")
vcoefVFI = input(2.5, title="Volume Flow Indicator :: Max. vol. cutoff")
signalLength=input(5, title="Volume Flow Indicator :: signal length")
smoothVFI=input(false, type=input.bool, title="Volume Flow :: Indicator smooth?")
ma(x,y) => smoothVFI ? sma(x,y) : x
typical=hlc3
inter = log( typical ) - log( typical[1] )
vinter = stdev(inter, 30 )
cutoff = coefVFI * vinter * close
vave = sma( volume, lengthVFI )[1]
vmax = vave * vcoefVFI
vc = iff(volume < vmax, volume, vmax)
mf = typical - typical[1]
vcp = iff( mf > cutoff, vc, iff ( mf < -cutoff, -vc, 0 ) )
vfi = ma(sum( vcp , lengthVFI )/vave, 3)
vfima=ema( vfi, signalLength )
dVFI=vfi-vfima
bullishVFI = vfi > 0 and vfi[1] <=0
bearishVFI = vfi < 0 and vfi[1] >=0
//***********************WaveTrend Oscillator [WT] ******************************//
n1 = input(10, "WaveTrend Oscillator:: Channel Length")
n2 = input(21, "WaveTrend Oscillator:: Average Length")
obLevel1 = input(60, "WaveTrend Oscillator:: Over Bought Level 1")
obLevel2 = input(53, "WaveTrend Oscillator:: Over Bought Level 2")
osLevel1 = input(-60, "WaveTrend Oscillator:: Over Sold Level 1")
osLevel2 = input(-53, "WaveTrend Oscillator:: Over Sold Level 2")
ap = hlc3
esa = ema(ap, n1)
dWTI = ema(abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * dWTI)
tci = ema(ci, n2)
wt1 = tci
wt2 = sma(wt1,4)
wtiSignal = wt1-wt2
bullishWTI = wt1 > osLevel1 and wt1[1] <= osLevel1 and wtiSignal > 0
bearishWTI = wt1 < obLevel1 and wt1[1] >= obLevel1 and wtiSignal < 0
// **************** Trend Magic code adapted from Glaz ********************* /
CCI = input(20, "Tend Magic:: Input for CCI")
ATR = input(5, "Tend Magic:: Input for ATRc")
Multiplier= input(1, "Tend Magic :: ATR Multiplier")
original= true
thisCCI = cci(close, CCI)
lastCCI = nz(thisCCI[1])
bufferDn= high + Multiplier * sma(tr,ATR)
bufferUp= low - Multiplier * sma(tr,ATR)
if (thisCCI >= 0 and lastCCI < 0)
bufferUp := bufferDn[1]
if (thisCCI <= 0 and lastCCI > 0)
bufferDn := bufferUp[1]
if (thisCCI >= 0)
if (bufferUp < bufferUp[1])
bufferUp := bufferUp[1]
else
if (thisCCI <= 0)
if (bufferDn > bufferDn[1])
bufferDn := bufferDn[1]
x = 0.0
x:=thisCCI >= 0 ?bufferUp:thisCCI <= 0 ?bufferDn:x[1]
swap = 0.0
swap:=x>x[1]?1:x<x[1]?-1:swap[1]
swap2=swap==1?color.lime:color.red
swap3=thisCCI >=0 ?color.lime:color.red
swap4=original?swap3:swap2
bullTrendMagic = swap4 == color.lime and swap4[1] == color.red
bearTrendMagic = swap4 == color.red and swap4[1] == color.lime
//********** Indicator: Support/Resistance based on COG Fib by Lazy Bear ****************
lengthFibCOG = input(20, "COG (Center of Gravity) fibs:: Period")
srcFibCOG = input(close, title= "COG (Center of Gravity) fibs:: :: Source")
calc_wima(srcFibCOG, length) =>
MA_s = 0.0
MA_s:=(srcFibCOG + nz(MA_s[1] * (length-1)))/length
MA_s
calc_ma(s, l) => sma(s,l)
medianCOG=input(0, title= "COG (Center of Gravity) fibs:: :: Median")
th=linreg(high, lengthFibCOG, medianCOG)
tl=linreg(low, lengthFibCOG, medianCOG)
tr_c=th-tl
tra= calc_wima(tr_c,lengthFibCOG)
mp=calc_ma( srcFibCOG, lengthFibCOG)
ub_4p2360 = mp + ( 4.2360 * tra)
ub_3p6180=mp + ( 3.6180 * tra)
ub_2p6180=mp + ( 2.6180 * tra)
ub_1p6180=mp + ( 1.6180 * tra)
ub_0p618=mp + ( 0.618 * tra)
lb_1p6180=mp - ( 1.6180 * tra)
lb_2p6180=mp - ( 2.6180 * tra)
lb_3p6180=mp - ( 3.6180 * tra)
lb_4p2360=mp - ( 4.2360 * tra)
lb_0p618=mp - ( 0.618 * tra)
plot(mp, title="Middlepoint", color=color.maroon, transp=iff(showFibCOG, 0, 100), linewidth=4)
plot(lb_0p618,title="S1", color=color.black, transp=iff(showFibCOG, 0, 100), linewidth=3)
plot(ub_0p618,title="R1", color=color.black, transp=iff(showFibCOG, 0, 100), linewidth=3)
plot(ub_1p6180,title="R2", color=color.lime, transp=iff(showFibCOG, 0, 100), linewidth=2)
plot(lb_1p6180,title="S2", color=color.lime, transp=iff(showFibCOG, 0, 100), linewidth=3)
plot(ub_2p6180,title="R3", color=color.red, transp=iff(showFibCOG, 0, 100), linewidth=1)
plot(lb_2p6180,title="S3", color=color.red, transp=iff(showFibCOG, 0, 100), linewidth=1)
plot(ub_3p6180,title="R4", color=color.purple, transp=iff(showFibCOG, 0, 100), linewidth=1)
plot(lb_3p6180,title="S4", color=color.purple, transp=iff(showFibCOG, 0, 100), linewidth=1)
plot(ub_4p2360,title="R5", color=color.blue, transp=iff(showFibCOG, 0, 100), linewidth=1)
plot(lb_4p2360,title="S5", color=color.blue, transp=iff(showFibCOG, 0, 100), linewidth=1)
// ************ Indicator: Custom COG channel by Lazy Bear **************** //
srcCOG = input(close, title= "COG (Center of Gravity) channel :: Source")
lengthCOG = input (34, title= "COG (Center of Gravity) channel :: Length")
median=input(0, title = "COG (Center of Gravity) channel :: median")
multCOG= input(2.5, title = "COG (Center of Gravity) channel :: mult")
offset = input(20, title="COG (Center of Gravity) channel :: offset")
tr_custom() =>
x1=high-low
x2=abs(high-close[1])
x3=abs(low-close[1])
max(x1, max(x2,x3))
atr_custom(x,y) =>
sma(x,y)
dev = (multCOG * stdev(srcCOG, lengthCOG))
basis=linreg(srcCOG, lengthCOG, median)
ul = (basis + dev)
ll = (basis - dev)
tr_v = tr_custom()
acustom=(2*atr_custom(tr_v, lengthCOG))
uls=basis+acustom
lls=basis-acustom
cRFT = cogRegionFillTransp ? 0 : 100
// Plot STDEV channel
plot(basis, linewidth=2, color=color.navy, title="COG Median STDEV", transp=cRFT)
lb=plot(ul, color=color.red, linewidth=2, title="COG BB+", style=plot.style_stepline, transp=cRFT)
tb=plot(ll, color=color.green, linewidth=2, title="COG BB-", style=plot.style_stepline, transp=cRFT)
// Plot ATR channel
plot(basis, linewidth=2, color=color.navy, linewidth=2, title="COG Median ATR ", transp=cRFT)
ls=plot(uls, color=color.red, linewidth=2, title="COG Starc+ ATR", style=plot.style_circles, transp=cRFT)
ts=plot(lls, color=color.green, linewidth=2, title="COG Star- ATR", style=plot.style_circles, transp=cRFT)
// Mark SQZ
plot_offs_high=0.002
plot_offs_low=0.002
sqz_f=(uls>ul) and (lls<ll)
b_color=sqz_f ? colorBlack : na
plot(sqz_f ? lls - (lls * plot_offs_low) : na, color=b_color, style=plot.style_cross, linewidth=3, title="COG SQZ", transp=0)
plot(sqz_f ? uls + (uls * plot_offs_high) : na, color=b_color, style=plot.style_cross, linewidth=3, title="COG SQZ", transp=0)
// ****************************************All the plots and coloring of bars***************************************************************
// Trend Magic
plotchar(tm and bullTrendMagic, title="TM", char=upSign, location=location.belowbar, color=colorBuy, transp=0, text="TM", textcolor=colorBuy, size=size.auto)
plotchar(tm and bearTrendMagic, title="TM", char=downSign, location=location.abovebar, color=colorSell, transp=0, text="TM", textcolor=colorSell, size=size.auto)
// WaveTrend Oscillator
plotshape(wtoLB and bullishWTI, color=colorBuy, style=shape.labelup, textcolor=#000000, text="WTI", location=location.belowbar, transp=0)
plotshape(wtoLB and bearishWTI, color=colorSell, style=shape.labeldown, textcolor=#ffffff, text="WTI", location=location.abovebar, transp=0)
// VFI
plotshape(vfiLB and bullishVFI, color=colorBuy, style=shape.labelup, textcolor=#000000, text="VFI", location=location.belowbar, transp=0)
plotshape(vfiLB and bearishVFI, color=colorSell, style=shape.labeldown, textcolor=#ffffff, text="VFI", location=location.abovebar, transp=0)
// PSAR
plotshape(inputIndividualSiganlPlot and sp and bullishPSAR, color=colorBuy, style=shape.labelup, textcolor=#000000, text="Sar", location=location.belowbar, transp=0)
plotshape(inputIndividualSiganlPlot and sp and bearishPSAR, color=colorSell, style=shape.labeldown, textcolor=#ffffff, text="Sar", location=location.abovebar, transp=0)
// Leledec
plotshape(inputIndividualSiganlPlot and sL and leledecMajorBearish, color=colorSell, style=shape.labeldown, textcolor=#ffffff, text="Leledec", location=location.abovebar, transp=0)
plotshape(inputIndividualSiganlPlot and sL and leledecMajorBullish, color=colorBuy, style=shape.labelup, textcolor=#000000, text="Leledec", location=location.belowbar, transp=0)
plotshape(min ? (minor==1?low:na) : na, style=shape.diamond, text="Leledec", size=size.tiny, location=location.belowbar, title="Leledec :: Weak", color=colorLime)
plotshape(min ? (minor==-1?high:na) : na, style=shape.diamond, text="Leledec", size=size.tiny, location=location.abovebar, title="Leleddec :: Weak", color=colorSell)
// Ichimoku
plot(tenkan, color=iff(sCloud, colorTenkanViolet, na), title="Tenkan", linewidth=2, transp=0)
plot(kijun, color=iff(sCloud, colorKijun, na), title="Kijun", linewidth=2, transp=0)
ichimokuSrc=input(close, "Ichimoku:: Source")
plot(ichimokuSrc, offset = -displacement, color=iff(sCloud, colorLime, na), title="Chikou", linewidth=1)
p1 = plot(senkouA, offset=displacement, color=iff(sCloud, color.lime, na), title="Senkou A", linewidth=1, transp=0)
p2 = plot(senkouB, offset=displacement, color=iff(sCloud, colorSell, na), title="Senkou B", linewidth=1, transp=0)
fill(p1, p2, color = senkouA > senkouB ? iff(sCloud, #1eb600, na) : iff(sCloud, colorSell, na), title="Ichimoku :: Kumo")
plotshape(inputIndividualSiganlPlot and strongBearishSignal, color=colorSell, style=shape.labelup, textcolor=#000000, text="Ichimoku", location=location.abovebar, transp=0)
plotshape(inputIndividualSiganlPlot and strongBullishSignal, color=colorBuy, style=shape.labeldown, textcolor=#ffffff, text="Ichimoku", location=location.belowbar, transp=0)
plotshape(inputNeutralMinorSignals and neutralBullishSignal, style=shape.flag, text="Ichimoku", size=size.small, location=location.belowbar, title="Ichimoku :: Neutral Bullish", color=colorLime)
plotshape(inputNeutralMinorSignals and weakBullishSignal, style=shape.diamond, text="Ichimoku", size=size.tiny, location=location.belowbar, title="Ichimoku :: Weak Bullish", color=colorLime)
plotshape(inputNeutralMinorSignals and neutralBearishSignal, style=shape.flag, text="Ichimoku", size=size.small, location=location.abovebar, title="Ichimoku :: Neutral Bearish", color=colorMaroon)
plotshape(inputNeutralMinorSignals and weakBearishSignal, style=shape.diamond, text="Ichimoku", size=size.tiny, location=location.abovebar, title="Ichimoku :: Weak Bearish", color=colorMaroon)
// AMA
plotshape(inputIndividualSiganlPlot and inputAma and amaLongConditionEntry, color=colorBuy, style=shape.labelup, textcolor=#000000, text="AMA", location=location.belowbar, transp=0)
plotshape(inputIndividualSiganlPlot and inputAma and amaShortConditionEntry, color=colorSell, style=shape.labeldown, textcolor=#ffffff, text="AMA", location=location.abovebar, transp=0)
// RMO
plotshape(inputIndividualSiganlPlot and sRMO and rahulMohindarOscilllatorLongEntry, color=colorBuy, style=shape.labelup, textcolor=#000000, text="RMO", location=location.belowbar, transp=0)
plotshape(inputIndividualSiganlPlot and sRMO and rahulMohindarOscilllatorShortEntry, color=colorSell, style=shape.labeldown, textcolor=#ffffff, text="RMO", location=location.abovebar, transp=0)
// TD
plot(sTD and SR?(TDbuyh ? TDbuyl: na):na,style=plot.style_circles, linewidth=1, color=color.red)
plot(sTD and SR?(TDselll ? TDsellh : na):na,style=plot.style_circles, linewidth=1, color=color.lime)
barColour = sell? tdSell : buy? tdBuy : sellovershoot? tdSellOvershoot : sellovershoot1? tdSellOvershoot1 : sellovershoot2?tdSellOverShoot2 : sellovershoot3? tdSellOverShoot3 : buyovershoot? tdBuyOverShoot : buyovershoot1? tdBuyOvershoot1 : buyovershoot2? tdBuyOverShoot2 : buyovershoot3? tdBuyOvershoot3 : na
barcolor(color=barColour, title ="TD Sequential :: Bar Colour")
// ****************************************BUY/SELL Signal ***************************************************************
bull = leledecMajorBullish or strongBullishSignal or rahulMohindarOscilllatorLongEntry or bullishVFI or amaLongConditionEntry or bullTrendMagic or bullishWTI
bear = leledecMajorBearish or bearishPSAR or strongBearishSignal or rahulMohindarOscilllatorShortEntry or bearishVFI or amaShortConditionEntry or bearTrendMagic or bearishWTI
if bull
persistent_bull := 1
persistent_bear := 0
if bear
persistent_bull := 0
persistent_bear := 1
plotshape(buySellSignal and bull and (persistent_bull[1] != 1 or bear), style=shape.labelup, location=location.belowbar, color=colorBuy, text="Buy", textcolor=#000000, transp=0)
plotshape(buySellSignal and bear and (persistent_bear[1] != 1 or bull), style=shape.labeldown, color=colorSell, text="Sell", location=location.abovebar, textcolor =#ffffff, transp=0)
//=== EXECUTION for EMA/Price Cross ===
strategy.entry("LONG", strategy.long, when=testPeriod() and buySellSignal and bull and (persistent_bull[1] != 1 or bear))
// strategy.close("LONG", when=testPeriod() and trailing_stopbuy_triggered)
strategy.entry("SHORT", strategy.short, when=testPeriod() and buySellSignal and bear and (persistent_bear[1] != 1 or bull))
//strategy.close("SHORT", when=testPeriod() and trailing_stopsell_triggered)
plot(strategy.equity)
// ****************************************Alerts***************************************************************
// For global buy/sell
alertcondition(bull and persistent_bull[1] != 1, title='Buy', message='Buy')
alertcondition(bear and persistent_bear[1] != 1, title='Short', message='Short')
// For WaveTrend Oscillator
alertcondition(bullishWTI, title='Bullish - WaveTrend Oscillator', message='Bullish - WaveTrend Oscillator')
alertcondition(bearishWTI, title='Bearish - WaveTrend Oscillator', message='Bearish - WaveTrend Oscillator')
// For Volume Flow Indicator
alertcondition(bullishVFI, title='Bullish - Volume Flow Indicator', message='Bullish - Volume Flow Indicator')
alertcondition(bearishVFI, title='Bearish - Volume Flow Indicator', message='Bearish - Volume Flow Indicator')
// For major Leledc Exhausion
alertcondition(leledecMajorBullish, title='Bullish - Leledec Exhausion', message='Bullish - Leledec Exhausion')
alertcondition(leledecMajorBearish, title='Bearish - Leledec Exhausion', message='Bearish - Leledec Exhausion')
// For Kaufman AMA wave
alertcondition(amaLongConditionEntry, title='Bullish - Kaufman AMA wave', message='Bullish - AMA :: Kaufman AMA wave')
alertcondition(amaShortConditionEntry, title='Bearish - Kaufman AMA wave', message='Bearish - AMA :: Kaufman AMA wave')
// For Rahul Mohindar Oscillator
alertcondition(rahulMohindarOscilllatorLongEntry, title='Bullish - Rahul Mohindar Oscillator', message='Bullish - RMO :: Rahul Mohindar Oscillator')
alertcondition(rahulMohindarOscilllatorShortEntry, title='Bearish - Rahul Mohindar Oscillator', message='Bearish - RMO :: Rahul Mohindar Oscillator')
// For Parabolic Sar
alertcondition(bullishPSAR, title='Bullish - Sar :: Parabolic SAR', message='Bullish - Sar :: Parabolic SAR')
alertcondition(bearishPSAR, title='Bearish - Sar :: Parabolic SAR', message='Bearish - Sar :: Parabolic SAR')
// For Ichimoku
alertcondition(strongBullishSignal, title='Bullish - Ichimoku', message='Bullish Ichimoku- Ichimoku')
alertcondition(strongBearishSignal, title='Bearish - Ichimoku', message='Bearish Ichimoku - Ichimoku')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment