自建用户函数不能取数
老师您好,刚才接触TB时间不久,我建立一个用户函数, h_h1的返回值是0,不能正确返回数值。改变为策略公式时,却能返回数值,是什么原因哪。Params Numeric howlong(20); Numeric leftlong(3); Numeric rightlong(3); Numeric N(3); Vars Series<Numeric> shorthigh; Series<Numeric> longhighbar; Series<Numeric> shorthighbar; Series<Array<Numeric>> h_high; Series<Array<Numeric>> h_bar; Numeric h_h1;Begin { Numeric PivotPrice1; Numeric PivotBar1; Bool ret1 = Pivot(high,howlong,leftlong,rightlong,1,1,PivotPrice1, PivotBar1); shorthighbar = PivotBar1; Numeric PivotPrice2; Numeric PivotBar2; Bool ret2 = Pivot(high,howlong*N,leftlong*N,rightlong*N,1,1,PivotPrice2, PivotBar2); longhighbar = PivotBar2; if(ret1) { shorthigh = PivotPrice1; if(shorthigh<>shorthigh[1]) { ArrayPushBack(h_high,PivotPrice1); Integer size = GetArraySize(h_high); if(size>5) { ArrayErase(h_high,0,1); } } } Array<Numeric> h_bar_h =h_high; Numeric h_h1=h_bar_h[4]; } Return h_h1; End