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

歡迎光臨散文網 會員登陸 & 注冊

量化軟件下載:赫茲量化中技術指標和數字濾波器

2023-07-31 17:22 作者:大牛啊呢  | 我要投稿

"External Data"(外部數據)按鈕允許使用來自 SAInpData 指標的數據。

原始數據包含代表濾波器內核的數組。我們將重制文件,以便其能夠將任何圖表指標傳遞至頻譜分析程序。修改后的指標提供自動和手動模式。在自動模式中,使用找到的第一個圖表指標。在手動模式中,用戶可在列表中設置一個子窗口和指標索引。在這種情況下,應手動將脈沖指標添加至圖表。此后,必要指標被應用以接收內核。

我們開始吧。我們應按照與脈沖相同的算法創(chuàng)建一個新的指標。添加輸入參數:

input bool Automatic=true; // Autosearch input int ?Window=0; ? ? ? // Subwindow index input int ?Indicator=0; ? ?// Indicator index

如果 Automatic=true,使用自動模式,同時忽略其他輸入參數。If Automatic=false,使用帶子窗口和指標索引的手動模式。

接下來,我們應在全局層面添加用于存儲句柄的整型變量。

int Impulse=0; // single impulse's handle int Handle=0; ?// required indicator's handle int Kernel=0; ?// filter kernel's handle

脈沖指標句柄存儲在 Impulse 中。指標的句柄 - 我們希望在頻譜分析程序中查看其內核 - 存儲在 Handle 中。基于脈沖指標構建的目標指標的句柄,或換言之目標指標的內核,存儲在 Kernel 中。


OnInit() 函數:

