TWAP (Time-Weighted Average Price) is an algorithmic trade execution strategy that aims to achieve an average execution price close to the time-weighted average price of the user-specified period. A TWAP strategy is often used to minimize a large order’s impact on the market by dispersing the large order into smaller quantities and executing them at regular intervals over time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
y1 = (open[1]+close[1]+high[1]+low[1])/4 y2 = (open[2]+close[2]+high[2]+low[2])/4 y3 = (open[3]+close[3]+high[3]+low[3])/4 y4 = (open[4]+close[4]+high[4]+low[4])/4 y5 = (open[5]+close[5]+high[5]+low[5])/4 y6 = (open[6]+close[6]+high[6]+low[6])/4 y7 = (open[7]+close[7]+high[7]+low[7])/4 y8 = (open[8]+close[8]+high[8]+low[8])/4 y9 = (open[9]+close[9]+high[9]+low[9])/4 y10 = (open[10]+close[10]+high[10]+low[10])/4 y11 = (open[11]+close[11]+high[11]+low[11])/4 y12 = (open[12]+close[12]+high[12]+low[12])/4 y13 = (open[13]+close[13]+high[13]+low[13])/4 y14 = (open[14]+close[14]+high[14]+low[14])/4 y15 = (open[15]+close[15]+high[15]+low[15])/4 y16 = (open[16]+close[16]+high[16]+low[16])/4 y17 = (open[17]+close[17]+high[17]+low[17])/4 y18 = (open[18]+close[18]+high[18]+low[18])/4 y19 = (open[19]+close[19]+high[19]+low[19])/4 y20 = (open[20]+close[20]+high[20]+low[20])/4 TWAP = (Y1+Y2+Y3+Y4+Y5+Y6+Y7+Y8+Y9+Y10+Y11+Y12+Y13+Y14+Y15+Y16+Y17+Y18+Y19+Y20)/20 d = 200 DER= STD[d] (TWAP) TWAPup1 = TWAP + DER TWAPup2 = TWAP + (DER*2) TWAPup3 = TWAP + (DER*3) TWAPdown1 = TWAP - DER TWAPdown2 = TWAP - (DER*2) TWAPdown3 = TWAP - (DER*3) RETURN TWAP as "TWAP",TWAPup1 as "dérivé+1",TWAPup2 as "dérivé+2",TWAPup3 as "dérivé+3",TwapDOWN1 as "dérivé-1",TWAPdown2 as "dérivé-2",TWAPdown3 as "dérivé-3" |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials