COCO研究院

 找回密碼
 註冊
搜索
查看: 5334|回復: 1

(已解決)程式debug請教

[複製鏈接]
發表於 12-3-19 21:57 | 顯示全部樓層 |閱讀模式
本帖最後由 jiuhtsair 於 12-3-19 22:46 編輯

各位大大好:
       小弟想將CCI、布林通道與3個移動平均線放在一起做一個訊號,可是將此三個指標放在一起編譯時..它一直告訴我
           Keyword "Plot**" can't been used in this type of study
           errLine 0, errColumn 0, errLineEnd 0, errColumnEnd 0
           編譯錯誤:  (函數)

找的頭昏眼花...卻不知何處錯誤,懇請各位大大教導..謝謝!
程式碼如下:(標示黃色處即為power language顯示錯誤處)

//...........................Input.......................................
inputs:
// Bollinger Bands
    BollingerPrice( Close ),
    TestPriceUBand( Close ),
    TestPriceLBand( Close ),
    Length( 20 ),
    NumDevsUp( 2 ),
    NumDevsDn( -2 ),
    Displace( 0 ) ,

//CCI Average
    CCILength( 14 ),
    CCIAvgLength( 9 ),
    OverSold( -100 ),
    OverBought( 100 ) ,   
   
// Mov Average 3 Lines
    Price( Close ),
    FastLength( 4 ),
    MedLength( 9 ),
    SlowLength( 18 );
//    Displace_MovAv( 0 ) ;
//...................................Variable............................
variables:
    var0_Bollinger( 0 ),
    var1_Bollinger( 0 ),
    var2_Bollinger( 0 ),
    var3_Bollinger( 0 ) ,
    var4_cci( 0 ),
    var5_cci( 0 ) ,
    var6_MovAv( 0 ),
    var7_MovAv( 0 ),
    var8_MovAv( 0 ) ;

var0_Bollinger = AverageFC( BollingerPrice, Length ) ;
var1_Bollinger = StandardDev( BollingerPrice, Length, 1 ) ;
var3_Bollinger = var0_Bollinger + NumDevsUp * var1_Bollinger ;
var2_Bollinger = var0_Bollinger + NumDevsDn * var1_Bollinger ;

var4_cci = CCI( CCILength ) ;
var5_cci = Average( var4_cci , CCIAvgLength ) ;

Plot4( var4_cci, "CCI" ) ;
Plot5( var5_cci, "CCIAvg" ) ;
Plot6( OverBought, "OverBot" ) ;
Plot7( OverSold, "OverSld" ) ;

var6_MovAv = AverageFC( Price, FastLength ) ;
var7_MovAv = AverageFC( Price, MedLength ) ;
var8_MovAv = AverageFC( Price, SlowLength ) ;


// Bollinger Bands
condition1 = Displace >= 0 or CurrentBar > AbsValue( Displace ) ;
if condition1 then
    begin
    Plot1[Displace]( var3_Bollinger, "UpperBand" ) ;
    Plot2[Displace]( var2_Bollinger, "LowerBand" ) ;
    Plot3[Displace]( var0_Bollinger, "MidLine" ) ;

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

//CCI Average
condition2 = var5_cci crosses over OverSold ;
if condition2 then
    Alert( "Indicator exiting oversold zone" )
else
begin
condition2 = var5_cci crosses under OverBought ;
if condition2 then
    Alert( "Indicator exiting overbought zone" ) ;
end;

// Mov Average 3 Lines
condition3 = Displace >= 0 or CurrentBar > AbsValue( Displace) ;
if condition3 then
    begin
    Plot8[Displace]( var6_MovAv, "FastAvg" ) ;
    Plot9[Displace]( var7_MovAv, "MedAvg" ) ;
    Plot10[Displace]( var8_MovAv, "SlowAvg" ) ;
                     
    if Displace <= 0 then
        begin        
        Condition3 = Price > var6_MovAv and var6_MovAv > var7_MovAv and var7_MovAv > var8_MovAv ;
        if Condition3 and Condition3[1] = false then
            Alert( "Bullish alert" )
        else
            begin
            Condition4 = Price< var6_MovAv and var6_MovAv < var7_MovAv and var7_MovAv < var8_MovAv ;
            if Condition4 and Condition4[1] = false then
                Alert( "Bearish alert" ) ;
            end ;
        end ;
    end ;

   

 樓主| 發表於 12-3-19 22:39 | 顯示全部樓層
感謝meimeichen大的指導...
小弟把它當成函數編譯..因此產生錯誤...
將它改成指標重新編譯後就...ok了!
感謝!感謝!
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

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

GMT+8, 24-12-28 14:37

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 |