この問題は,どのようにデバッグされますか? アカウントにポジションがない場合,次のコードを使用してポジション情報を取得します. while(true){ var position=_C(exchange.GetPosition)
if(position==null){ continue } type=position[0].Type if(type==PD_LONG){ if(exsell!==sellPrice){ CancelPendingOrders() exchange.SetDirection(“closebuy”) exchange.Sell(sellPrice,position[0].Amount) exsell=sellPrice } } getpositionは,アカウントにポジションがない場合,空の配列を取得します.[ループが再開されますが,リールディスクテストは失敗します. TypeError: cannot read property ‘Type’ of undefined at main (FILE:129)
条件を変更してみました.[0]==null または typeof(position) ==undefined は実行できません.[0].Type barが策略を誤報する
この問題はどのように解決されるのでしょうか?