COCO研究院

 找回密碼
 註冊
搜索
查看: 3317|回復: 7

語法請教

[複製鏈接]
發表於 15-8-11 22:15 | 顯示全部樓層 |閱讀模式
以下是MC內置的bollinger band語法:

inputs:
        BollingerPrice( Close ),
        TestPriceUBand( Close ),
        TestPriceLBand( Close ),
        Length( 20 ),
        NumDevsUp( 2 ),
        NumDevsDn( -2 ),
        Displace( 0 ) ;

variables:
        var0( 0 ),
        var1( 0 ),
        var2( 0 ),
        var3( 0 ) ;

var0 = AverageFC( BollingerPrice, Length ) ;
var1 = StandardDev( BollingerPrice, Length, 1 ) ;
var3 = var0 + NumDevsUp * var1 ;
var2 = var0 + NumDevsDn * var1 ;

condition1 = Displace >= 0 or CurrentBar > AbsValue( Displace ) ;
if condition1 then
        begin
        Plot1[Displace]( var3, "UpperBand" ) ;
        Plot2[Displace]( var2, "LowerBand" ) ;
        Plot3[Displace]( var0, "MidLine" ) ;

                         
        if Displace <= 0 then
                begin
                condition1 = TestPriceLBand crosses over var2 ;
                if condition1 then
                        Alert( "Price crossing over lower price band" )
                else
                begin
                condition1 = TestPriceUBand crosses under var3 ;
                if condition1 then
                        Alert( "Price crossing under upper price band" ) ;
                end;
                end ;
        end ;

我想寫"上通道減下通道"
我用X=testpriceuband(close)[1]-testpricelband(close)[1]
及XX=testpriceuband(close)[0]-testpricelband(close)[0]
但compile不到, 請問應該怎寫?


發表於 15-8-11 22:20 | 顯示全部樓層
我用X=testpriceuband(close)[1]-testpricelband(close)[1]
及XX=testpriceuband(close)[0]-testpricelband(close)[0]

山不轉路轉

AA=testpriceuband(close)
BB=testpricelband(close)

所以

X=AA[1]-BB[1]
XX=AA-BB

其實

X=XX[1] ?

 樓主| 發表於 15-8-11 23:08 | 顯示全部樓層
pcking2008 發表於 15-8-11 22:20
我用X=testpriceuband(close)[1]-testpricelband(close)[1]
及XX=testpriceuband(close)[0]-testpricelband ...

用這方法都是做不了:
------ Compiled with error(s): ------
Unknown Function
line 56, column 0

發表於 15-8-11 23:11 | 顯示全部樓層
lahahaha 發表於 15-8-11 23:08
用這方法都是做不了:
------ Compiled with error(s): ------
Unknown Function

前兩行是你的原始程式...我只是複製..


發表於 15-8-12 08:27 | 顯示全部樓層

var0 = AverageFC( BollingerPrice, Length ) ; 布林中線
var1 = StandardDev( BollingerPrice, Length, 1 ) ; 標準差
var3 = var0 + NumDevsUp * var1 ;  { 上通道 = 布林中線 + 2個標準差}
var2 = var0 + NumDevsDn * var1 ;  { 下通道  = 布林中線 - 2個標準差}

你想寫"上通道減下通道" = Var3 - Var2
發表於 15-8-12 08:34 | 顯示全部樓層
如果您只是在主程式內要計算通道寬度

Var : Bandwidth(0)

BandWidth = StandardDev( Close, Length, 1 ) * 4 { 4 代表上下各2個標準差 }
發表於 15-8-12 08:39 | 顯示全部樓層
對了~ [就是愛現 程式交易] 部落格內有好幾篇關於布林通道的相關策略應用範例可參考
 樓主| 發表於 15-8-17 22:45 | 顯示全部樓層
easytrader788 發表於 15-8-12 08:39
對了~ [就是愛現 程式交易] 部落格內有好幾篇關於布林通道的相關策略應用範例可參考 ...

謝謝, 立即去觀摩學習!!!
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-6-2 09:02

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 | AI繪圖AI超擬真美女AI beauty AI Stable DiffusionAI正妹AI Lookbook