Falar é barato, mostra-me o código
Só para aprender, tenha cuidado ao usar no mercado real.
Só funcionam nas bolsas de moeda digital.
Nota: esta estratégia incluiu modelo. (função com $.)
Os iniciantes podem começar com esta estratégia, aprender a programar, saber a diferença entre backtesting e mercado real.
/*backtest start: 2020-10-11 00:00:00 end: 2020-10-11 23:59:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Binance","currency":"BTC_USDT"}] */ start = false function main() { Log('started'); var initAccount = _C(exchange.GetAccount); var ticker = exchange.GetTicker(); var InitValue = (initAccount.Stocks + initAccount.FrozenStocks)*ticker.Last + initAccount.Balance + initAccount.FrozenBalance; while (true) { var records = _C(exchange.GetRecords, PERIOD_M15); if(!start){ Log(records[0], records.length) start = true } ticker =_C(exchange.GetTicker); var FastRecords = TA.MA(records,FastPeriod); var SlowRecords = TA.MA(records,SlowPeriod); var NowAccount = _C(exchange.GetAccount); var n = _Cross(FastRecords, SlowRecords); if (n >= EnterPeriod && NowAccount.Balance > 0) { var Price = _N(ticker.Sell+Slippage, 2); var Amount = _N(0.99*NowAccount.Balance/Price, 3); if(Amount>0.1){ var id = exchange.Buy(Price, Amount); if(exchange.GetOrders(id).Status == ORDER_STATE_PENDING){exchange.CancelOrder(id);} LogProfit((NowAccount.Stocks + NowAccount.FrozenStocks)*ticker.Last + NowAccount.Balance + NowAccount.FrozenBalance - InitValue); } } if(n <= -EnterPeriod && NowAccount.Stocks > 0) { var Price = _N(ticker.Buy-Slippage, 2); var Amount = _N(NowAccount.Stocks, 3); if(Amount>0.1){ var id = exchange.Sell(Price, Amount); if(exchange.GetOrders(id).Status == ORDER_STATE_PENDING){exchange.CancelOrder(id);} LogProfit((NowAccount.Stocks + NowAccount.FrozenStocks)*ticker.Last + NowAccount.Balance + NowAccount.FrozenBalance - InitValue); } } if(!IsVirtual()){ Sleep(Interval*1000) } } }
Eu amo o Jimmy.O exchange.GetOrders ((id).Status deveria ser o exchange.GetOrders ((id).type, certo?