The resource loading... loading...

Sharing of Aries Aries-ADX values to be notified when conditions are met

Author: Written by TradeMan, Date: 2023-01-16 09:32:01
Tags:

Share strategies & codes & ideas & templates to give back to the FMZ platform and community

This is my life story. Call the ADX indicator to provide FMZ communication notification under certain conditions You can order multiple transaction pairs

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


/*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"]]
*/

/*
为回馈FMZ平台与社区,进行策略&代码&思路&模板的分享

简介:
调用ADX指标,达到一定条件进行FMZ通讯通知
可以顺序轮询多交易对

欢迎合作交流,共同学习进步~
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, "adx值超过"+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();
        }
    }
}


More

Light cloudsThis WeChat notification is not working now, is it?

Written by TradeManOh, but you can email me.