簡體   English   中英

無法使用#property嚴格進行迭代

[英]Can't make iteration with #property strict

我的這段代碼正常工作。 基本上,此代碼是每5分鍾顯示五個前柱上的移動平均線的值。 MA的當前值被忽略。

int     TrendMinDurationBar = 5,
        SlowPeriod          = 14,
        FastPeriod          = 7;

void OnTick()
{
    if ( NewBar( PERIOD_M5 ) == true ) MA( PERIOD_M5 );
}

void MA( int TF )
{
    double Slow[], Fast[];
    ArrayResize( Slow, TrendMinDurationBar + 1 );
    ArrayResize( Fast, TrendMinDurationBar + 1 );

    for (  int i = 1; i <= TrendMinDurationBar; i++ )
    {      Slow[i] = NormalizeDouble( iMA( Symbol(), TF, SlowPeriod, 0, MODE_EMA, PRICE_OPEN, i ), Digits );
           Fast[i] = NormalizeDouble( iMA( Symbol(), TF, FastPeriod, 0, MODE_EMA, PRICE_OPEN, i ), Digits );
           Alert( "DataSlow" + ( string )i + ": " + DoubleToStr( Slow[i], Digits ) );
    }
}

bool NewBar( int TF )
{
    static datetime lastbar = 0;
           datetime curbar  = iTime( Symbol(), TF, 0 );

    if (  lastbar != curbar )
    {     lastbar  = curbar; return( true );
    }
    else                     return( false );
}

當包含#property strict ,代碼在編譯后僅工作一次。 M5圖表上的新條形存在后,不會進行任何迭代。

如果我堅持使用#property strict怎么辦?

歡迎來到另一個New MQL4.56789抓住22

我的求職者來自Help > MQL4 Reference > Updated MQL4

這個(列[New MQL4 with #property strict]

任何類型的函數都應返回一個值

還有一個需要回顧的問題,即使是static double替代,代碼也只會丟失邏輯,在這種情況下,效率極低:

退出{}塊時釋放局部數組


在MT4 Build 950中與#property strict作為EA完美配合使用。

您確定要以EA而非腳本或指標的形式運行它嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM