最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

量化軟件下載: 赫茲量化開發(fā)多品種指標分析價格偏離

2023-08-01 13:10 作者:大牛啊呢  | 我要投稿

指標開發(fā)

下一步進行指標編程。首先我們需要創(chuàng)建一個新項目。為此, 在 赫茲量化\MQL5\Indicators 目錄中創(chuàng)建與我們的指標同名的文件夾, 并在 Include 文件夾中我們會放置包含文件。下一步, 在指標文件夾中創(chuàng)建主文件??梢酝ㄟ^手工創(chuàng)建帶有 *.mq5 后綴的文本文件,或使用 MQL5 向?qū)?的模板。加上程序核心函數(shù) OnInit(), OnDeinit()OnCalculate() , 我們還使用了 OnChartEvent() 以及 OnTimer()。

就像在之前的文章中, 加上當前品種,我們將顯示外部參數(shù)中指定的五個品種。但此時, 替代某些公式的計算數(shù)值, 我們將在圖表上輸出原始價格數(shù)據(jù)。用戶可在外部參數(shù)的下拉列表中自由選擇呈現(xiàn)的數(shù)據(jù)類型: 折線, 柱線 或 蠟燭條。

如果我們打算就顯示單色數(shù)據(jù)線, 那么指定緩存區(qū)數(shù)量等于指標屬性中的品種數(shù)量就足夠了。 (#property). 但既然此處有兩種模式來繪制序列作為柱線或蠟燭條, 我們就需要更多的緩存區(qū)用于雙色模式: 絲瓜緩存區(qū)來渲染每個序列,并用一個緩存區(qū)來為每一個圖形序列元素設(shè)置顏色(依據(jù)條件)。

對于每個序列,它需要在程序?qū)傩詨K中指定顏色。為此,簡單地將它們列出清單,并用逗號分隔。第一個顏色用于單色模式。在雙色模式中, 它用于陽線。第二個顏色用于雙色模式中的陰線。

所有這些參數(shù)的代碼提供如下:

#property indicator_chart_window // Indicator is in the main window #property indicator_buffers 25 ? // Number of buffers for indicator calculation #property indicator_plots ? 5 ? ?// Number of plotting series //--- Indicator buffers colors #property indicator_color1 ?clrDodgerBlue,C'0,50,100' #property indicator_color2 ?clrLimeGreen,C'20,80,20' #property indicator_color3 ?clrGold,C'160,140,0' #property indicator_color4 ?clrAqua,C'0,140,140' #property indicator_color5 ?clrMagenta,C'130,0,130'

使用 #define 語句可以聲明常量,并且使用 #include 命令行可以包含已經(jīng)在上邊描述的函數(shù)文件, 以及來自 標準庫 的畫布類:

//--- Constants #define RESET ? ? ? ? ? 0 // Returning the indicator recalculation command to the terminal #define SYMBOLS_COUNT ? 5 // Number of symbols //--- Include the class for working with the canvas #include <Canvas\Canvas.mqh> //--- Include the class for working with the canvas #include "Include/Checks.mqh" #include "Include/Chart.mqh" #include "Include/Objects.mqh"

加入 ENUM_DRAWTYPE 和 ENUM_START_POINT 枚舉來創(chuàng)建用于外部參數(shù)的下拉列表,以便選擇價格數(shù)據(jù)繪制類型,和價格偏離模式的起始點數(shù):

//--- Drawing type of the price data enum ENUM_DRAWTYPE ?{ ? LINE ? =0, ?// Line ? BARS ? =1, ?// Bars ? CANDLES=2 ? // Candlesticks ?}; //--- Mode of the price divergence starting point enum ENUM_START_POINT ?{ ? VERTICAL_LINE=0, ?// Vertical line ? MONTH ? ? ? ?=1, ?// Month ? WEEK ? ? ? ? =2, ?// Week ? DAY ? ? ? ? ?=3, ?// Day ? HOUR ? ? ? ? =4 ? // Hour ?};

數(shù)據(jù)渲染類型已經(jīng)在前面描述過, 現(xiàn)在讓我們來說說價格偏離起始點數(shù)的含義。

總共此處有五種模式: 垂直線, 月線, 周線, 日線 和 小時線。對于 垂直線 模式, 當在圖表中加載指標時會加入一條垂直線。您可以拖拽此線到指定柱線,此處所有品種的價格將會匯聚到一點。當前品種指定柱線的開盤價格將會作為這次匯聚的參考點。任何其它模式將告知程序,每次價格將在指定周期的開始匯聚。即,在每月的開始, 在每周的開始, 在每天的開始或在每小時的開始。

以下您可以發(fā)現(xiàn)指標的輸入?yún)?shù)列表:

