Tests - über die langfristigen Effekte von Martin

Schriftsteller:xxs1xxs1, Datum: 2021-09-04 01:47:51
Tags:

Ich weiß nicht, ob das nicht auch Martin ist. Ich will mehr tun. Ich will einfach einen Preis finden, um zu starten. Ein kleiner Anfangs-Rückstand ist beispielsweise ein Vorbereitungsfall von 10%. Ein großer Stand kann langsam auf 10% 20% 50% gesetzt werden. Wenn man irgendwie einen Rückgang spüren kann, ist die Wahrscheinlichkeit groß. Das ist ein sehr wichtiger Bestand. Ich möchte Sie bitten, Ihre Talente zu nutzen, und ich hoffe, dass wir mehr Vorschläge haben, um gemeinsam einen mechanischen Handel zu machen. Das Wichtigste ist, den Empfangspunkt zu berechnen.


/*backtest
start: 2021-05-1 00:00:00
end: 2021-08-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
args: [["OpType",1]]
*/

//各功能测试
exchange.SetContractType("swap") //合约设置
// exchange.SetCurrency("TRX_USDT");
//    exchange.SetMarginLevel(20) //合约倍数设置 

//exchange.IO("trade_margin")
//exchange.IO("currency", "STPT_USDT")
var account = _C(exchange.GetAccount) //帐户信息
var log_profit = 0
var log_profit_intervel = 1000 * 60 * 5
var symbol_list = [] //"1.5倍vol,kdj与ma多头"
var symbol_list1 = [] //"3倍vol,当前涨幅4%或者vol5倍"
var symbol_list2 = [] //"三连涨"
var order_list = []
var num = 0 //记录补仓数量
if (_G("symbol")) {
    symbol_list = _G("symbol")
    order_list = _G("orderlist")
    Log("上一次数据", symbol_list)
    Log("上一次数据完成数据", order_list)
}

// 撤单函数
function CancelPendingOrders() {
    Sleep(1000); // 休眠 1秒
    var ret = false;
    while (true) {
        var orders = null;
        // 持续获取未成交订单数组,如果返回异常,则继续获取
        while (!(orders = exchange.GetOrders())) {
            Sleep(1000); // 休眠 1秒
        }
        if (orders.length == 0) { // 如果订单数组为空
            return ret; // 返回撤单状态
        }
        for (var j = 0; j < orders.length; j++) { // 遍历未成交订单数组
            exchange.CancelOrder(orders[j].Id); // 依次取消未成交订单
            ret = true;
            if (j < (orders.length - 1)) {
                Sleep(1000); // 休眠 1秒
            }
        }
    }
}

