capissimo

SpreadTrade - Distance (ps4 ver. 2)

This script implements a rebrushed distance-based pair trading strategy. In this strategy, normally they trade the difference between the prices of two instruments. This difference is also called spread. Here, however we’ll trade the difference between two time frames of one instrument. And that's the main trick. Common procedure consists of the following steps:

1. Select two CORRELATED stocks. Here we'll use the same instrument in different TFs.
2. Generate the spread by calculating the difference between the prices/instruments. For distance based pair trading, we need to (rescale the data first and then) check the distance between them.
3. Define the logic to trade the spread and generate the trading signals. In this example we’ll calculate the rolling mean and rolling standard deviation of the spread. Whenever the spread goes above a rolling mean by one standard deviation, we’ll short the spread expecting the mean reversion behavior to hold true. And whenever the spread goes below its rolling mean by one standard deviation, we’ll go long on the spread.

Mind that the meaning of the orange and blue signals depends on whether tf variable is smaller or larger than the built-in timeframe.multiplier variable, i.e. tf of the chart.

For details see https://analyticsprofile.com/algo-tradin...

Donate: PayPal (paypal.me)

Sep 04
發布通知: Added 4 more distance measures.
Sep 04
發布通知: Added Mahalanobis distance measure.
Sep 04
發布通知: Minor fix.
Sep 04
發布通知: Minor fix - typos and norm function.
Sep 04
發布通知: Minor fix.
從喜愛的腳本中移除 添加到喜愛的腳本
Donate: PayPal (paypal.me)
this one is fum…!

small typo on line 68, Manhatten needs to be Manhattan
on line 80, need to remove the white space on Correl. change "Correl " to "Correl"
回覆
capissimo kocurekc
@kocurekc, thx)
回覆
Aweesome stuff buddy! Thanks for this!
回覆
@nilux, glad to hear that.) thx.
回覆
首頁 股票篩選器 外匯篩選器 加密貨幣篩選器 全球財經日曆 節目 如何運作 圖表功能 價格 網站規則 版主 網站 & 經紀商解決方案 小工具 圖表解決方案 輕量圖表庫 幫助中心 推薦朋友 功能請求 部落格 & 新聞 常見問題 維基 推特
概述 個人資料設定 賬戶和賬單 推薦朋友 我的客服工單 幫助中心 發表的想法 粉絲 正在關注 私人訊息 在線聊天 登出