開拓者1分鐘圖里面取道5分鐘的數據的均線 源碼[開拓者公式]
- 內容: 使用環境:
基本數據源為1分鐘,通過DataConvert可以轉化為對應的5分鐘數據,有些朋友希望能夠在1分鐘圖里面取道5分鐘的數據的均線,效果要和單獨使用5分鐘的均線一樣。為此,提供以下函數。
1、新建一個用戶函數,TransMinsData,返回值為數值型。
參數1:要計算的數據源。
參數2:想按N分鐘來處理,本例是5分鐘,不能大于60。
參數3:希望取多少個N分鐘前的數據。- Params
- NumericSeries Price(1);
- Numeric nMinSet(5);
- Numeric MinsAgo(2);
- Vars
- NumericSeries barCnt;
- NumericSeries MinData;
- Numeric i;
- Numeric j;
- Numeric nIndex(0);
- Begin
- If(IntPart(Minute%nMinSet)==0)
- {
- barCnt = 1;
- }Else
- {
- barCnt = barCnt[1] + 1;
- }
- MinData = Price;
- If(MinsAgo == 0)
- {
- return MinData;
- }Else
- {
- For i = 1 To MinsAgo
- {
- If( i == 1)
- {
- j = 0;
- }Else
- {
- j = j + BarCnt[j];
- }
- If (j > CurrentBar ) Return InvalidNumeric;
- nIndex = nIndex + BarCnt[j];
- }
- Return MinData[nIndex];
- }
- End
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯系技術人員 QQ: 262069696 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容