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

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



PureBytes Links

Trading Reference Links

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/