- Katılım
- 23 Eki 2020
- Mesajlar
- 1,828
In "Daytrading Stock Pairs" in this issue, Mark Conway and Aaron Behle discuss volatility bands and spread values. These indicators can be easily recreated in MetaStock. To create an indicator in MetaStock, select "Indicator Builder" from the Tools menu, click "New," enter the code for the indicator, and then click OK. The following code is for MetaStock Professional 7.0. |
|
Spread & Volatility hv1:=Input("30 day historical volatility of first security",0,100,0.5); hv2:=Input("30 day historical volatility of second security",0,100,0.5); r:=Input("correlation coefficient of these securities",0,100,0.5); vf:=Input("volatility factor",0,5,1.5); p1:= Security("ATVI", C ); p2:= Security("THQI", C ); {For MetaStock 6.52 or end-of-day users, change the above two lines to: p1:= p; p2:= C; This version is more readily adaptable to any security pair, but it requires more care in plotting it. The modified version requires you to insert the prices of the one security into the chart of the other. Then you must plot this indicator on the prices you just inserted.) To continue with the code: } newday:=ROC(DayOfWeek(),1,$)<>0; yp1:=ValueWhen(1,newday, Ref(p1,-1)); yp2:=ValueWhen(1,newday, Ref(p2,-1)); sprd:= (p1/yp1) - (p2/yp2); vb:=(hv1 + hv2) * Power(1/252,0.5) * (1-r); sprd; vb*vf; Neg(vb*vf) |
To plot the indicator, locate it in MetaStock's Indicator Quicklist, then click and drag it onto the desired chart. --William Golson, Equis International www.equis.com | |
| |
Source / From: |