Upon closer inspection, looks like I introduced that error, not you ;) Anyway, you should be good now (at least with the syntax, the best PosSize logic to use is still yours to work out).
Mike --- In [email protected], "Mike" <sfclimb...@...> wrote: > > Hi, > > Sorry, the SetForeign advice was good. But, my example propogated > another error in your original code. sig.PosSize is a scaler, not an > array. As such, you cannot pass the result of an array calculation as > value. Instead, you must calculate the value for the given bar. Your > original example thus becomes: > > SetCustomBacktestProc(""); > > if ( Status( "action" ) == actionPortfolio ) > { > bo = GetBacktesterObject(); > bo.PreProcess(); > > for ( bar = 0; bar < BarCount; bar++ ) > { > CurrentEquity = bo.Equity; > > for ( sig = bo.GetFirstSignal( bar ); sig; sig = > bo.GetNextSignal( bar ) ) > { > SetForeign( sig.Symbol ); > YesterdayClose = Ref(C, -1); > YesterdayATR = Ref(ATR(10), -1); > sig.PosSize = CurrentEquity * YesterdayClose[bar] / > YesterdayATR[bar]; > RestorePriceArrays(); > } > > bo.ProcessTradeSignals( bar ); > } > > bo.PostProcess(); > } > > Note also that you should be calling bo.PostProcess instead of > bo.ListTrades. > > Mike > > --- In [email protected], "ezbentley" <ezbentley@> wrote: > > > > Hi Mike, > > > > Thanks for the attempt to help. However, I still get an error with > the following code: > > > > SetForeign(sig.Symbol); > > sig.PosSize = CurrentEquity * AccountRiskPercent * ref(C, -1) / 100; > > RestorePriceArrays(); > > > > Error 19. COM method/function 'PosSize' call failed. > > > > Thanks, > > >
