PureBytes Links
Trading Reference Links
|
--- In amibroker@xxxxxxxxxxxxxxx, "Barry Scarborough" <razzbarry@xxx> wrote:
Barry,
Besides the null behavior you are seeing, I think you have a logic issue:
> Buy = tradeTime AND fMAup AND bsBuy > bsSell; // never true
For the first bar, I don't think bsBuy > bsSell can ever be true. That means that Buy is never true for the first bar. Then for subsequent bars, BarsSince(Buy) can also never be greater than BarsSince(Sell) so you will never get a Buy. You may need special handling so that you can get the first Buy signal.
Tuzo
>
> I must be brain dead this morning. BarsSince is not working as expected. I am trying to use BarsSince in the signal logic but when I try to set the values before the buy sell short and cover the value returned is null, 1e+010. That doesn't make sense. If I get the values after the signals are set the values are correct. But this prevents them from being use in the signal logic.
>
> Why doesn't BarsSince return the correct values in the first assignment?
>
> The code follows.
>
> Thanks,
> Barry
>
> // BarsSince test
> #include <AT Functions\Colors.afl>
>
> fMA = MA(C, 5);
> fMAup = fMA >= Ref(fMA, -1);
> fMAdn = fMA < Ref(fMA, -1);
> Plot(fMA, "MA", MA1color);
>
> sysTime = TimeNum();
> tradeTime = IIf(sysTime >= 73000 AND sysTime < 161500, True, False);
>
> Plot( C, "Close", pricecolor, styleNoTitle | styleBar ); // shows all style options
>
> Buy = Sell = Short = Cover = 0;
>
> // #### First assignment
> // barssince returns null here
> bsBuy = BarsSince(Buy);
> bsSel = BarsSince(Sell);
> bsSht = BarsSince(Short);
> bsCov = BarsSince(Cover);
> StrFormat("sysTime=%g, TradeTime=%g \nBS buy=%g, BS sell=%g \nBS short=%g, BS cover=%g",sysTime, tradeTime, bsBuy , bsSel, bsSht, bsCov);
>
> Buy = tradeTime AND fMAup; // works fine
> // when I try to use barssince the buy logic is never true.
> Buy = tradeTime AND fMAup AND bsBuy > bsSell; // never true
>
> Short = tradetime AND fMAdn;
> Sell = tradetime AND fMAdn;
> Cover = tradetime AND fMAup;
>
> // #### Second assignment
> // barssince returns the true values here
> bsBuy = BarsSince(Buy);
> bsSel = BarsSince(Sell);
> bsSht = BarsSince(Short);
> bsCov = BarsSince(Cover);
>
> StrFormat("\nBS buy=%g, BS sell=%g \nBS short=%g, BS cover=%g", bsBuy , bsSel, bsSht, bsCov);
>
> PlotShapes(Buy * shapeUpArrow, uparrow, 0, Low, -5);
> PlotShapes(Sell * shapeDownArrow, dnarrow,0, High, -5 );
> PlotShapes(Short * shapeHollowDownArrow, dnarrow, 0, High, -20 );
> PlotShapes(Cover * shapeHollowUpArrow, uparrow, 0, Low, -20);
>
------------------------------------
**** 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/
|