U Based Grid Amplitude Filtering
Find the coin with the highest average amplitude for grid trading
JavaScriptGrid
Find the coin with the highest average amplitude for grid trading
Parameters
| Name | Default | What it controls |
|---|---|---|
| Day | 30 | Day |
Source JavaScript
/* jshint esversion: 6 */
// var Day = 30; //Number of Days Tracked
var Quote = "USDT"; //Denominated Currency,BUSDorUSDT
function GetAmplitude(klineList) {
let ret = {
ampl: 0,
change: 0,
maxAmpl: 0,
maxAmplTime: 0,
minAmpl: 100,
minAmplTime: 0,
maxChange: 0,
minChange: 0,
avgAmpl: 0,
avgChange: 0,
day: 0,
};
for (let i = 0; i < klineList.length; i++) {
const item = klineList[i];
amp = (parseFloat(item.High - item.Low) / parseFloat(item.Open)) * 100.0; //Amplitude
change = (parseFloat(item.Close - item.Open) / parseFloat(item.Open)) * 100.0; //Increase
if (amp > ret.maxAmpl) {
ret.maxAmpl = amp;
ret.maxAmplTime = item.Time;
}
if (amp < ret.minAmpl) {
ret.minAmpl = amp;
ret.minAmplTime = item.Time;
}
if (change > ret.maxChange) {
ret.maxChange = change;
}
if (change < ret.minChange) {
ret.minChange = change;
}
ret.ampl += amp;
ret.change += change;
ret.day = i + 1;
}
ret.avgAmpl = ret.ampl / klineList.length;
ret.avgChange = ret.change / klineList.length;
return ret;
}
function main() {
exchange.SetContractType("swap");
exchange.SetMaxBarLen(1000);
let table = {
type: "table",
title: "Volatility Information",
cols: ["Currency", "Number of days", "Average amplitude %", "Maximum amplitude %", "Maximum amplitude time", "Minimum amplitude", "Minimum amplitude time", "Total amplitude %", "Average increase or decrease %", "Maximum increase %", "Maximum decrease %", "Increase or decrease%"],
rows: [],
};
let info = exchange.IO("api", "GET", "/fapi/v1/exchangeInfo");
for (let i = 0; i < info.symbols.length; i++) {
const ele = info.symbols[i];
if (ele.contractType == "PERPETUAL" && ele.status == "TRADING" && ele.quoteAsset == Quote) {
let symbol = ele.baseAsset + "_" + Quote;
exchange.SetCurrency(symbol);
let records = exchange.GetRecords(PERIOD_D1);
if (records.length < Day) {
Log(ele.baseAsset + Quote+".P", records.length);
continue; //Only count currencies with enough days
}
let ampls = GetAmplitude(records.splice(-1 * (Day + 1), Day));
//
table.rows.push([
ele.baseAsset + Quote+".P", //Currency
ampls.day, //Days
_N(ampls.avgAmpl, 2), //Average Volatility
_N(ampls.maxAmpl, 2), //Maximum Volatility
_D(ampls.maxAmplTime), //Maximum amplitude time
_N(ampls.minAmpl, 2), //Minimum Volatility
_D(ampls.minAmplTime), //Minimum amplitude time
_N(ampls.ampl, 2), //Total amplitude
_N(ampls.avgChange, 2), //Average Increase
_N(ampls.maxChange, 2), //Maximum Increase
_N(ampls.minChange, 2), //Minimum Increase
_N(ampls.change, 2), //Total increase
]);
}
}
LogStatus("`" + JSON.stringify(table) + "`\n");
}
Published by ChaoZhang on the FMZ strategy square · last modified 2024-03-10. 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 grid bot with inventory caps and order deduplication from strategies/U-Based-Grid-Amplitude-Filtering.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
- Bybit Inverse Contract Dynamic Grid Special GridJavaScript · Grid
- Grid Pending Order Plus Martin Multiple IncreaseJavaScript · Grid · 1d
- Single Commodity Small Shop Strategy V20 Annualized 130JavaScript · Grid · 1d
- Two Way Contract Grid Trading V102JavaScript · Grid · 1m
- Mesh Deformation Strategy for Single Sided MeshJavaScript · Grid
- Mesh Deformation Strategy for Single Sided Mesh NotesJavaScript · Grid · 1d