|
樓主 |
發表於 16-5-28 10:21
|
顯示全部樓層
本帖最後由 f29825604 於 16-5-28 10:25 編輯
自訂mc指標CCICXAverage
///////////////////////////
// eleader-fucntion
///////////////////////////
def cci(period) :
m1 = (h+l+c)/3
m2 = ma(m1, period)
d1 = array(len(m2) - period + 1)
for i in range(period) :
d1 = d1 + abs(m1 - m2)
d1 = d1 / period
return (m1-m2) / (0.015 * d1)
****************************
mc 內 CCIClassic[Buildin-Fucntion]
****************************
- Inputs: Len(NumericSimple);
- Variables: var0(0),var1(0),var2(0),var3(0), var4(0);
- If Len > 0 Then Begin
- var4 = (High + Low + Close) / 3;
- var3 = Average(var4 , Len);
- var2 = 0;
- for var1 = 0 to Len - 1 Begin
- var2 = var2 + AbsValue(var4[var1] - var3);
- End;
- var2 = var2 / Len;
- If var2 = 0 Then
- CCIClassic = 0
- Else
- CCIClassic = (var4 - var3) / (0.015 * var2);
- End
- Else
- CCIClassic = 0;
複製代碼 新增CCICXAverage指標
用原本mc指標CCI Average修改
- inputs:
- CCILength( 14 ),
- CCIAvgLength( 9 ),
- OverSold( -100 ),
- OverBought( 100 ) ;
- variables:
- var0( 0 ),
- var1( 0 ) ;
- var0 = CCIClassic( CCILength ) ;
- var1 = XAverage( var0, CCIAvgLength ) ;
- Plot1( var0, "CCIC" ) ;
- Plot2( var1, "CCIXAvg" ) ;
- Plot3( OverBought, "OverBot" ) ;
- Plot4( OverSold, "OverSld" ) ;
- condition1 = var1 crosses over OverSold ;
- if condition1 then
- Alert( "Indicator exiting oversold zone" )
- else
- begin
- condition1 = var1 crosses under OverBought ;
- if condition1 then
- Alert( "Indicator exiting overbought zone" ) ;
- end;
複製代碼 可以用
做紀錄
可查詢
Thanks!!
|
|