【TeeChart Pro ActiveX教程】(七):使用函數(上)
功能類型
1 功能特點
TeeChart Pro功能是一個系列,幾乎可以是任何系列類型,應用代數函數,數據源是另一個圖表系列。 所有函數都派生自Teefunction類并繼承TeeFunction的Period屬性。
TeeChart Pro提供以下預定義功能列表:
功能類型 | 投入數量 | 描述 |
標準 | ||
Add | Unlimited | 繪制輸入總和 |
Subtract | Unlimited | 繪圖的輸入值按包含的降序減去 |
Multiply | Unlimited | 乘法函數繪制輸入值的乘積 |
Divide | Unlimited | 分割函數繪制輸入按包含的降序劃分 |
High | Unlimited | 高功能繪制高輸入點 |
Low | Unlimited | 低功能繪制低輸入點 |
Average | Unlimited | 平均函數將計算每組Period點的平均值 |
Y=F(X) | None | 繪制用戶定義的函數 |
Count | Unlimited | 計算圖表中的系列點數 |
Extended | ||
Smoothing | 1 | 創建了一條平滑的線,連接來自給定源系列的點 |
Exponential Average | 1 | 基于權重的指數平均值 |
Standard Deviation | 1 | 映射每組Period點的標準偏差(或完全標準差) |
Root Mean Square | 1 | (RMS) Result = Sqrt( Sum( Square(Value) ) ) / NumValues ) |
Cross Points | Unlimited | 兩個Line系列相互交叉的亮點 |
Peformance | 1 | 從一個系列點到下一個系列點的百分比變化 |
Curve Fitting | 1 | 使用TypeFitting公式通過數據輸入繪制曲線 |
Trend | 1 | 通過輸入系列點繪制最佳趨勢線 |
Exponential Trend | 1 | 指數加權的趨勢 |
Cumulative | Unlimited | 根據輸入的累積值構造一條線 |
Financial | ||
ADX | 1 | 金融功能,平均方向變化 |
R.S.I. | 1 | RSI = 100.0 - ( 100.0 / ( 1.0 + Abs( Ups / Downs ) ) ) |
Moving Average | 1 | 移動平均線功能將計算每組周期點的簡單或加權平均值 |
Exponential Moving Average | 1 | 使用以下公式: FP = 2 / ( Period + 1 ) |
Momentum | 1 | 每個Y值是當前點的Y值減去最后一個Period點的Y值 |
Momentum Division | 1 | 與先前'第n'值相比的價值比率 |
MACD | 1 | 財務功能。移動平均收斂分歧 |
Stochastic | 1 | 財務功能。計算給定時期內的最高值和最低值 |
Bollinger | 1 | 財務功能。使用移動平均線(可能是指數)和標準差 |
Compression | 1 | 計算日期時間段內源系列的最高值和最低值 |
Closed Location Value | 1 | CLV = ( (Close-Low)-(High-Close))/(High-Low) |
On Balance Volume | 1 | 對于OHLC系列中的每個點,將收盤價與開盤價進行比較。如果Close更高,則添加該點的Volume值。如果關閉較低,則降低音量值。 |
Commodity Channel Index | 1 | 財務指標用于識別商品的周期性轉向 |
Volume Oscillator | 1 | 計算兩個指數移動平均線之間的差異(a - b) |
多種函數類型僅支持一個輸入系列。但是,可以鏈接鏈接函數,例如,將圖表中多個系列的平均值創建為平均函數系列,然后使用平均函數作為趨勢函數的輸入來標識平均值的趨勢。
2 添加功能
使用圖表編輯器,在“第一個圖表”頁面上,選擇“Add”按鈕,就像將新系列添加到圖表一樣。在TeeChart Gallery中,選擇Functions選項卡以選擇所需的功能。每個功能都顯示為一個系列,您可以稍后通過選擇第一個圖表頁面上的更改按鈕來更改與該功能關聯的系列類型。之后,在函數系列的“Datasource”頁面上可以輕松更改函數定義。在這里,同樣容易,您可以將已添加到Chart的正常Series的定義更改為Function的定義(Function實際上是數據源的定義,而不是Series Type的定義)。
下圖顯示了編輯函數時的“Datasource”頁面。線系列(名稱“Series1”,標題“平均”)被定義。數據源頁面底部的左側列表框顯示了可用于輸入的圖表中的其他系列(此處為“Series0”)。
假設我們從一個完全空的Chart開始,這里是代碼中用于構建簡單的Series-Function相關Chart的步驟。
With TChart1 'Add 2 data Series .AddSeries scBar .AddSeries scBar ' Populate them with data (here random) .Series(0).FillSampleValues 10 .Series(1).FillSampleValues 10 ' Add a series to be used for an Average Function .AddSeries scLine 'Define the Function Type for the new Series .Series(2).SetFunction tfAverage 'Define the Datasource for the new Function Series 'Datasource accepts the Series titles of the other 2 Series .Series(2).DataSource = "Series0,Series1" ' *Note - When populating your input Series manually you will need to ' use the Checkdatasource method ' - See the section entitled 'Defining a Datasource' 'Change the Period of the Function so that it groups averages 'every 2 Points .Series(2).FunctionType.Period = 2 End With
我們可以添加另一個函數來告訴我們有關前一個函數的信息
With TChart1 'Add another Series to be used for a 2nd Function .AddSeries scLine 'Define the Function Type for the new Series .Series(3).SetFunction tfHigh 'Define the Datasource for the new Function Series 'Use the existing Function (Series2) as input .Series(3).DataSource = "Series2" 'Leave the Period at default 0 (No Period set) to draw 'A line at Highest of all points of the Average Function End With
購買TeeChart Pro AciveX正版授權,請點擊“”喲!