HIGHESTSINCEBARS Returns the number of bars that have passed since highest ARRAY value since EXPRESSION was true on the Nth most recent occurrence. 这是哪国的英语啊?我怎么看得那么晕。
我吧,我承认我比较笨。简单的方法我是搞不定了,只能兜个大圈了。 Code: SetOption("InitialEquity", 10000000); buyCond = c > ref(c, -1); sellCond = c < ref(c, -1); buy = buyCond; sell = sellCond; cover = short = false; dn = dateNum(); SetOption("UseCustomBacktestProc", True ); if(status("action") == actionPortfolio){ bo = GetBacktesterObject(); bo.PreProcess(); lastEntryDate = 0; for(bar = 0; bar < barCount; bar++) { for (sig = bo.GetFirstSignal(bar); sig; sig = bo.GetNextSignal(bar)) { if(sig.IsEntry()) { if(dn[bar] == lastEntryDate) sig.PosSize = 0; else lastEntryDate = dn[bar]; } } bo.ProcessTradeSignals(bar); } bo.PostProcess(); }
上面的似乎无法在开平过多仓后,禁止开空仓。 也许改成这样能好点? buyshort = exrem(buy or short, 是否换日) buy = buyshort and buy; short = buyshort and short;