T Step LSMA
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 | 100 | length |
| v_input_2 | 0.5 | sc |
| v_input_3 | false | No Smoothing |
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=4
study("T-Step LSMA",overlay=true)
length = input(100),sc = input(.5),ns = input(false,"No Smoothing")
//----
b = 0.,ls = 0.
src = sc*close+(1-sc)*nz(ls[1],close)
//----
er = 1 - abs(change(src,length))/sum(abs(change(src)),length)
n = cum(1)-1
a = cum(abs(src - nz(b[1],src)))/n*(1+er)
b := src > nz(b[1],src) + a ? src : src < nz(b[1],src) - a ? src : nz(b[1],src)
//----
alpha = fixnan(correlation(src,b,length) * (stdev(src,length)/stdev(b,length)))
beta = sma(src,length) - alpha*sma(b,length)
ls := alpha*b+beta
//----
osc = 0
osc := b > b[1] ? 1 : b < b[1] ? 0 : osc[1]
css = osc == 1 ? color.blue :#e65100
plot(ns ? b : fixnan(ls),color=css,linewidth=3,transp=0)
alertcondition(change(osc)>0,title="Up",message="Up-trending Market Estimated")
alertcondition(change(osc)<0,title="Dn",message="Down-trending Market Estimated")
buySignal = change(osc)>0
sellSignal= change(osc)<0
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/T-Step-LSMA.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
- Gann High LowPine Script · Other · 4h
- MACD StrategyPine Script · Other
- Monthly Performance PnL Calendar StrategyPine Script · Other · 1d
- QQE MOD SSL Hybrid Waddah Attar ExplosionPine Script · Other · 4h