股票量化軟體 燭台方向統計再現的研究

2023-07-20 21:31:31 字數 5604 閱讀 8396

首先我們要在某些條款上達成一致。 儘管這些條款是常用的,但我們還是要再過一遍,避免曲解。 如果燭台的開盤價小於**價 - 則被稱為上公升燭(在給出的圖形中,它們均塗以白色),反之則為下降燭,均塗以黑色。 如果開盤價等於**價,這些燭台將被稱為等價燭台(我自己的術語)。 如果***了一段時間,則這段時間是**趨勢,反之則為**趨勢。

我們看一看**:

編輯。

編輯。圖 1 usdjpy 的 4 小時時間範圍的燭台圖,時間範圍為 2009 年 11 月 20 日至 2009 年 12 月 8 日。

如圖 1 中所示,如果是**趨勢,則形成此趨勢的燭台大部分是**的,如果是**趨勢,則燭台也是**的。 如果是橫向的,則燭台也會不停變換其方向。赫茲量化軟體。

實際上,我們的問題是確定燭台中是否有再現情況,以及它相對於趨勢的變更會作出怎樣的反應。赫茲量化軟體。

當然,所有這些都可以手動完成,例如我們可以採用小時圖或任何其他型別的圖,在紙上寫下燭台方向,並相互比較一段時間。 工作有很多,但都能完成。 不過我們還有 mql4 程式語言這個神奇的工具,我們可以用它輕鬆建立 expert advisor,它將自己進行所有計算並告知我們計算結果的所有相關資訊。

所以,我們要做的是:

首先我們必須能夠指定乙個感興趣的時間段。 15 分鐘燭台是不太可能有的,因為在過去幾年,每天在 7 點 15 分時百分百是**趨勢。 然而,因為這種情況發生的概率雖小但仍存在,所以我們必須能夠至少對過去六個月的時段測試這種情況。

第二,最好是能夠了解所研究期間有多少燭台是上公升燭,有多少是下降燭。 你必須同意這一點:如果在過去 10 天內,在 18:00 開啟的小時燭台上公升了 6 次,下降了 4 次,則此資訊不太可能會給我們提供重要的參考。 現在,如果 10 次中有 9 次下降,則此資訊需被納入考慮範圍,用於確定今天 18:00 在哪個方向上建倉等。赫茲量化軟體。

第三,最好還能了解燭台開盤價和**價之間的平均差距,以及它們在給定時段內的平均高度。

第四,我們應能夠在不同時間範圍上執行我們的計算。赫茲量化軟體。

所有這些都可在給出的指令碼的外部變數script_statistics_candles 中定義

現在看看下圖。

編輯。圖 2 指令碼的輸入引數。

圖 2 顯示可在指令碼中更改的輸入引數。

open_session- 研究時段的開始時間。

close_session -研究時段的結束時間。

period_time- 指令碼考慮燭台再現可能性時所處的時間範圍。 可取以下值之一。 請記住這些值,其他值都不是允許值。 相應地,這些值對應於 5 分鐘、15 分鐘、30 分鐘、1 小時和 4 小時的圖形週期。

下面是指令碼**。我在**中新增了盡可能多的注釋,因為我自己也在學習一本關於 mql4 的教材,並且經常求助於此**上的 expert advisor,尤其是帶詳細注釋的 expert advisor。 應該承認,對於剛接觸 mql4 的新手來說,此**上的任何文章(除了其他東西)都有教學價值。

//+script_statistics_candles_v2.mq4 |/copyright © 2009, igor aleksandrov |/[email protected] |/#property copyright "copyright © 2009, igor aleksandrov"#property link "[email protected]"#property show_inputs//-input parameter***tern string open_session ="2009.11.20"; date of the opening of the studied session extern string close_session = 2009.11.26"; date of the closing of the studied sessionextern int period_time = 60; /period of the graph on which the expert advisor will be working, /can take the value of 5;15;30;60;240//-int day_bars_i; /number for i bar in sessiondouble mas_vira_maina[24,60]=,declare an array for bars with an equal opening-closing price mas_vira[24,60]=,declare an array for calculating bullish bars mas_maina[24,60]=,declare an array for calculating bearish bars mas_kol_vo[24,60]=,declare an array for calculating the number of the counted bars mas_profit[24,60]=,declare an array of the calculation of profit by open-close mas_h_l[24,60]=;declare an array of calculating the profit by high-lowstring symb; /name of the financial. instrument on which the script is executedbool new_day = false; /flag of the new day//-starting---int start() else //otherwise, request the opening price of the i-th bar open_bars_price= iopen( symb, period_time,i); request the closing price of the i-th bar close_bars_price=iclose( symb, period_time,i); request the minimum price of the i-th bar low_bars_price=ilow( symb, period_time,i); request the maximum price of the i-th bar high_bars_price=ihigh( symb, period_time,i); if the opening price of the bar is lower than the closing price, then the session is bullish if(open_bars_priceclose_bars_price) if the opening price is equal to the closing price, then session is undefined if(open_bars_price==close_bars_price) closing bracket of the bar search cycle//-print the information to the expert advisor journal---print("processed - total_day," days; "total_bars," bars, period ",period_time," minutes");for (int h=0; h<=23; h++)hours cycle mas_vira_maina[h,m]=0; /set to zero mas_vira[h,m]=0; /set to zero mas_maina[h,m]=0; /set to zero mas_kol_vo[h,m]=0; /set to zero mas_profit[h,m]=0; /set to zero mas_h_l[h,m]=0; /set to zero } end of the minute cycle} /end of the hour cycle print("-script completed the work --return(0); general closing bracket
如你所見,我宣布了六個正在計算的全域性級陣列。

