[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Q regarding removing succeeding signals from HighestSince or LowestSince



PureBytes Links

Trading Reference Links

The way I see it, there is a logical problem with trying to do this
with purely array maths. I think it has to be done iteratively using a
loop.

The problem is that you want to create a buy array first, then use
HighestSince(Buy, ...) as part of the definition of the sell array.
What you really mean though is highest since the buy signal after the
most-recent sell signal, but with array maths you can't reference a
previous sell signal during the definition of the sell array. So you
have a Catch-22 in that you can't remove redundant buy signals until
the sell array has been defined, but can't define the sell array with
HighestSince(Buy, ...) while there are redundant buy signals.

Unless array maths is changed to allow iterative definitions, whereby
an array could be defined based on earlier values of the same array in
the same statement, I think you will need to use a loop.

Regards,
GP


--- In amibroker@xxxxxxxxxxxxxxx, "janhausd" <janhaus@xxx> wrote:
>
> Hi,
> 
> I did some searching in the posts, and it looks like many people have
> asked for methods to remove the extraneous signals from HighestSince
> or LowestSince so that the function can return the very first signal
> and not the ones which appear afterwards.
> 
> I've tried copying the code from these two posts, using loops or loops
> + global vars, or some combination of ExRem, or Flip or ExRemSpan but
> I have not yet gotten it working:
> http://finance.groups.yahoo.com/group/amibroker/message/117998
> http://finance.groups.yahoo.com/group/amibroker/message/72151
> 
> Is there a simple way to accomplish this? Otherwise, the trailing
> stops don't work correctly since HighestSince is reset with each
> succeeding Buy signal and vice versa for LowestSince. The below is the
> code I'm looking to fix:
> 
> ---
> Buy = Signal1 & Signal2;
> Short = Signal1Rev & Signal2Rev;
> Buy = Ref(Buy,-1);
> Short = Ref(Short,-1);
> BuyPrice = O;
> ShortPrice = O;
> SetTradeDelays(0,0,0,0);
> 
> sellstopline = HighestSince( Buy, High ) * STrailingStopPct;
> BuyBarsSince = BarsSince(Buy == 1);
> sellprofitline = Ref(BuyPrice, -BuyBarsSince) * SProfitStopPct;
> sellex = sellstopline > P;
> sellex2 = P > sellprofitline;
> Sell= IIf(sellex,4,(IIf((sellex2),3,0)));
> SellPrice = O;
> 
> coverstopline = LowestSince( Short, Low ) * BTrailingStopPct;
> ShortBarsSince = BarsSince(Short == 1);
> coverprofitline = Ref(ShortPrice, -ShortBarsSince) * BProfitStopPct;
> buyex = P > coverstopline;
> buyex2 = coverprofitline > P;
> Cover= IIf(buyex==1, 4, (IIf((buyex2),3,0)));
> CoverPrice = O;
> Equity(1,0);
> --
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
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/