compare two symbols

Discussion in 'Automated Trading' started by btoovey, Mar 25, 2010.

  1. Hello Btoovey

    Here is what your set up would look like in Tradestation with a time exit.
    I added the easy language code for using data1 and data2. I leave the rest to you.
    This kind of code has been around forever.

    Set up
    a) Calculate the percent change of the traded instrument IBM in data1
    Data1 Percent Change = (Close/Close[1] -1) * 100
    b) Calculate the percent change of the $INDU index in data 2
    Data2 Percent Change = (Close/Close[1] -1) * 100
    c) Calculate the relative strength of the percent change of the traded instrument versus the
    percent change of the index:
    Spread = (Data1 Percent Change/Data2 Percent Change -1) * 100
    d) If the spread is less than the oversold level (92),
    then buy this bar on the close.

    e) If the spread is higher than the overbought level (108),
    then sell this bar on the close.

    f) Exit out of all long positions when the market retraces to the lowest low of the last 6 bars.

    g) Exit out of all short positions when the market breaks out of the highest high of the last 6 bars.

    h) If 6 bars have gone by without any significant profit, exit all positions.
     
    #11     Mar 26, 2010
  2. btoovey

    btoovey

    Ok - Thanks for the responses - I downloaded multicharts and easylanguage seems pretty easy. Added multiple symbols to the same chart just trying to figure out how to reference data1 and data2 - as long as it can be done.

    Thanks again!

    Brian
     
    #12     Mar 28, 2010
  3. btoovey

    btoovey

    In this example:

    Condition1 = Close of Data1 > Close[1] of Data1 ;
    Condition2 = Low of Data2 < Low[1] of Data2 and
    Close of Data2 > Close[1] of Data2 ;
    if Condition1 and Condition2 then
    Buy next bar at market ;


    If Data2 is an equity as well, how do I specify the order to be placed on Data2?

    And how do I specify specifically the mapping between data1 and symbol1 and data2 and symbol2?

    Thanks,
    Brian
     
    #13     Mar 28, 2010
  4. moarla

    moarla

    ensign software
     
    #14     Mar 28, 2010
  5. btoovey

    btoovey

    So from what I am reading you cant place an order on the stock in data2, but you can use global variables to accomplish this with two charts. So I guess my question is:

    What is the syntax for defining a global variable - can't find it.

    How do I make sure data1 = symbol1, data2 = symbol2.

    Again using multicharts
     
    #15     Mar 28, 2010
  6. Hello Btoovey,

    I read your posts after mine. If you want me to respond directly to me press “quote” otherwise I might not find your thread again. The answer to your questions are as follows:

    Data1 and Data2 are used for computation of the spread Go under format symbol to see which symbol are data1 and which is data2. In your case data1 is IBM and active and the Index is $INDU and is specified in a hidden subgraph. Because $INDU is hidden your order will not go to $INDU but to IBM.

    Your order would look something like:

    If Spread < {the over sold level I set up for low}
    Buy this Bar at Close

    It has been awhile since I traded this spread technique but that’s how it worked for me. I never used global variables. Tradestation knows that an active symbol gets the order and not the hidden one. That is how it has always worked since 2000I. Please let me know if they changed it. Multcharts should work the same.

    RabbitOne


     
    #16     Mar 28, 2010
  7. btoovey

    btoovey

    Thanks for the reply - I figure out how to map data1 in the strategy to data1 on the symbol - under symbol properties you can specify this. And your right you can only trade the first symbol.

    I want to trade two symbols on an event though thats why im trying to figure out global variables - only whay to trigger two charts that I can find. I cant find any documentation on it though - ill keep looking
     
    #17     Mar 28, 2010
  8. In easy language/tradestation, you can only place trades for "data1". It's not possible to trade data 2.
     
    #18     Mar 28, 2010
  9. Hello Btoovey,

    It sounds like you want to do some pairs trading. A while back I wanted to write a code on Spread Trading for compare 2 different symbols: say, 10-year& 30-year Bond, when some conditions met. In this process I would Short one and Buy the other; then once the spread (the difference between the 2 symbols) changes I would take my profit or be stopped out.

    Since you can only trade the symbol in data1, I had to write two strategies for back testing. One strategy would trade one symbol, and the other would trade the other symbol. This is clumsy but it was the only way I could do pairs trading back in 2005. The only way I could analyze these trades was to export the data to a spread sheet. It was too clumsy so I abandoned the process.

    I’m not aware that TS has added pairs trading using global variables for one workspace?


     
    #19     Mar 29, 2010
  10. btoovey

    btoovey

    Well I have been using multicharts to test this, and I am trying to get a dll called GlobalVariable installed now - which should in theory allow me to have one chart where my strategy is executed, and then by setting a global variable, have the second chart trade off this variable.

    I will keep you updated.

    I do have a question though.

    by default my strategy and indicator are updating on every tic update right now, regardless of data1 or data2. Is there any way to have my indicator only update on new bars for data2 only?

    Brian
     
    #20     Mar 31, 2010