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

[amibroker] Re: Long and short but only together?



PureBytes Links

Trading Reference Links

If you want the buy or short to be dependent upon a signal from other symbols in the watchlist, then you have a few options:

1. Use Foreign to reference each of the remaining symbols in the list while processing each individual symbol.

2. Write custom backtester code to iterate through the list of signals and check for balanced signals. Cancel signals that aren't paired by setting PosSize to zero.

3. Write a preliminary AFL that uses AddToComposite to count the number of long and short signals at each bar (e.g. ~LongSignal, ~ShortSignal), then run your second AFL afterwards that references the composites in addition to its own buy/short signal.

Option 1 would be very slow and somewhat against the natural processing of AFL (i.e. it would work, but would be highly redundant).
http://www.amibroker.com/guide/afl/afl_view.php?id=54

Option 2 requires reading up on custom backtesting but would be the more natural way to go, and most useful for future projects.
http://www.amibroker.com/guide/a_custombacktest.html

Option 3 requires reading up on composites and would require a two pass approach (once for the composite, again for the trade logic) and might also need static variables if you need exact balance (i.e. upon finding 3 longs and 2 shorts you chose to only take 2 longs to match the 2 shorts).
http://www.amibroker.org/3rdparty/IntroToAtc.pdf

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "felixbraendli" <felixbraendli@xxx> wrote:
>
> Thks very much... I tried that... but i doesn t work, because (I think) in portfolio backtesting the backtester takes one share by share and applys the rules. That means that with your formula the backtester takes the first stock from the portfolio and tests if buy and sell rule is true... if it is then it buys...
> But the backtester should look for all buy rules for all stocks at a bar, take the best stock due to positionscore and go long...
> the same thing the backtester should do with the short signals...
> Then the final rule should come in: that only long or short is enterd when both for the portfolio is true...
> 
> perhaps there must be another way... with low level programming? 
> After my opinion we ve overseen something... it couldnt be that hard to program?
> 
> best regards... if you see another way let me know... lg
> 
> Felix Brändli
>




------------------------------------

**** 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/