# Stochastic cross in extremes

> Stochastic cross in extremes is an alert that checks every 1 hour, can fire every time its condition is met, waits 3 bars between alerts and shows whe

Source: https://algobarsx.com/docs/ex-26-stochastic-cross-alert/

```algobarsx
alert "Stochastic cross in extremes"
    check: every 1h
    repeat: every time
    cooldown: 3 bars
    show_on_chart: true

k_line = stoch().k
d_line = stoch().d

when crosses_above(k_line, d_line) and k_line < 20:
    notify "Stochastic bullish cross at {k_line:0} on {market.symbol}"

when crosses_below(k_line, d_line) and k_line > 80:
    notify "Stochastic bearish cross at {k_line:0} on {market.symbol}"
```
What this script says

Stochastic cross in extremes is an alert that checks every 1 hour, can fire every time its condition is met, waits 3 bars between alerts and shows where it fires on the chart.

It calculates `k_line` as the k of the stochastic and `d_line` as the d of the stochastic.

When `k_line` crosses above `d_line` and `k_line` is below 20, it sends the notification "Stochastic bullish cross at {k_line:0} on {market.symbol}".

When `k_line` crosses below `d_line` and `k_line` is above 80, it sends the notification "Stochastic bearish cross at {k_line:0} on {market.symbol}".
