如何在 EA 中调用?

//+------------------------------------------------------------------+ //|test_SDC.mq5 //|版权所有 2022 fxMeter | //|https://www.mql5.com/zh/users/fxmeter||. //+------------------------------------------------------------------+ #property copyright "Copyright 2022,fxMeter" #property link "https://www.mql5.com/zh/users/fxmeter" #property version "1.00" input int InputStarBar = 0;//StarBar input int InputCalcBars = 120;// 计算栏 input double f1=1.0;//内部通道乘法器 input double f2=2.0;//外通道乘法器 int handle = -1; //+------------------------------------------------------------------+ //| 专家初始化函数| //+------------------------------------------------------------------+ int OnInit() { //--- //1.Create a handle to StandardDeviationChannel handle = iCustom(Symbol(),PERIOD_CURRENT,"StandardDeviationChannel",InputStarBar,InputCalcBars,f1,f2); /2.检查句柄是否创建成功 if(handle==INVALID_HANDLE)//失败 { Alert("Create a handle to StandardDeviationChannel failed"); return(INIT_FAILED); } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| 专家去初始化函数| //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| 专家勾选功能| //+------------------------------------------------------------------+ void OnTick() { //--- double mid_right = GetBufferValue(0,InputStarBar); double top_right = GetBufferValue(1,InputStarBar); double btm_right = GetBufferValue(2,InputStarBar); double mid_left = GetBufferValue(0,InputStarBar+InputCalcBars-1); double top_left = GetBufferValue(1,InputStarBar+InputCalcBars-1); double btm_left = GetBufferValue(2,InputStarBar+InputCalcBars-1); Comment( "mid_left = ",d2s(mid_left)," , ","mid_right = ",d2s(mid_right),"\n", "top_left = ",d2s(top_left)," , ","top_right = ",d2s(top_right),"\n", "btm_left = ",d2s(btm_left)," , ","btm_right = ",d2s(btm_right) ); } //+------------------------------------------------------------------+ double GetBufferValue(int which_buffer,int which_bar) { double tmp[1]= {0}; CopyBuffer(handle,which_buffer,which_bar,1,tmp); return tmp[0]; } //+------------------------------------------------------------------+ //将双数转换为字符串 string d2s(double x) { return DoubleToString(x,_Digits); }
附加的文件:
test_SDC.mq5
3 kb
Indicators: Standard Deviation Channel MT4
- 2021.08.20
- www.mql5.com
Standard Deviation Channel MT4: Author: Ziheng Zhuang...
如果有多时间框架版本就更好了
太神奇了
MT5 标准偏差通道:
基于收盘价标准偏差的通道。
作者: Ziheng Zhuang