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

[amibroker] Re: How can I create buy/sell signal on two symbols simultaneously?



PureBytes Links

Trading Reference Links

Hi,

You've got the concept reversed. I am reasonably confident that your
system can be done using AmiBroker. But, you need to clarify something;

Do you plan to evaluate multiple symbols in a watchlist and have them
all generate the Buy in the 2nd symbol (i.e. the index)? If so, what
do you want to happen if multiple symbols generate a buy for a given
bar? Which positionsize value would you want to use (the first, the
last, something else)?

If you want to take signals based on more than one other symbol (e.g.
a watchlist), you can iterate through the symbols of the watchlist and
pass the name of each to the SetForeign call. But, you would then have
to resolve collisions on position sizing.

If you just want to use a single other symbol as the trigger, you can
get rid of the loop and just pass the symbol name directly to SetForeign.

Script for symbols in watchlist
-------------------------------
Buy = ...
Sell = ...
PositionSize = ...


script for second symbol only (e.g. SPY)
----------------------------------------
listnum = ... // number of your watchlist
list = CategoryGetSymbols(categoryWatchlist, listnum);

for(i = 0; (sym = StrExtract(list, i)) != ""; i++) {
  SetForeign(sym);
  foreignBuy = ... // Exactly as Buy in above script
  foreignSell = ... // Exactly as Sell in above script
  foreignPositionSize = ... // Exactly as PositionSize in above script
  RestorePriceArrays();

  Buy = Buy OR foreignBuy;
  Sell = Sell OR foreignSell;
  PositionSize = ??? // You need to decide how to handle this
}

When using SetForeign, all values for Open/High/Low/Close will come
from the foreign symbol, and all functions will be applied against
those values. If you didn't want to repeat the identical code, you
could wrap it in a function in the first script, then use the include
statement to include it in the second script.

Hope that helps.

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "markhoff" <markhoff@xxx> wrote:
>
> 
> I would like to mention one point which might be essential to find a
> solution: The 2nd symbol is always the same independent on the 1st
> symbol, means for all signals on the symbols within a list the
> contrary signals should be created on a single 2nd symbol, e.g. an
> index tracker like SPY.
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "markhoff" <markhoff@> wrote:
> >
> > Hi folks,
> > 
> > I'm struggeling with one idea which I would like to implement in AFL,
> > but I have no clue if it is possible.
> > The basic concept is to generate a buy/sell signal on two symbols at
> > the same time, based on the trigger from the actual (1st) symbol which
> > is evaluated by AA backtester (e.g. when processing a watchlist).
> > Stepwise Example:
> > 
> > --- cut ---
> > 
> > buy = <my formula to create the buy signal for the current symbol>
> > sell = <my formula to create the sell signal for the current symbol>
> > 
> > positionsize = <my formula to calculate possize of the current symbol>
> > 
> > // now my problem (algorithm description)
> > 
> > if(buy == true)
> > {
> >   sell_2nd_symbol = true;
> >   positionsize_2nd_symbol = positionsize;
> > }
> > if(sell == true)
> > {
> >   buy_2nd_symbol = true;
> >   positionsize_2ns_symbol = positionsize;
> > }
> > 
> > --- cut ---
> > 
> > So I have to transfer both buy/sell signal and positionsize for each
> > trade of the 1st (actual) symbol to a 2nd symbol to create the
> > appropriate signals also here, and the trade for both symbols should
> > be done on the same DAY (no bar number, which might be different if
> > the size of my array for 1st symbol is different from 2nd symbol).
> > 
> > I could not find any way to do it with the custom backtester, now I'm
> > not sure if I missed the right way or if I ran into a limitation
of AB.
> > 
> > Does anybody have a hint how to solve above problem?
> > 
> > Thanks in advance and best regards,
> > Markus
> >
>



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

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/