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)

릴리즈 노트: Added 4 more distance measures.
릴리즈 노트: Added Mahalanobis distance measure.
릴리즈 노트: Minor fix.
릴리즈 노트: Minor fix - typos and norm function.
릴리즈 노트: Minor fix.
즐겨찾기 스크립트에서 빼기 즐겨찾기 스크립트에 넣기
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.
응답
홈으로 스탁 스크리너 포렉스 스크리너 크립토 스크리너 이코노믹 캘린더 사용안내 차트 특징 프라이싱 하우스룰(내부규정) 모더레이터 웹사이트 & 브로커 솔루션 위젯 차팅 솔루션 도움 받기 기능 개발/개선 요청 블로그 & 뉴스 잦은물음 위키 트위터
프로화일 프로화일설정 계정 및 빌링 트레이딩뷰 코인 나의 서포트 티켓 도움 받기 공개아이디어 팔로어 팔로잉 비밀메시지 채팅 로그아웃