title: Ichimoku Cloud Alert Setup (PineScript)
body: <p>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.</p>
  <ul>
  <li>[OK] when the cloud on the right changes color,</li>
  <li>[OK] if the candle close is above the cloud,</li>
  <li>[OK] Tenkan-Kijun lines (blue, red) crossing</li>
  <li><strong>[??]</strong> <em><strong>Chikouspan (green) line closing above or below the cloud and price</strong></em></li>
  </ul>
  <p>when three parameters are captured, it creates the green/red circle symbol for the Long/Short position at the bottom</p>
  <p><a href="https://i.stack.imgur.com/UUTU3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UUTU3.png" alt="enter image description here" /></a></p>
  <p>but i have to manually check the green line for incoming signals like this.</p>
  <p>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.</p>
  <p><a href="https://i.stack.imgur.com/MMkkZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MMkkZ.png" alt="enter image description here" /></a></p>
  <p>I can't include the green line (chikouspan) in the signal</p>
  <p><strong>The green line;</strong></p>
  <ul>
  <li>For long position: should close above candles and cloud</li>
  <li>For the short position: it should close below the candles and the cloud.</li>
  </ul>
  <p>Does anyone know how I can achieve this and can help?</p>
  <p>I am sharing the codes clearly below. Anyone can use it. Have a good day..</p>
  <pre><code>//@version=5
  indicator(title=&quot;YC Ichimoku Cloud&quot;, shorttitle=&quot;YC Ichimoku&quot;, overlay=true)
  
  TenkanPeriods = input.int(9, minval=1, title=&quot;ICH: Tenkan-Sen Line Length&quot;)
  KijunPeriods = input.int(26, minval=1, title=&quot;ICH: Kijun-Sen Line Length&quot;)
  SenkouBPeriods = input.int(52, minval=1, title=&quot;ICH: SenkouSpan B Length&quot;)
  displacement = input.int(26, minval=1, title=&quot;ICH: Yerdeğişim&quot;)
  donchian(len) =&gt; 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=&quot;ICH: Tenkan-Sen Line&quot;)
  plot(KijunLine, color=color.new(#f83444,20), title=&quot;ICH: Kijun-Sen Line&quot;)
  plot(close, offset = -displacement + 1, color=color.new(#48a84d, transp=30), title=&quot;ICH: ChikouSpan&quot;)
  p1 = plot(SenkouA, offset = displacement - 1, color=color.new(#A5D6A7, transp=80),
       title=&quot;ICH: Senkou Span A&quot;)
  p2 = plot(SenkouB, offset = displacement - 1, color=color.new(#EF9A9A, transp=80),
       title=&quot;ICH: Senkou Span B&quot;)
  fill(p1, p2, color = SenkouA &gt; 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 &gt; KijunLine
  TkS = TenkanLine &lt; KijunLine
  
  CsL = ta.mom(close, displacement -1) &gt; 0
  CsS = ta.mom(close, displacement -1) &lt; 0
  
  FiyatBulutUstu = close &gt; SsHigh 
  FiyatBulutAlti = close &lt; SsLow
  
  AlSinyal  = TkL and CsL and FiyatBulutUstu
  SatSinyal = TkS and CsS and FiyatBulutAlti
  
  YesilBulut = SenkouA &gt; 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)
  </code></pre>