herijuana
herijuana

Reputation: 21

Ichimoku Cloud Alert Setup (PineScript)

I'm setting up an alarm system on ichimoku. I need four parameters for it to alarm but I was able to run three parameters.

when three parameters are captured, it creates the green/red circle symbol for the Long/Short position at the bottom

enter image description here

but i have to manually check the green line for incoming signals like this.

this occurs a few candles after the signal arrives and you have no choice but to wait. or it will return before the conditions are met and cause it to produce a false signal.

enter image description here

I can't include the green line (chikouspan) in the signal

The green line;

Does anyone know how I can achieve this and can help?

I am sharing the codes clearly below. Anyone can use it. Have a good day..

//@version=5
indicator(title="YC Ichimoku Cloud", shorttitle="YC Ichimoku", overlay=true)

TenkanPeriods = input.int(9, minval=1, title="ICH: Tenkan-Sen Line Length")
KijunPeriods = input.int(26, minval=1, title="ICH: Kijun-Sen Line Length")
SenkouBPeriods = input.int(52, minval=1, title="ICH: SenkouSpan B Length")
displacement = input.int(26, minval=1, title="ICH: Yerdeğişim")
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
TenkanLine = donchian(TenkanPeriods)
KijunLine = donchian(KijunPeriods)
SenkouA = math.avg(TenkanLine, KijunLine)
SenkouB = donchian(SenkouBPeriods)
plot(TenkanLine, color=color.new(color.blue,20), title="ICH: Tenkan-Sen Line")
plot(KijunLine, color=color.new(#f83444,20), title="ICH: Kijun-Sen Line")
plot(close, offset = -displacement + 1, color=color.new(#48a84d, transp=30), title="ICH: ChikouSpan")
p1 = plot(SenkouA, offset = displacement - 1, color=color.new(#A5D6A7, transp=80),
     title="ICH: Senkou Span A")
p2 = plot(SenkouB, offset = displacement - 1, color=color.new(#EF9A9A, transp=80),
     title="ICH: Senkou Span B")
fill(p1, p2, color = SenkouA > SenkouB ? color.rgb(67, 160, 71, 92) : color.rgb(244, 67, 54, 92))

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

BulutuBekle = input.bool(true, title='ICH: Bulut Onayını Bekle')
LongSgn  = input.bool(true, title='ICH: Long Sinyal')
ShortSgn = input.bool(true, title='ICH: Short Sinyal')

SsHigh = math.max(SenkouA[displacement - 1], SenkouB[displacement - 1])
SsLow  = math.min(SenkouA[displacement - 1], SenkouB[displacement - 1])

TkL = TenkanLine > KijunLine
TkS = TenkanLine < KijunLine

CsL = ta.mom(close, displacement -1) > 0
CsS = ta.mom(close, displacement -1) < 0

FiyatBulutUstu = close > SsHigh 
FiyatBulutAlti = close < SsLow

AlSinyal  = TkL and CsL and FiyatBulutUstu
SatSinyal = TkS and CsS and FiyatBulutAlti

YesilBulut = SenkouA > SenkouB ? true : false

if BulutuBekle
    AlSinyal := AlSinyal and YesilBulut
    SatSinyal := SatSinyal and not YesilBulut
    SatSinyal

InLong = false
InLong := InLong[1]

InShort = false
InShort := InShort[1]

open_long = AlSinyal and not InLong
open_short = SatSinyal and InLong

if open_long
    InLong := true
    InLong
if open_short
    InLong := false
    InLong

plotchar(open_long and LongSgn, title = 'ICH: Long Sgn', char='•', color = color.new(color.lime,  transp = 30) ,location = location.bottom, size = size.tiny)
plotchar(open_short and ShortSgn, title = 'ICH: Short Sgn', char='•', color = color.new(color.red,  transp = 10) ,location = location.bottom, size = size.tiny)

Upvotes: 2

Views: 3328

Answers (1)

rumpypumpydumpy
rumpypumpydumpy

Reputation: 3823

You have to factor in the displacements. Since the chikouspan is just the current close value displaced into the past we can just use close as one side of the comparison.

So for your long condition you would use close > high[chikou displacement] in order to determine if the chikou is above the historical candle.

In order to determine if the chikou is above the cloud, you need to add the displacement values for the chikou and the cloud close > cloud[chikou displacement + cloud displacement]

Upvotes: 1

Related Questions