int OnInit() ?{ //--- indicator buffers mapping ? SetIndexBuffer(0,DataBuffer,INDICATOR_DATA); ? Impulse=iCustom(NULL,0,"SpecAnalyzer\\Impulse");//get the single impulse handle ? if(Impulse==INVALID_HANDLE) ? ? { ? ? ?Alert("Impulse initialization failed"); ? ? ? return(INIT_FAILED); ? ? } //--- ? return(0); ?}

由于脈沖指標在程序操作期間沒有發(fā)生變化,指標的句柄應在 OnInit() 函數中接收。還需要檢查句柄接收錯誤。如果失敗,"Impulse initialization failed"(脈沖初始化失?。┫@示,指標的操作通過 INIT_FAILED 鍵中斷。

OnDeinit() 函數:

void OnDeinit(const int reason) ?{ //--- delete the indicators ? IndicatorRelease(Impulse); ? IndicatorRelease(Handle); ? IndicatorRelease(Kernel); ?}

用過的指標在 OnDeinit() 函數中刪除。

OnCalculate() 函數:


static bool Flag=false; ? ? ? ?//error flag if(Flag) return(rates_total); //exit in case of the flag

標記靜態(tài)變量添加至函數的開頭部分。如果在程序的執(zhí)行期間發(fā)生錯誤,F(xiàn)lag 等于 true 且 OnCalculate() 函數的所有進一步迭代從開始處被中斷。

下面是與手動模式相關的代碼塊:

? string Name; ?//short name of the required indicator ? if(!Automatic)//in case of the manual mode ? ? { ? ? ?if(ChartIndicatorsTotal(0,Window)>0)//if an indicator is present ? ? ? ?{ ? ? ? ? Name=ChartIndicatorName(0,Window,Indicator);//search for its name ? ? ? ? Handle=ChartIndicatorGet(0,Window,Name);//search for the handle ? ? ? ?} ? ? ?else//otherwise ? ? ? ?{ ? ? ? ? Alert("No indicator"); ? ? ? ? Flag=true; ? ? ? ? return(rates_total); ? ? ? ?} ? ? ?if(Handle==INVALID_HANDLE)//in case of a handle receiving error ? ? ? ?{ ? ? ? ? Alert("No indicator"); ? ? ? ? Flag=true; ? ? ? ? return(rates_total); ? ? ? ?} ? ? ?CopyBuffer(Handle,0,0,1024,DataBuffer);//display the kernel on the chart ? ? ?return(rates_total); ? ? }

如果 Automatic=false,手動模式啟動。將檢查指標是否存在。如果成功,我們開始搜索名稱和句柄,檢查句柄是否存在錯誤,并將數據復制到指標的緩沖區(qū)。如果失敗,"No indicator"(無指標)消息顯示,F(xiàn)lag 切換為 true,OnCalculate() 函數的執(zhí)行被中斷。

自動模式的代碼塊要有趣得多。它包含在圖表上搜索指標和創(chuàng)建內核。

所以,我們來考慮搜索指標。其主要目標是接收句柄。

? if(ChartIndicatorsTotal(0,0)>0)//if the indicator is in the main window ? ? { ? ? ?Name=ChartIndicatorName(0,0,0);//search for its name ? ? ?if(Name!="SpecAnalyzer")//if it is not SpecAnalyzer ? ? ? ? Handle=ChartIndicatorGet(0,0,Name);//look for a handle ? ? ?else ? ? ? ?{ ? ? ? ? Alert("Indicator not found"); ? ? ? ? Flag=true; ? ? ? ? return(rates_total); ? ? ? ?} ? ? } ? else//otherwise ? if(ChartIndicatorsTotal(0,1)>0)//if the indicator is in the first subwindow ? ? { ? ? ?Name=ChartIndicatorName(0,1,0);//search for its name ? ? ?if(Name!="SAInpData")//if it is not SAInpData ? ? ? ? Handle=ChartIndicatorGet(0,1,Name);//look for a handle ? ? ?else//otherwise ? ? ? ?{ ? ? ? ? Alert("Indicator not found"); ? ? ? ? Flag=true; ? ? ? ? return(rates_total); ? ? ? ?} ? ? } ? if(Handle==INVALID_HANDLE)//in case of a handle receiving error ? ? { ? ? ?Alert("No indicator"); ? ? ?Flag=true; ? ? ?return(rates_total); ? ? }

首先,我們在圖表的主要子窗口中搜索指標,確保它不是 SpecAnalyzer。如果在主窗口中未找到指標,我們在下一個子窗口中繼續(xù)搜索(考慮到此處有可能是 SAInpData)。所有其他操作與手動模式類似。

我們來創(chuàng)建一個指標。我們應接收獲得指標的參數,并基于脈沖創(chuàng)建一個類似指標:

? ENUM_INDICATOR indicator_type;//obtained indicator's type ? MqlParam parameters[]; ? ? ?//parameters ? int parameters_cnt=0; ? ? ?//number of parameters //--- receive the indicator's type, parameter values and amount ? parameters_cnt=IndicatorParameters(Handle,indicator_type,parameters); //--- define that a single impulse is to be sent to the indicator's input ? parameters[parameters_cnt-1].integer_value=Impulse; //--- receive the indicator's handle from the single impulse - filter's kernel ? Kernel=IndicatorCreate(NULL,0,indicator_type,parameters_cnt,parameters); ? if(Kernel==INVALID_HANDLE)//in case of a handle receiving error ? ? { ? ? ?Alert("Kernel initialization failed"); ? ? ?Flag=true; ? ? ?return(rates_total); ? ? } ? CopyBuffer(Kernel,0,0,1024,DataBuffer);//display the kernel on the chart


量化軟件下載:赫茲量化中技術指標和數字濾波器的評論 (共 條)

分享到微博請遵守國家法律
汉沽区| 保靖县| 砚山县| 东阳市| 武宁县| 界首市| 福州市| 铁力市| 房山区| 华阴市| 若尔盖县| 绥宁县| 岱山县| 调兵山市| 永清县| 皋兰县| 安仁县| 淳安县| 台东市| 衡阳县| 鱼台县| 鄂托克前旗| 辉南县| 陆良县| 嘉善县| 南木林县| 潼关县| 中西区| 寿光市| 青海省| 青河县| 沭阳县| 黎平县| 阳高县| 赤壁市| 博湖县| 忻州市| 太湖县| 嵩明县| 栾城县| 和林格尔县|