function symbols() {


    log_profit_intervel = 1000 * 60 * 5


    if (Date.now() - log_profit > log_profit_intervel && !IsVirtual()) { //全部交易对 
        log_profit = Date.now()
        var symbol = JSON.parse(HttpQuery("https://www.binance.com/fapi/v1/exchangeInfo"))
        let symbol_all = []
        symbol.symbols.forEach(function(v, k, arr) {
            if (v.quoteAsset == "USDT" && v.contractType == "PERPETUAL") {
                let str = v.symbol.split("USDT", 1)
                str = str + "_USDT"
                symbol_all.push([str, v.pricePrecision, v.quantityPrecision])
            }
        })

        // exchange.SetCurrency("TRX_USDT");                        //交易对设置
        //exchange.SetPrecision(priceScale, amountScale)            //精度设置


        for (let i = 0; i < symbol_all.length; i++) {

            if (symbol_list.length > 0) {

                let flag = false
                symbol_list.forEach(function(v, k, arr) {
                    //   Log(v[0],symbol_all[i][0])
                    if (v[0] == symbol_all[i][0]) {
                        flag = true;
                    }
                })
                if (flag) {
                    continue;
                }
            }



            exchange.SetCurrency(symbol_all[i][0])
            //  exchange.SetCurrency("DOGE_USDT")
            exchange.SetPrecision(symbol_all[i][1], symbol_all[i][2])
            let records = exchange.GetRecords(60 * 60 * 1)
            let kdj = TA.KDJ(records, 9, 3, 3)
            let ma7 = TA.EMA(records, 7)
            let ma25 = TA.EMA(records, 25)

            //      let records1 = exchange.GetRecords(60 * 15)
            //      let kdj1 = TA.KDJ(records1, 9, 3, 3)

            let len = records.length - 1
            let rs = records[len]
            //      let rs1 = records[len]
            //      if ((rs.Close > rs.Open && rs.Volume > rs1.Volume * 1.5 && rs.Close / rs.Open > 1.04) || (rs.Close > rs.Open && rs.Volume > rs1.Volume * 2)) 
            //     if (rs.Close > rs.Open && _Cross(kdj[0], kdj[1]) > 0 && _Cross(kdj[0], kdj[1]) < 3 && rs.Close / rs.Low < 1.03 && _Cross(kdj1[0], kdj1[1]) > 0 && _Cross(kdj1[0], kdj1[1]) < 3) 

            if (rs.Close > rs.Open && rs.Volume > rs1.Volume * 1.5 && _Cross(kdj[0], kdj[1]) > 0 && _Cross(kdj[0], kdj[1]) < 5 && _Cross(ma7, ma25) > 0) {

                symbol_list.push([symbol_all[i][0], symbol_all[i][1], symbol_all[i][2]]) //加入数据保存

            }
            if ((rs.Close > rs.Open && rs.Volume > rs1.Volume * 2 && rs.Close / rs.Open > 1.04) || (rs.Close > rs.Open && rs.Volume > rs1.Volume * 4)) {
                symbol_list1.push([symbol_all[i][0], symbol_all[i][1], symbol_all[i][2]]) //加入数据保存
            }
            if (records[len - 3].Close > records[len - 3].Open && records[len - 1].Close > records[len - 1].Open && records[len - 2].Close > records[len - 2].Open) {
                symbol_list2.push([symbol_all[i][0], symbol_all[i][1], symbol_all[i][2]]) //加入数据保存
            }

            Sleep(100)
        }
        Log("没数据", symbol_list)
        Log("没数据", symbol_list1)
        Log("三连涨", symbol_list2)

    }
}







