[MT4指标]老朋友用的一个mt3的指标高手们帮忙弄成mt4的吧
我用起来还不错 就是只能在mt3上用
原理其实很简单 就是判断前12根k线的最高最低点
主要用来辅助判断突破的
/*[[
- Hide quoted text -
Name := 12LineBreak
Author := Amir
Notes := hacked up by transport
Separate Window := no
First Color := Red
First Draw Type := Symbol
First Symbol := 159
Use Second Data := Yes
Second Color := LawnGreen
Second Draw Type := Symbol
Second Symbol := 159
]]*/
Inputs: LinesBreak(12),AllBars(500);
Variables: val1(0),val2(0),shift(0),NumBars(500),Swing(0);
Variables: val11(0),val12(0);
If Bars val1) then
{
Swing=1;
};
if (Swing=2) then
{
SetIndexValue2(shift,val1);
};
if (Swing=1) then
{
SetIndexValue(shift,val2);
};
End;
遇到矛盾 先站在对方的立场上想想问题,先试着去理解别人
● 如何使用WinMTR查询平台连接流畅度
发表于:2005-12-22 00:26只看该作者
2楼
其实,这就是国外80年代一个著名的技术指标Donchian Channel. 曾经在期货杂志上发表过。轰动一时。
下面是我用MT4实现的代码:
//+------------------------------------------------------------------+
//| |
//| Copyright ? [email protected] |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright [email protected]"
#property link ""
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 White
#property indicator_color2 Blue
extern int size=12;
extern int shift=0;// 1 to 100
//---- buffers
double up1,dn1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,up1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,dn1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
for (int i=Bars-1;i>=0;i--)
{
up1=High[Highest(NULL,0,MODE_HIGH,size,i+shift)];
dn1=Low[Lowest(NULL,0,MODE_LOW,size,i+shift)];
}
//----
return(0);
}
//+------------------------------------------------------------------+
[ 本帖最后由 maningok 于 2005-12-22 08:31 编辑 ]
4楼
强哦 呵呵 老兄圣诞快乐哈
遇到矛盾 先站在对方的立场上想想问题,先试着去理解别人
● 如何使用WinMTR查询平台连接流畅度
发表于:2005-12-22 01:17只看该作者
5楼
呵呵,圣诞快乐,祝论坛兴旺,祝这里的汇友发大财!!
韬客社区www.talkfx.co
6楼
感觉有点不大一样 我在mt3上显示的是
比如突破了12天的高点后 只输出低点的数值
还是发个图你看看吧
Snap1.gif

遇到矛盾 先站在对方的立场上想想问题,先试着去理解别人
● 如何使用WinMTR查询平台连接流畅度
发表于:2005-12-22 02:43只看该作者
7楼
个人使用习惯不同,这次做个和原图一模一样的给你
mt.jpg
原帖由 老正 于 2005-12-22 09:50 发表 感觉有点不大一样 我在mt3上显示的是 比如突破了12天的高点后 只输出低点的数值 还是发个图你看看吧

韬客社区www.talkfx.co
发表于:2005-12-22 02:44只看该作者
8楼
代码在这里
//+------------------------------------------------------------------+
//| |
//| Copyright ? [email protected] |
//+------------------------------------------------------------------+
#property copyright "Copyright [email protected]"
#property link ""
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Chartreuse
#property indicator_color2 Red
extern int size=80;
extern int shift=1;// 1 to 100
//---- buffers
double up1,dn1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW,5,5);
SetIndexBuffer(0,up1);
SetIndexArrow(0,158);
SetIndexStyle(1,DRAW_ARROW,5,5);
SetIndexBuffer(1,dn1);
SetIndexArrow(1,158);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int dir;
double up,dn;
for (int i=Bars-1;i>=0;i--)
{
up=High[Highest(NULL,0,MODE_HIGH,size,i+shift)];
dn=Low[Lowest(NULL,0,MODE_LOW,size,i+shift)];
if(High>up) dir=1;
if(Low0) dn=0;
if(dir<0) up=0;
up1=up;
dn1=dn;
}
//----
return(0);
}
//+------------------------------------------------------------------+
韬客社区www.talkfx.co
9楼
。。。。。惭愧啊。。明明知道编成的思路很简单 就是不知道怎么个写法。。。。
谢谢啦 呵呵
遇到矛盾 先站在对方的立场上想想问题,先试着去理解别人
● 如何使用WinMTR查询平台连接流畅度
发表于:2005-12-22 03:34只看该作者
10楼
maningok出手就是不一样,谢谢你的指标。
11楼
嘿嘿 老哥这里写反了吧
if(dir>0) dn=0;
if(dir<0) up=0;
我把它反过来就ok了
if(dir<0) dn=0;
if(dir>0) up=0;
遇到矛盾 先站在对方的立场上想想问题,先试着去理解别人
● 如何使用WinMTR查询平台连接流畅度
发表于:2005-12-22 03:58只看该作者
12楼
谢谢老正,我要实现的功能是:当碰到上边界的时候,下边界隐藏,当碰到下边界的时候,上边界隐藏。的确写反了。我原来的代码怎么改过来呢?已经超过60分钟了,不能改了吗?
:P
[ 本帖最后由 maningok 于 2005-12-22 12:02 编辑 ]
原帖由 老正 于 2005-12-22 11:35 发表 嘿嘿 老哥这里写反了吧 if(dir>0) dn=0; if(dir<0) up=0; 我把它反过来就ok了 if(dir<0) dn=0; if(dir>0) up=0;
韬客社区www.talkfx.co
13楼
我当时要实现的是 突破上边界后 上边界隐藏 只显示下边界 作为参考的止损
你要实现的功能代码是对的
要实现我的功能就得反过来写了。。
遇到矛盾 先站在对方的立场上想想问题,先试着去理解别人
● 如何使用WinMTR查询平台连接流畅度