Playing the cross
For this script i used Kijun-sen from Ichimoku Cloud and Moving Average. Kijun-sen is the base line of the Ichimoku Cloud or the midpoint price of the last 26 period. Moving Average is a constantly updated average…
For this script i used Kijun-sen from Ichimoku Cloud and Moving Average.
Kijun-sen is the base line of the Ichimoku Cloud or the midpoint price of the last 26 period. Moving Average is a constantly updated average price of a given range. In this script i used the standard Kijun-sen settings and the Moving Average, 55 length.
You will get an red or green signal when the lines cross each other. Try the indicator yourself to see, why it could be useful.
A special thanks to @norok and @happyCloud1537 for teaching me! This will lead to more scripts from my side, since i really like to code and trade.
backtest

Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_int_1 | 26 | Kijun-Sen length |
| v_input_int_2 | 55 | EMA length |
| v_input_1_close | 0 | Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4 |
Source Pine Script
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Glenn234
//@version=5
indicator("Playing the cross", shorttitle="PtC", overlay=true)
// Ichimoku code - Kijun-Sen
basePeriods = input.int(26, minval=1, title="Kijun-Sen length")
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
KijunSen = donchian(basePeriods)
plot(KijunSen, color=color.green, title="Kijun-Sen")
// Moving Average Exponential code
len = input.int(55, minval=1, title="EMA length")
src = input(close, title="Source")
MovingAverage = ta.ema(src, len)
plot(MovingAverage, title="EMA", color=color.red)
// Cross code
Up = MovingAverage > KijunSen and MovingAverage[1] < KijunSen[1]
Down = MovingAverage < KijunSen and MovingAverage[1] > KijunSen[1]
bgcolor(Up ? color.new(color.green, 60) : na, title="Up Cross")
bgcolor(Down ? color.new(color.red, 60) : na, title="Down Cross")
if Down
strategy.entry("Enter Long", strategy.long)
else if Up
strategy.entry("Enter Short", strategy.short)
Published by ChaoZhang on the FMZ strategy square · last modified 2022-05-11. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Playing-the-cross.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- EMA Cloud Intraday StrategyPine Script · Other · 1d
- Customizable Ichimoku Cloud Trading StrategyPine Script · Other · 2h
- Ichimoku Oscillator ChartPrimePine Script · Other
- Equilibrium At a GlanceJavaScript · Other
- Angle Attack Follow Line IndicatorPine Script · Other · 15m
- Bully SignalsPine Script · Other · 1h