Gann High Low
Pine Script strategy by Zer3192.
The original spec has no written description. Read the source below.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 13 | HIGH Period |
| v_input_2 | 21 | LOW Period |
Source Pine Script
/*backtest
start: 2021-05-08 00:00:00
end: 2022-05-07 23:59:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
indicator('Gann High Low', overlay=true)
HPeriod = input(13, 'HIGH Period')
LPeriod = input(21, 'LOW Period')
iff_1 = close < nz(ta.sma(low, LPeriod))[1] ? -1 : 0
HLd = close > nz(ta.sma(high, HPeriod))[1] ? 1 : iff_1
HLv = ta.valuewhen(HLd != 0, HLd, 0)
sma_1 = ta.sma(high, HPeriod)
sma_2 = ta.sma(low, LPeriod)
HiLo = HLv == -1 ? sma_1 : sma_2
HLcolor = HLv == -1 ? color.maroon : color.blue
plot(HiLo, linewidth=2, color=HLcolor)
alertcondition(ta.cross(close, HiLo), title='Price Cross Alert', message='Price - HiLo Crossing!')
alertcondition(ta.crossover(close, HiLo), title='PRICE CrossOver Alarm', message='LAST PRICE is ABOVE HiLo')
alertcondition(ta.crossunder(close, HiLo), title='PRICE CrossUnder Alarm', message='LAST PRICE is BELOW HiLo!')
buySignal=ta.crossover(close, HiLo)
sellSignal=ta.crossunder(close, HiLo)
if buySignal
strategy.entry("buy", strategy.long)
else if sellSignal
strategy.entry("sell", strategy.short) Published by Zer3192 on the FMZ strategy square · last modified 2022-06-25. 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/Gann-High-Low.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
- Angle Attack Follow Line IndicatorPine Script · Other · 15m
- Customizable Backtest Start Time StrategyPine Script · Other · 2d
- MACD StrategyPine Script · Other
- Monthly Performance PnL Calendar StrategyPine Script · Other · 1d
- QQE MOD SSL Hybrid Waddah Attar ExplosionPine Script · Other · 4h
- RedK Volume Accelerated Directional Energy RatioPine Script · Other · 1h