//--- External parameters input ?ENUM_DRAWTYPE ? ?DrawType ? ? ? ? ? ? =CANDLES; ? ? ? // Drawing type input ?ENUM_START_POINT StartPriceDivergence =VERTICAL_LINE; // Start of price divergence input ?bool ? ? ? ? ? ? TwoColor ? ? ? ? ? ? =false; ? ? ? ? // Two-color bars/candlesticks sinput string dlm01=""; //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - input ?string ? ? ? ? ? Symbol02 ? ? ? ? ? ? ="GBPUSD"; ? ? ?// Symbol 2 input ?bool ? ? ? ? ? ? Inverse02 ? ? ? ? ? ?=false; ? ? ? ? // Inverse symbol 2 input ?string ? ? ? ? ? Symbol03 ? ? ? ? ? ? ="AUDUSD"; ? ? ?// Symbol 3 input ?bool ? ? ? ? ? ? Inverse03 ? ? ? ? ? ?=false; ? ? ? ? // Inverse symbol 3 input ?string ? ? ? ? ? Symbol04 ? ? ? ? ? ? ="NZDUSD"; ? ? ?// Symbol 4 input ?bool ? ? ? ? ? ? Inverse04 ? ? ? ? ? ?=false; ? ? ? ? // Inverse symbol 4 input ?string ? ? ? ? ? Symbol05 ? ? ? ? ? ? ="USDCAD"; ? ? ?// Symbol 5 input ?bool ? ? ? ? ? ? Inverse05 ? ? ? ? ? ?=false; ? ? ? ? // Inverse symbol 5 input ?string ? ? ? ? ? Symbol06 ? ? ? ? ? ? ="USDCHF"; ? ? ?// Symbol 6 input ?bool ? ? ? ? ? ? Inverse06 ? ? ? ? ? ?=false; ? ? ? ? // Inverse symbol 6

品種數(shù)量從 2 開始, 因為 1 是當前圖表品種。

可以對每個包含的品種進行翻轉(zhuǎn)。翻轉(zhuǎn)意即品種數(shù)據(jù)將會被上下顛倒。這很有用,當分析品種列表中的貨幣對含有相同貨幣 (例如, 美元) 則它們就有了同樣的基準。例如, 在 EURUSD 貨幣對中, 美元是基準貨幣, 在 USDCHF 貨幣對中也可以作為基準。如果圖表中的當前品種是 EURUSD, 那么您翻轉(zhuǎn) USDCHF, 其呈現(xiàn)結(jié)果將更便于您的分析。

以下是全局變量和數(shù)組列表:

//--- Structure of the indicator buffers arrays struct buffers ?{ ? double ? ? ? ? ? ?open[]; ? // Open prices buffer ? double ? ? ? ? ? ?high[]; ? // High prices buffer ? double ? ? ? ? ? ?low[]; ? ?// Low prices buffer ? double ? ? ? ? ? ?close[]; ?// Close prices buffer ? double ? ? ? ? ? ?icolor[]; // Buffer to determine the color of element ?}; buffers ? ? ? ? ? buffer_data[SYMBOLS_COUNT]; //--- Load the class CCanvas ? ? ? ? ? canvas; //--- Variables/arrays for copying data from OnCalculate() int ? ? ? ? ? ? ? OC_rates_total ? ? =0; // Size of input time series int ? ? ? ? ? ? ? OC_prev_calculated =0; // Bars processed at the previous call datetime ? ? ? ? ?OC_time[]; ? ? ? ? ? ? // Opening time double ? ? ? ? ? ?OC_open[]; ? ? ? ? ? ? // Open prices double ? ? ? ? ? ?OC_high[]; ? ? ? ? ? ? // High prices double ? ? ? ? ? ?OC_low[]; ? ? ? ? ? ? ?// Low prices double ? ? ? ? ? ?OC_close[]; ? ? ? ? ? ?// Close prices long ? ? ? ? ? ? ?OC_tick_volume[]; ? ? ?// Tick volumes long ? ? ? ? ? ? ?OC_volume[]; ? ? ? ? ? // Real volumes int ? ? ? ? ? ? ? OC_spread[]; ? ? ? ? ? // Spread //--- For the purpose of storing and checking the time of the first bar in the terminal datetime ? ? ? ? ?series_first_date[SYMBOLS_COUNT]; datetime ? ? ? ? ?series_first_date_last[SYMBOLS_COUNT]; //--- Time array of the bar from which we will start drawing datetime ? ? ? ? ?limit_time[SYMBOLS_COUNT]; //--- Symbol names array string ? ? ? ? ? ?symbol_names[SYMBOLS_COUNT]; //--- Array of symbol inverse flags bool ? ? ? ? ? ? ?inverse[SYMBOLS_COUNT]; //--- Colors of indicator lines color ? ? ? ? ? ? line_colors[SYMBOLS_COUNT]={clrDodgerBlue,clrLimeGreen,clrGold,clrAqua,clrMagenta}; //--- String representing the lack of the symbol string ? ? ? ? ? ?empty_symbol="EMPTY";



量化軟件下載: 赫茲量化開發(fā)多品種指標分析價格偏離的評論 (共 條)

分享到微博請遵守國家法律
松溪县| 孟连| 彭阳县| 桂林市| 堆龙德庆县| 赫章县| 香港 | 江永县| 高密市| 翁源县| 揭阳市| 赤水市| 同心县| 津市市| 谷城县| 米易县| 巫山县| 新蔡县| 沅江市| 教育| 林西县| 油尖旺区| 沾益县| 海丰县| 大名县| 永定县| 黄骅市| 措美县| 南漳县| 中江县| 克山县| 习水县| 齐齐哈尔市| 元江| 孟连| 大城县| 手游| 鱼台县| 昭觉县| 昔阳县| 社旗县|