Amibroker backtest code - buy if stock B is 5% above open?

Discussion in 'Trading Software' started by JeremyTheTrader, Jan 19, 2010.

  1. I'm trying to do some back testing in Amibroker and can't figure out home to do the following...

    I want Amibroker to trigger a buy of stock A (ABC) if stock B (XYZ) high of for the day is 5% or more above the open price. I can't figure out how to reference a different stock. Any ideas?

  2. I think the function is called foreign symbol. Google that in the docs.

    A-Z Index | Category Index |
    - access foreign security data

    Referencing other symbol data
    (AFL 1.5)

    SYNTAX foreign( TICKER, DATAFIELD, fixup = 1)
    FUNCTION Allows referencing other (than current) tickers in the AFL formulas. TICKER is a string that holds the symbol of the stock. DATAFIELD defines which array is referenced. Allowable data fields: "O" (open), "H" (high), "L" (low), "C" (close), "V" (volume), "I" (open Interest), and for v5.29 and above: "1" (aux1), "2" (aux2)
    The last parameter - fixup - accepts following values
    0 - the holes are not fixed
    1 - default value - missing data bar OHLC fields are all filled using previous bar Close and volume is set to zero.
    Note: you can use Foreign/RelStrength without specifying last parameter:
    Foreign( "ticker", "field" ), RelStrength( "ticker" ) - then the holes will be fixed.

    2 - (old pre-4.90 behaviour) - causes filling the holes in the data with previous O, H, L, C, V values