0bps

Strategy vault / Tools & templates

Share Notify When the ADX Value Reaches the Conditions

In order to give back to the FMZ platform and community, share strategies & codes & ideas & templates Introduction: Call the ADX indicator and send FMZ communication notifications when certain conditions are met Can…

Author
作手君TradeMan
Complexity
Starter · 60 lines
Parameters
4
Backtest bar
1h · intraday
Tested on
ETH/USD · futures

In order to give back to the FMZ platform and community, share strategies & codes & ideas & templates

Introduction: Call the ADX indicator and send FMZ communication notifications when certain conditions are met Can sequentially poll multiple trading pairs

Welcome to cooperate and communicate, learn and progress together~ v:haiyanyydss

Parameters

NameDefaultWhat it controls
P_interval_time1000Polling interval (milliseconds)
P_contractquartercontract
P_adx_len50ADXParameters
P_adx_val10WeChat notification trigger value (ADX greater than this value))

Source JavaScript

/*backtest
start: 2020-01-01 00:00:00
end: 2021-02-02 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_OKCoin","currency":"ETH_USD"},{"eid":"Futures_OKCoin","currency":"BTC_USD"}]
args: [["P_contract","quarter|quarter"],["P_contract_value","10|100"]]
*/

/*
In order to give back to the FMZ platform and community, share strategies & codes & ideas & templates

Introduction:
Call the ADX indicator and send FMZ communication notifications when certain conditions are met
Can sequentially poll multiple trading pairs

Welcome to cooperate and communicate, learn and progress together~
v:haiyanyydss
*/

function getPara(val, i){
    val = ""+val;
    var ret = val.split("|").length>i?val.split("|")[i]:val.split("|")[val.split("|").length-1];
    return ret.trim();
}

function Trade(e){
    this.e = e;
    this.last_alert_time = 0;
    this.ontick = function(){
        var records = _C(this.e.GetRecords);
        var last_record = records[records.length-1];
        var adx = talib.ADX(records, this.adx_len);
        if(this.last_alert_time < last_record.Time && adx[adx.length-1] > this.adx_val){
            this.last_alert_time = last_record.Time;
            Log(this.e.GetCurrency(), this.contract, "adxValue exceeds"+this.adx_val , new Date(), "@");
        }
    }
}

function main() {
    LogReset();
    var tradeArr = [];
    for(var i in exchanges){
        var trade = new Trade(exchanges[i]);  
        trade.adx_len = 1*getPara(P_adx_len, i);
        trade.adx_val = 1*getPara(P_adx_val, i);
        trade.contract = getPara(P_contract, i);
        trade.e.SetContractType(trade.contract);
        tradeArr.push(trade)
    }
    
    while (true) {
        for(var i in tradeArr){
            Sleep(P_interval_time);
            tradeArr[i].ontick();
        }
    }
}

Published by 作手君TradeMan on the FMZ strategy square · last modified 2023-02-09. 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.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a tested, production-ready module from strategies/Share-Notify-When-the-ADX-Value-Reaches-the-Conditions.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. 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

esc

Try , , or .

↑↓ move↵ open