Chasing Highs and Selling Lows
Python strategy by ChildeTang.
PythonOther
The original spec has no written description. Read the source below.
Parameters
| Name | Default | What it controls |
|---|---|---|
| PERIOD | 60 | timeframe |
| LENGTH | 1440 | Length |
Source Python
list=[]
def doTicker():
#Log(exchange.GetAccount())
#Log(list)
ticker = exchange.GetTicker()
last = ticker.Last
if len(list) < LENGTH:
list.append(last)
else:
pMax = max(list)
pMin = min(list)
if last > pMax:
Log("buy " + str(exchange.GetAccount()))
account = exchange.GetAccount()
if account.Balance > last:
#id = exchange.Buy(last, 1)
id = exchange.Buy(-1, 1)
Log("buy id --> " + str(id))
elif last < pMin:
Log("sell " + str(exchange.GetAccount()))
account = exchange.GetAccount()
if account.Stocks > 0:
#id = exchange.Sell(last, 1)
id = exchange.Sell(-1, 1)
Log("sell id --> " + str(id))
list.pop(0)
list.append(last)
def main():
while(true):
doTicker() #Execution Strategy
Sleep(PERIOD * 1000) #Rest for a while
Published by ChildeTang on the FMZ strategy square · last modified 2018-06-06. 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/Chasing-Highs-and-Selling-Lows.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
- Dynamic Balancing Strategy Python VersionPython · Other
- Exchange Wash Trading and Mutual BrushingPython · Other
- Leek Protection Program Tang Anqi Channel Position Balancing StrategyPython · Other
- Paul The Gambler Lévy Gold EditionPython · Other
- Porting OKCoin Leek Harvester Multi Variety Version Annotated Python VersionPython · Other
- Python Example Using asyncio http to Obtain Market DataPython · Other