{data1 = S&P 500 Futures -- five-minute continuous data} {data2 = 10-Year-Treasury-Notes Futures -- five-minute continuous data} {data3 = S&P 500 Futures -- daily closing prices using continuous data} {data4 = 10-Year-Treasury-Notes Futures -- daily closing prices using continuous data} {Note: times in EST} inputs: entryFactor(3.0), exitFactor(5.0), length(30); variables: interMarketSpread(0), histVolSP(0), histVolNotes(0), R(0), weightSP(0.5), weightNotes(0.5), volBand(0); if close[1] of data3 <> 0 and close[1] of data4 <> 0 then interMarketSpread = log(close of data1/close of data3) - log(close of data2/close of data4); if date <> date[1] and close[1] <> 0 and close[1] of data3 <> 0 and close[1] of data4 <> 0 then begin histVolSP = stdDev(log(close/close[1]),length) of data3; histVolNotes = stdDev(log(close/close[1]),length) of data4; R = coefficientR(log(close of data3/close[1] of data3), log(close of data4/close[1] of data4), length); if (square(weightSP) * square(histVolSP) + square(weightNotes) * square(histVolNotes) + 2 * weightSP * weightNotes * R * histVolSP * histVolNotes) > 0 then volBand = squareroot(square(weightSP) * square(histVolSP) + square(weightNotes)* square(histVolNotes) + 2 * weightSP * weightNotes * R * histVolSP * histVolNotes); end; If time < 1700 or time > 2100 then begin If interMarketSpread crosses above - entryFactor * volBand then buy next bar on open; If interMarketSpread crosses below entryFactor * volBand then sell short next bar on open; end; If marketposition = 1 then begin If interMarketSpread crosses above 0 then sell next bar on open; If interMarketSpread crosses below -exitFactor * volBand then sell next bar on open; end; If marketposition = -1 then begin If interMarketSpread crosses below 0 then buy to cover next bar on open; If interMarketSpread crosses above exitFactor * volBand then buy to cover next bar on open; end;