function main() {

    let loss = 2
    let loss_m = 0

    while (1) {
        // symbols()



        exchange.SetPrecision(priceScale, amountScale) //精度设置

        exchange.SetMarginLevel(MarginLevel) //合约倍数

        let records = exchange.GetRecords(60 * 60 * 4)
        let kdj = TA.KDJ(records, 9, 3, 3)
        let account = exchange.GetAccount()
        let position = _C(exchange.GetPosition) //持仓信息
        let Amount = position[0] ? position[0].Amount : 0
        let ticker = _C(exchange.GetTicker); // 获取 Tick 数据
        let ma7 = TA.EMA(records, 7)
        let ma25 = TA.EMA(records, 25)
        let money = bet * MarginLevel //买入数量为 2U的商品                

        if (_N(money / ticker.Sell, amountScale) == 0) {
            continue;
        }
        let len = records.length - 1
        if (!position[0] && _Cross(kdj[0], kdj[1]) > 0 && kdj[2][len] > kdj[1][len] + 2) {
            exchange.SetDirection("buy")
            exchange.Buy(-1, money / ticker.Sell, ticker.Last,"开仓价:", ticker.Sell)


        } else if (position[0] && position[0].Profit > position[0].Margin * 0.2) { //盈利20%就清仓

            //     Log(loss_m,position[0])
            exchange.SetDirection("closebuy")
            exchange.Sell(-1, position[0].Amount,ticker.Last, "盈利", position[0].Profit, ticker.Last, "#ff0000")
            loss = 0.6
            num = 0 //计数清零
            CancelPendingOrders() //清理无效定单

        } else if (position[0] &&  _Cross(kdj[0], kdj[1]) < 0 && position[0].Profit > position[0].Margin * 0.1) { //死叉平仓

            //     Log(loss_m,position[0])
            exchange.SetDirection("closebuy")
            exchange.Sell(-1, position[0].Amount,ticker.Last, "死叉平仓", position[0].Profit, ticker.Last, "#00009c")
            loss = 0.6
            num = 0 //计数清零
            CancelPendingOrders() //清理无效定单

        }else if (position[0] && position[0].Margin / bet < 2.5 && position[0].Profit * -1 > position[0].Margin * 0.4) { //本金亏完在补一次

            let nn = 0.2 //指数
            if (position[0].Profit * -1 / position[0].Margin > 0.4) {
                nn = position[0].Profit * -1 / position[0].Margin
                Log(nn, "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------")

            }

            exchange.SetDirection("buy")
            exchange.Buy(-1, position[0].Amount * nn, ticker.Last,"小补仓", ticker.Last, "持仓数量:", position[0].Amount, "| 浮动亏盈:", position[0].Profit, "| Margin:", position[0].Margin, "| 现有资金:", account.Balance, "| 持仓均价:", position[0].Price, "-------|最大单次浮亏", loss_m, "#0000ff")

            //      CancelPendingOrders() //清理无效定单
        } else if (position[0] && position[0].Margin / bet >= 2.5 && position[0].Margin / bet < 6 && position[0].Profit * -1 > position[0].Margin * 2) { //本金亏完在补一次


            exchange.SetDirection("buy")
            exchange.Buy(-1, position[0].Amount * 2, ticker.Last,"大补仓", ticker.Last, "持仓数量:", position[0].Amount, "| 浮动亏盈:", position[0].Profit, "| Margin:", position[0].Margin, "| 现有资金:", account.Balance, "| 持仓均价:", position[0].Price, "-------|最大单次浮亏", loss_m, "#ccff00")

            //    CancelPendingOrders() //清理无效定单
        }

        Sleep(1000)

        // Log("已经清算的数据",order_list)
        //     Log("结束", symbol_list)
        _G("orderlist", order_list)
        _G("symbol", symbol_list)
        Sleep(1000 * 2)

        if (position[0]) loss_m = position[0].Profit < loss_m ? position[0].Profit : loss_m

        let cmd = GetCommand()
        if (cmd) {
            Log(cmd)
            let arr = cmd.split(":")
            if (arr[0] == "要做空") {
                dan = 100
            } else if (arr[0] == "检查symbol_list") {
                Log("没数据就是没有符合条件的", symbol_list)
            } else if (arr[0] == "已经清算的数据") {

                Log("已经清算的数据", order_list)

            } else if (arr[0] == "清除持久数据数据") {

                Log("已经清算的数据")
                _G(null)

            }



        }
    }
Log( _C(exchange.GetPosition))





}

Mehr

Hexie8Kann man mehrere Währungen haben?

Die BettlerIch möchte Ihnen einige Fragen stellen, wie man die Mindestzahl aller Währungen berechnet.

xxs1xxs1Sie können mehrere Währungen wählen. Sie können sie selbst eingeben. Ich empfehle Ihnen, selbst zu schreiben: https://www.fmz.com/strategy/313036, das ist die Mehrwährung.

xxs1xxs1Sie müssen den Punkt berechnen, an dem Sie Ihre Position aufbauen. Zum Beispiel, wie viel Sie verlieren oder wie weit sich Ihr Bestand von seinem aktuellen Preis unterscheidet, um eine Aufstockung auszulösen.

Die BettlerKDJ ist immer in bedingungsvollen Zustand und jede Minute nachher löst er einen Nachschub aus, was soll ich tun?

xxs1xxs1Wenn man die Preise der Münzen um etwa 0,25 U*20 mal/der aktuellen Währungspreis multipliziert, bekommt man wahrscheinlich die geringste Anzahl von Aufträgen.