PureBytes Links
Trading Reference Links
|
Seems like spread programming requires Rube Goldberg
type treatments. Think he was a fellow San Franciscan
so what the heck.
I emailed Alex awhile back and he said the best way to
accomplish this task was to write a highD, lowD for
spreads, but this is way beyond me.
I have worked with for count=0 to X population, but
have not figured out how to do it with traps. Doesn't
fly, but then again the Rube Goldberg in me says there
has to be a way.
So perhaps the excel export and the global variable, I
use TS 8, will have to be the way. Any help in this
area would be greatly appreciated and would be happy
to talk shop about spreads as well.
Doug
--- Lee Goldberg <best-revenge@xxxxxxx> wrote:
> Hi Doug,
>
> I understand better from your reply comments.
> My new comments between...
>
> At 05:17 PM 6/30/2004 -0700, Doug Johnson wrote:
> >First let me take a step back. I use intraday
> (5min) data to collect all
> >my high and low for the spread during the day data.
> I collect the high and
> >low for the spread by always using the closing
> price of each stock and
> >trapping the highest spread high and lowest spread
> low. Then at the end of
> >the day I wish to register four things, but the
> first two are especially
> >important.
> >1. The high of the spread for the day.(intraday
> traps)
> >2. The low of the spread for the day.
> >3. The close of the spread for the day. (closeD
> data1-closeD data2)
> >4. The open of the spread for the day, when both
> stocks are open, not the
> >opening price of both stocks (perhaps off
> volume...).
> >
> > From here with these 2-4 data points I want to put
> them into an
> > array/function and convert the intraday collection
> to an end of day
> > average true range for twenty days calculation. (I
> like to know when a
> > spread has traveled more than 100% atr20, if open
> is extreme %...)
>
> I agree that using a small compression (ex. 5 mins)
> to get spread values is
> the best way to get more accurate daily highs and
> lows for a spread. Data1
> and data2 make their highs and lows for the day at
> different times so
> spread highs/lows based on day bars are way off.
>
> Here's what I do to make accurate, historical daily
> spread bars. This
> might work for you since you mentioned you want EOD
> spread high/low for use
> in an ATR study.
>
> Don't let the process turn you off, it's very quick
> and easy and the
> resultant data stream is excellent. You can
> actually use the resultant
> data with the built-in TS2k ATR or any other
> built-ins. I got the basic
> idea some time ago from Alex Matulich.
>
> 1.Create a chart of 5min bars for data1. Insert
> data2 5min bars in
> subgraph2. Toggle the Data Window open and right
> click on it. Select to
> send the chart data to a file. Select and send one
> symbol at a time. The
> procedure will send an ascii file that is perfect
> for TS and Excel to the
> location, and with the name, you specify. Do it for
> both data1 & 2.
>
> 2.Open each new data file in XL. Each one will open
> in a separate
> workbook. Copy/paste the Date/Time/O/H/L/C columns
> from the data2
> worksheet onto the data1 worksheet. I leave an
> empty column or two between
> the set of data1 columns and the data2 columns.
>
> 3.After that, it's easy to confirm that the
> times/bars for both data
> match-up, and to fix any mis-matches. Then you do
> the calcs to create the
> spread h/l/o/c for each bar. You end up with a data
> stream of the actual
> spread bars' D/T/O/H/L/C that you save in a format
> that TS reads. After
> you do the initial batch, adding a new day's worth
> of data after the close
> takes less time than drinking your first Sam Adams.
>
> 4.The "artificial" spread data you created can then
> be used in a TS chart
> of any equal or bigger time compression you choose.
> That includes Daily,
> and the most accurate daily spread high/low is
> automatically charted when
> you make the chart. For example, I use 24 hr. data
> so I found that
> plotting daily spread bars made of hourly spread
> bars from using the
> process described, gives me the daily spread
> high/low within pennies of
> what 5min bars gave me. You can apply any built in
> study to that
> artificial spread data.
>
> 5. If you want to use the XL method, let me know and
> I'll give you the
> actual how-to. The XL work is very easy with just a
> few tips on
> selecting/copying/pasting/saving in XL.
>
> >With my, I call them traps, trap code, I don't know
> how to populate an
> >array. Functions seems to be the way to go, it
> would be a piece of cake if
> >there was a highD for a spread.
>
> Usually a loop is used to populate an array. If you
> look at one of the
> built-in (or other) studies/functions that use an
> array you'll see how it's
> done. I forget what the limit is for the number of
> elements permitted in
> an array. If you're using a very small compression
> in a long market
> session you might exceed the limit?
>
> >It seems like each day the functions you submitted
> would need to clear
> >themselves each morning and store the data at the
> end of the day for
> >reference purposes.
>
> My functions will clear/initialize at the beginning
> of each new bar, no
> matter what compression the bars are. As above, the
> bigger the bar
> compression the less accurate the spread values will
> be, so applying the
> functions on daily data are not accurate.
>
> So, a "real time" XL alternative idea off the top of
> my head....
>
> At the end of a session use your BarsBack calc
> >(if barInterval<>0 then BarsBack =
> timeBack/barInterval)
> in
>
> Highest(SprdTrueHigh(adj1,adj2),BarsBack) and
> Lowest(SprdTrueLow(adj1,adj2),BarsBack)
>
> Even though you're using 5min bars, the end of each
> session will show you
> the highest/lowest spread values that occurred
> during that session. You
> can plug them into whatever study you like.
>
> >I hope one of these ideas is helpful. Admittedly,
> I'm the lee RUBE
> >Goldberg of the Olist.
> >
> >Lee
> >
> Lee Goldberg <best-revenge@xxxxxxx> wrote:
> >>Sorry. The indicator needs the function inputs so
> it is
> >>
> >>SprdTR = average(SprdTrueRange(Adj1,Adj2) ,N);
> >>
>
>>*******************************************************
> >>Hi Doug,
> >>
> >>I took the easy way out (maybe the wrong way out?)
> and made 3 user
> >>functions like so:
> >>
> >>{SpreadTrueHigh user function}
> >>Inputs: Adj1(numeric), Adj2(numeric) ;
> >>Vars: SprdC(0), SprdH(0) ;
> >>
> >>SprdC = (C data1)*Adj1 - (C data2)*Adj2 ;
> >>SprdH = (H data1)*Adj1 - (H data2)*Adj2 ;
> >>
> >>If SprdC[1] > SprdH Then
> >>SprdTrueHigh = SprdC[1]
> >>Else
> >>SprdTrueHigh = SprdH ;
>
>>*********************************************************
> >>{SpreadTrueLow user function}
> >>Inputs: Adj1(numeric), Adj2(numeric) ;
> >>Vars: SprdC(0), SprdL(0) ;
> >>
> >>SprdC = (C data1)*Adj1 - (C data2)*Adj2 ;
> >>SprdL = (L data1)*Adj1 - (L data2)*Adj2 ;
> >>
> >>If SprdC[1] < SprdL Then
> >>SprdTrueLow = SprdC[1]
> >>Else
> >>SprdTrueLow = SprdL ;
>
>>****************************************************
> >>{SpreadTrueRange user function}
> >>Inputs: Adj1(numeric), Adj2(numeric);
> >>
> >>SprdTrueRange =
> SprdTrueHigh(Adj1,Adj2)-SprdTrueLow(Adj1,Adj2) ;
>
>>**********************************************************
> >>Then you can do something like
> >>
> >>SprdTR = average(SprdTrueRange,N) ;
> >>
> >>Regards,
> >>Lee
> >>
> >>At 10:55 AM 6/29/2004 -0700, you wrote:
> >> >Hello all,
> >> >
> >> >I am a spread trader of stock pairs. I am trying
> to
> >> >create some tradestation code for average true
> range
> >> >of a spread relationship.
> >> >
> >> >Below is my attempt, but it is flawed, and gets
> even
> >> >more flawed when 1/2 days are in the mix.
> >> >
> >> >What I wish to do is create an array and during
> the
> >> >day capture the high of the spread on say a 5
> min
> >> >basis, and the low of the spread on a 5 min
> basis, as
> >> >well as the close. The close should be no
> problem.
> >> >
> >> >What I want to do is mimic the highD, lowD
> function,
> >> >for a spread relationship, and be able to call
> back 20
> >> >days of data. I know how to capture the hi and
> low,
> >> >see below, for the day, but I don't know how to
> >> >successively store those values in an array.
> >> >
> >> >Can anyone help me adapt this code into a more
> stable
> >> >and dynamic array format?
> >> >
> >> >inputs: spreadMultiple(1) , rangePct(1),
> >> >timeBack(390);
> >> >variables: hSpread(0), lSpread(0),
> spreadRange(0),
> >> >spreadRange2(0), spreadRange3(0),
> spreadRange4(0),
> >> >spreadRange5(0), avgRange5(0), spread(0),
> barsBack(0)
> >> >;
> >> >
> >> >spread=(close data1*spreadMultiple) - close
> data2;
> >> >
> >> >if date<>date[1] then
> >> >begin
> >> > hSpread=-999999;
> >> > lSpread=999999;
> >> >
> >>
> >> >
> >> >if currentBar>500 then
> >> >begin
> >> >
> >>
>
>spreadRange=absValue(absValue(hSpread[barsBack+1])-absValue(lSpread[bars
>
> >> Bac
> >> > k+1]));
> >> >
> >>
>
>spreadRange2=absValue(absValue(hSpread[barsBack+2])-absValue(lSpread[bar
>
> >> sBa
> >> > ck+2]));
> >> >
> >>
>
>spreadRange3=absValue(absValue(hSpread[barsBack+3])-absValue(lSpread[bar
>
> >> sBa
> >> > ck3]));
> >> >
> >>
>
>spreadRange4=absValue(absValue(hSpread[barsBack+4])-absValue(lSpread[bar
>
> >> sBa
> >> > ck+4]));
> >> >
> >>
>
>spreadRange5=absValue(absValue(hSpread[barsBack+5])-absValue(lSpread[bar
>
> >> sBa
> >> > ck+5]));
> >> >
> >>
>
>avgRange5=spreadRange+spreadRange2+spreadRange3+spreadRange4+spreadRange
>
> >> 5)/5;
> >> >end;
> >> >
> >> >if spread>hSpread then hSpread=spread;
> >> >
> >> >if spread>
> >> >if currentBar>300 then
> >> >begin
> >> > value1=hSpread-(avgRange5*rangePct);
> >> > value2=lSpread+(avgRange5*rangePct);
> >> >
> >> > plot1(spread,"spread",magenta);
> >> > plot2(value1,"ar-",green );
> >> > plot3(value2,"ar+",green );
> >> >end;
> >> >
> >> >Thanks,
> >> >Doug
> >>
> >>
> >>
> >>
> >>
> >>At 10:55 AM 6/29/2004 -0700, Doug Johnson wrote:
> >> >Hello all,
> >> >
> >> >I am a spread trader of stock pairs. I am trying
> to
> >> >create some tradestation code for average true
> range
> >> >of a spread relationship.
> >> >
> >> >Below is my attempt, but it is flawed, and gets
> even
> >> >more flawed when 1/2 days are in the mix.
> >> >
> >> >What I wish to do is create an array and during
> the
> >> >day capture the high of the spread on say a 5
> min
> >> >basis, and the low of the spread on a 5 min
> basis, as
> >> >well as the close. The close should be no
> problem.
> >> >
> >> >What I want to do is mimic the highD, lowD
> function,
> >> >for a spread relationship, and be able to call
> back 20
> >> >days of data. I know how to capture the hi and
> low,
> >> >see below, for the day, but I don't know how to
> >> >successively store those values in an array.
> >> >
> >> >Can anyone help me adapt this code into a more
> stable
> >> >and dynamic array format?
> >> >
> >> >inputs: spreadMultiple(1) , rangePct(1),
> >> >timeBack(390);
> >> >variables: hSpread(0), lSpread(0),
> spreadRange(0),
> >> >spreadRange2(0), spreadRange3(0),
> spreadRange4(0),
> >> >spreadRange5(0), avgRange5(0), spread(0),
> barsBack(0)
> >> >;
> >> >
> >> >spread=(close data1*spreadMultiple) - close
> data2;
> >> >
> >> >if date<>date[1] then
> >> >begin
> >> > hSpread=-999999;
> >> > lSpread=999999;
> >> >
> >> >if barInterval<>0 then barsBack =
> >> >timeBack/barInterval;
> >> >
> >> >if currentBar>500 then
> >> >begin
> >> >
> >>
>
>spreadRange=absValue(absValue(hSpread[barsBack+1])-absValue(lSpread[bars
>
> >> Bac
> >> > k+1]));
> >> >
> >>
>
>spreadRange2=absValue(absValue(hSpread[barsBack+2])-absValue(lSpread[bar
>
> >> sBa
> >> > ck+2]));
> >> >
> >>
>
>spreadRange3=absValue(absValue(hSpread[barsBack+3])-absValue(lSpread[bar
>
> >> sBa
> >> > ck3]));
> >> >
> >>
>
>spreadRange4=absValue(absValue(hSpread[barsBack+4])-absValue(lSpread[bar
>
> >> sBa
> >> > ck+4]));
> >> >
> >>
>
>spreadRange5=absValue(absValue(hSpread[barsBack+5])-absValue(lSpread[bar
>
> >> sBa
> >> > ck+5]));
> >> >
> >>
>
>avgRange5=spreadRange+spreadRange2+spreadRange3+spreadRange4+spreadRange
>
> >> 5)/5;
> >> >end;
> >> >
> >> >if spread>hSpread then hSpread=spread;
> >> >
> >> >if spread>
> >> >if currentBar>300 then
> >> >begin
> >> > value1=hSpread-(avgRange5*rangePct);
> >> > value2=lSpread+(avgRange5*rangePct);
> >> >
> >> > plot1(spread,"spread",magenta);
> >> > plot2(value1,"ar-",green );
> >> > plot3(value2,"ar+",green );
> >> >end;
> >> >
> >> >Thanks,
> >> >Doug
> >>
> >>
> >>
> >>
> >>
>
|