double mas_vira_maina[24,60]=,declare the bar array with an equal price of opening-closingmas_vira[24,60]=,declare the array for calculating the bullish barsmas_maina[24,60]=,declare the array for calculating the bearish barsmas_kol_vo[24,60]=,declare the array for calculating the number of counted barsmas_profit[24,60]=,declare the array for calculating the profit for open-closemas_h_l[24,60]=;declare the array for calculating the profit for high-low
我們將把條柱計數記錄到mas_kol_vo緩衝區中。 這麼做的理由。 看起來,建倉-平倉和最**-最低價的單元格陣列的值能被計數天數除,尤其是**中有計數器時 -total_day。 但我在處理指令碼的過程中碰到了乙個問題,即歷史記錄中缺少某些條柱,因此結果看上去非常有趣。 例如,所獲得的某些條柱的高度完全是不現實的。赫茲量化軟體。

注釋中可以很明顯地看出剩餘陣列的用途。赫茲量化軟體。

實際上現在要檢查不同趨勢方向時的條柱的可重複性。 為此,讓我們以 usdjpy 的小時圖為例,如圖 1 中所示。 我們可以看到,在 2009 年 11 月 20 日至 2009 年 11 月 26 日這段時間內,圖中呈**趨勢;從 2009 年 11 月 26 日至 2009 年 12 月 2 日,呈橫盤趨勢;從 2009 年 12 月 2 日至 2009 年 12 月 8 日,圖中表現出**趨勢。赫茲量化軟體。

讓我們檢查這段時間內是否有重複燭台,如果有,則算出其變更方向。赫茲量化軟體。

將指令碼設定為小時圖。 對於不明白怎麼做的讀者,我會提供更詳細的說明。 將指令碼script_statistics_candles_v2.mq4**到資料夾 \program files\terminalname\expert\scripts 中。 複製。 指令碼顯示在「瀏覽器」視窗的左下角。 看起來就像這樣:

編輯。赫茲量化軟體。

如果你用滑鼠將指令碼從此視窗拖動到終端視窗,你將看到乙個屬性視窗 - 圖 2. 指定計算的開始和結束日期。赫茲量化軟體。

期貨股票量化交易軟體 赫茲量化軟體

螢火蟲演算法 firefly algorithm,fa 是一種模擬自然界螢火蟲交配行為的啟發式優化。演算法。自然界的螢火蟲通過發光來吸引同伴,並且光線越亮的螢火蟲更容易吸引其他螢。火蟲。這一啟示被廣泛運用於解決各種優化問題,例如函式優化 組合優化等。螢火蟲演算法概述。螢火蟲演算法基於以下三個關鍵行為...

股票量化軟體 資訊的儲存和閱覽

就像我說的那樣,print 函式在記錄ea交易執行時生成的資訊時並不總是那麼方便。特別是當有幾個ea交易同時在乙個相同終端上執行時就更加明顯。每個ea交易都把它自己的資訊寫到記錄檔案中,這樣就很難在其中找東西了。這種情況下,對此類資訊的分析就不用提了 這非常費力和麻煩。赫茲量化軟體。這個問題可以用比...

期貨股票量化交易軟體 高頻交易策略

在金融領域,隨著技術的迅速發展,高頻交易 hft 已成為乙個熱門話題。它涉及利用極高速度和複雜的演算法在微秒或毫秒級別進行交易,目標是從小的 差異中獲利。在這篇文章中,我們將深入 高頻交易策略的核心特點 實施方式以及相關爭議。一 什麼是高頻交易?高頻交易是一種演算法交易,它涉及大量的訂單在極短的時間...