顺水外汇EA交易网MT4
标题:
求关于多周期指标的写法
[打印本页]
作者:
过去了
时间:
2018-1-11 13:19
标题:
求关于多周期指标的写法
最近看了一个多周期指标CCI,但
切换周期时特别卡
,说明这个指标虽然实现了,但方式有问题。
求论坛里汇友,介绍个多周期的写法流程……
[attach]17723[/attach]
[C++] 纯文本查看 复制代码#property copyright "Copyright © 2006, Eli hayun"
#property link "http://www.elihayun.com"
//----
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 5
#property indicator_buffers 8
#property indicator_color1 Red
#property indicator_color2 Lime
#property indicator_color3 Red
#property indicator_color4 Lime
#property indicator_color5 Red
#property indicator_color6 Lime
#property indicator_color7 Red
#property indicator_color8 Lime
//---- parameters
//extern int MaMetod = 2;
//extern int MaPeriod = 6;
//extern int MaMetod2 = 3;
//extern int MaPeriod2 = 2;
extern int BarWidth=0;//3;
extern color UpBarColor=Blue;
extern color DownBarColor=Red;
extern color TextColor=White;
//----
double Gap=1; // Gap between the lines of bars
//---- buffers
double buf4_up[];
double buf4_down[];
double buf3_up[];
double buf3_down[];
double buf2_up[];
double buf2_down[];
double buf1_up[];
double buf1_down[];
double haOpen;
double haClose;
/*
extern int Period_1 = 15;
extern int Period_2 = 30;
extern int Period_3 = 60;
extern int Period_4 = 240;
extern bool AutoDisplay = false;
*/
string shortname="";
bool firstTime=true;
//----
int ArrSize=110;//112;//168;//158;//159;
int UniqueNum=228;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//SetAutoDisplay();
firstTime=true;
//IndicatorShortName(shortname);
//---- indicators
SetIndexStyle(0,DRAW_ARROW,0,BarWidth,UpBarColor);
SetIndexArrow(0,ArrSize);
SetIndexBuffer(0,buf1_up);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW,0,BarWidth,DownBarColor);
SetIndexArrow(1,ArrSize);
SetIndexBuffer(1,buf1_down);
SetIndexEmptyValue(1,0.0);
SetIndexStyle(2,DRAW_ARROW,0,BarWidth,UpBarColor);
SetIndexArrow(2,ArrSize);
SetIndexBuffer(2,buf2_up);
SetIndexEmptyValue(2,0.0);
SetIndexStyle(3,DRAW_ARROW,0,BarWidth,DownBarColor);
SetIndexArrow(3,ArrSize);
SetIndexBuffer(3,buf2_down);
SetIndexEmptyValue(3,0.0);
SetIndexStyle(4,DRAW_ARROW,0,BarWidth,UpBarColor);
SetIndexArrow(4,ArrSize);
SetIndexBuffer(4,buf3_up);
SetIndexEmptyValue(4,0.0);
SetIndexStyle(5,DRAW_ARROW,0,BarWidth,DownBarColor);
SetIndexArrow(5,ArrSize);
SetIndexBuffer(5,buf3_down);
SetIndexEmptyValue(5,0.0);
SetIndexStyle(6,DRAW_ARROW,0,BarWidth,UpBarColor);
SetIndexArrow(6,ArrSize);
SetIndexBuffer(6,buf4_up);
SetIndexEmptyValue(6,0.0);
SetIndexStyle(7,DRAW_ARROW,0,BarWidth,DownBarColor);
SetIndexArrow(7,ArrSize);
SetIndexBuffer(7,buf4_down);
SetIndexEmptyValue(7,0.0);
//
IndicatorDigits(0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//SetAutoDisplay();
// shortname = "# Forex Freedom("+Period_1+","+Period_2+","+Period_3+","+Period_4+")";
firstTime=true;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i=0, y15m=0, y4h=0, y1h=0, y30m=0, yy;
int limit=Bars-counted_bars;
int Period_1, Period_2, Period_3, Period_4;
switch(Period())
{
case 1:
Period_1=1; Period_2=5; Period_3=15; Period_4=30;
break;
case 5:
Period_1=5; Period_2=15; Period_3=30; Period_4=60;
break;
case 15:
Period_1=15; Period_2=30; Period_3=60; Period_4=240;
break;
case 30:
Period_1=30; Period_2=60; Period_3=240; Period_4=1440;
break;
case 60:
Period_1=60; Period_2=240; Period_3=1440; Period_4=10080;
break;
case 240:
Period_1=240; Period_2=1440; Period_3=10080; Period_4=43200;
break;
case 1440:
Period_1=1440; Period_2=10080; Period_3=43200; Period_4=43200;
break;
case 10080:
Period_1=10080; Period_2=43200; Period_3=43200; Period_4=43200;
break;
case 43200:
Period_1=43200; Period_2=43200; Period_3=43200; Period_4=43200;
break;
}
shortname="MTF_4TF_Supertrend_BarM("+Period_1+","+Period_2+","+Period_3+","+Period_4+")";
IndicatorShortName(shortname);
//----
SetIndexLabel(0,"MTF_ST,"+Period_4+"");
SetIndexLabel(1,"MTF_SV,"+Period_4+"");
SetIndexLabel(2,"MTF_ST,"+Period_3+"");
SetIndexLabel(3,"MTF_ST,"+Period_3+"");
SetIndexLabel(4,"MTF_ST,"+Period_2+"");
SetIndexLabel(5,"MTF_ST,"+Period_2+"");
SetIndexLabel(6,"MTF_ST,"+Period_1+"");
SetIndexLabel(7,"MTF_ST,"+Period_1+"");
datetime TimeArray_4H[], TimeArray_1H[], TimeArray_30M[], TimeArray_15M[];
//----
if (firstTime || NewBar())
{
firstTime=false;
int win=UniqueNum; // WindowFind(shortname);
double dif=Time[0] - Time[1];
for(int ii=ObjectsTotal()-1; ii>-1; ii--)
{
if (StringFind(ObjectName(ii),"FF_"+win+"_")>=0)
ObjectDelete(ObjectName(ii));
else
ii=-1;
}
double shift=0.2;
for(ii=0; ii
作者:
jueeee
时间:
2018-1-11 14:48
呵呵,这是要干嘛 https://pan.baidu.com/s/1cl8Fwi
作者:
过去了
时间:
2018-1-11 16:05
留下证据,避免说我瞎说。虽然我不是个无聊的人,但这是
在我的求知帖子里,希望来的人都有所收获
,而不是那个啥是吧……
不说了,论坛里口水见多了。继续……。
[attach]17724[/attach]
作者:
wdnpy485
时间:
2018-1-11 16:39
不会写代码,给你个源码参考参考
作者:
过去了
时间:
2018-1-11 18:04
感谢感谢!!!
作者:
engjing
时间:
2018-1-11 19:10
感谢分享
作者:
engjing
时间:
2018-1-11 20:13
感谢分享
作者:
harro
时间:
2018-1-11 20:47
小手一抖,金币到手,金币不够,帖子来凑
作者:
阿强989
时间:
2018-1-11 21:38
谢谢分享
作者:
一生平安
时间:
2018-1-11 22:57
谢谢分享
作者:
新昕心
时间:
2018-1-11 23:11
谢谢分享
作者:
bary
时间:
2018-1-12 00:24
切换周期的时候 MT4 会重新初始化图表上的指标,如果计算量大就是会很卡。
作者:
剑儿
时间:
2018-1-12 01:13
谢谢分享
作者:
gxwzpy
时间:
2018-1-12 01:29
来看看来学习
作者:
黄小溪
时间:
2018-1-12 01:46
来自安卓客户端
欢迎光临 顺水外汇EA交易网MT4 (http://waterforex.com/)
Powered by Discuz! X3.2