Strategy vault / Tools & templates
Trade05 K Line Support and Resistance ATR Take Profit
In order to give back to the FMZ platform and community, share strategies & codes & ideas & templates Introduction: Volume-price factor combination ✱Contact Information (Welcome to Discuss and Learn Together))…
In order to give back to the FMZ platform and community, share strategies & codes & ideas & templates
Introduction: Volume-price factor combination
✱Contact Information (Welcome to Discuss and Learn Together)) WECHAT: haiyanyydss TEL: https://t.me/JadeRabbitcm ✱Fully automatic CTA & HFT trading system @2018 - 2023
Parameters
| Name | Default | What it controls |
|---|---|---|
| LENTH | 250 | LENTH |
| percent | 5 | percent |
Source MyLanguage
(*backtest
start: 2018-01-01 00:00:00
end: 2021-06-30 23:59:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_OKCoin","currency":"BTC_USD","stocks":10}]
args: [["percent",5],["ContractType","quarter",126961]]
*)
ATRS:=50;
//Trading volume
//LOTS:=MAX(1,INTPART(percent/100*MONEY/(C*MARGIN*UNIT)));//Gold principal
LOTS:=MAX(1,INTPART(percent/100*MONEY*C/(MARGIN*UNIT)));//Coin principal
// Calculate CurrentKWeighted average of lines, resistance lines and support lines
AVGP:=(HIGH + LOW + (CLOSE * 2)) / 4;
RS^^HHV((AVGP * 2) - LOW,LENTH);
ST^^LLV((AVGP * 2) - HIGH,LENTH);
// CalculationATR
TR:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATRVAL:=MA(TR,LENTH);
// Open Position
IF BKVOL<=1 AND HIGH >= REF(RS,1) AND VOL > 0 THEN BEGIN
1,BPK(LOTS);
END
IF SKVOL<=1 AND LOW <= REF(ST,1) AND VOL > 0 THEN BEGIN
1,SPK(LOTS);
END
// Determine entry based on openingBARofATRCalculate take-profit price
IF BKVOL>0 AND BARSBK>0 THEN BEGIN
MYEXITPRICE:=BKPRICE + ATRVAL * ATRS;
END
IF SKVOL>0 AND BARSSK>0 THEN BEGIN
MYEXITPRICE:=SKPRICE - ATRVAL * ATRS;
END
// Close Position
IF BKVOL>0 AND BARSBK>0 AND VOL>0 THEN BEGIN
// Take Profit Exit
IF HIGH >= MYEXITPRICE THEN BEGIN
1,SP(LOTS);
END
END
IF SKVOL>0 AND BARSSK>0 AND VOL>0 THEN BEGIN
// Take Profit Exit
IF LOW <= MYEXITPRICE THEN BEGIN
1,BP(LOTS);
END
ENDPublished by 作手君TradeMan on the FMZ strategy square · last modified 2023-09-04. 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 tested, production-ready module from strategies/Trade05-K-Line-Support-and-Resistance-ATR-Take-Profit.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
- Trade04 Double Moving Average ATR Channel High and Low PointsMyLanguage · Tools & templates
- Digital Currency Futures Multi Variety ATR Strategy TeachingJavaScript · Tools & templates · 1d
- Indicator Library Python VersionPython · Tools & templates
- ML Alerts TemplatePine Script · Tools & templates · 2h
- Monthly Returns Strategy with BenchmarkPine Script · Tools & templates · 2h
- Platform Price Indicator Monitoring 11JavaScript · Tools & templates