PureBytes Links
Trading Reference Links
|
ROC takes an array as argument. If you pass a scaler, then that scaler gets treated as an array with all its elements set to the same value. In other words, no change from one bar to the next.
Just calculate ROC normally, then access the result using your bar index. e.g.
foreignROC = ROC(Close);
var1 = foreignROC[bar];
Mike
--- In amibroker@xxxxxxxxxxxxxxx, "senior_banana" <senior_banana@xxx> wrote:
>
> I'm trying to use ROC() on a per bar basis, but all I get is zero.
>
> Abbreviated example below, but
> - C[bar] works as expected.
> - ROC(C) gives the same result for every bar (as expected)
> - ROC(C[bar]) gives me Zero. I would expect this to give me ROC for that bar. Is there a way to do that?
>
> Thanks,
> Ryan
>
>
> SetCustomBacktestProc("");
>
> if (Status("action") == actionPortfolio) {
> barDates = DateTime();
>
> bo = GetBacktesterObject();
> bo.PreProcess();
>
> for (bar = 0; bar < BarCount; bar++) {
> barDate = barDates[bar];
>
> for (sig = bo.GetFirstSignal(bar); sig; sig = bo.GetNextSignal(bar)) {
> if (sig.IsEntry() && sig.IsLong()) {
> SetForeign("XLE");
>
> //THIS NUMBER IS ALWAYS ZERO???
> Var1 = ROC(C[bar]);
>
> _TRACE(NumToStr(bar)+" "+NumToStr(C[bar])+" "+NumToStr(Var1));
>
> RestorePriceArrays();
> }
> }
> bo.HandleStops(bar);
> bo.UpdateStats(bar, 1);
> bo.UpdateStats(bar, 2);
> }
> bo.PostProcess();
> }
>
> Buy = C > MA(C,300);
> Sell = C < MA(C,300);
>
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|