Strategy vault / Tools & templates
Python KLineChart
The platform (Javascript/Python language) activates KLineChart support, supports all drawing functions of Pine language (the parameters remain consistent), and supports customized buying and selling signals. The…
The platform (Javascript/Python language) activates KLineChart support, supports all drawing functions of Pine language (the parameters remain consistent), and supports customized buying and selling signals. The following is a demonstration example
Reference Document https://www.fmz.com/api#klinechart

Source Python
'''backtest
start: 2022-03-30 09:00:00
end: 2022-06-30 15:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
'''
import sys
def main():
Log(sys.version)
c = KLineChart()
c.reset(0)
bars = exchange.GetRecords()
for bar in bars:
c.begin(bar)
c.barcolor('rgba(255, 0, 0, 0.2)' if bar.Close > bar.Open else 'rgba(0, 0, 0, 0.2)')
if bar.Close > bar.Open:
c.bgcolor('rgba(0, 255, 0, 0.5)')
h = c.plot(bar.High, 'high')
l = c.plot(bar.Low, 'low')
c.fill(h, l, 'rgba(255, 0, 0, 1)' if bar.Close > bar.Open else '#000000')
c.hline(bar.High)
c.plotarrow(bar.Close - bar.Open)
c.plotshape(bar.Low, style = 'diamond')
c.plotchar(bar.Close, char = 'X')
c.plotcandle(bar.Open*0.9, bar.High*0.9, bar.Low*0.9, bar.Close*0.9)
if bar.Close > bar.Open:
c.signal("long", bar.High, 1.5, "LONG")
elif bar.Close < bar.Open:
c.signal("closelong", bar.Low, 1.5)
c.close()Published by 发明者量化 on the FMZ strategy square · last modified 2022-07-01. 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/Python-KLineChart.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
- 2 3 Python Version Drawing Class Library Compatible 2 3Python · Tools & templates
- Local StoragePython · Tools & templates
- Python Version Dual Thrust OKCoin FuturesPython · Tools & templates
- TBD Python2 3Python · Tools & templates
- FMZ Real Offer Robot Automatically Detects and Restarts Program WeChat PushPython · Tools & templates
- OkEX Websocket Realtime v3Python · Tools & templates