顺水外汇EA交易网MT4
标题:
缠论指标不能用,高手帮忙看看
[打印本页]
作者:
linghuchong007
时间:
2018-1-11 13:37
标题:
缠论指标不能用,高手帮忙看看
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
extern int type=1;//0为点,1为线
//---- buffers
double IndicatorBuffer1[];
double DingOrDi[];
double MACDAreaBuffer[];
double MaiMaiDianBuffer[];
int Deviation=0; // 忽略次要波动,小于100个Point Value的波动是小波动(黄金、A300的Point Value均为0.01)
bool NeedPrint(int i)
{
return (false);//不打印
if( TimeYear(Time
)==2013
&& TimeMonth(Time
)==10
&& TimeDay(Time
)==17
&& TimeHour(Time
)==20
&& TimeMinute(Time
)==45
)
{
return (true);
}
else
{
return (false);
}
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//没有产生新的K线前,不重复计算
static datetime dt=0;
if(dt==Time[0])
{
return;
}
else
{
dt=Time[0];
}
Sleep(5000);
// Print("DateTime:",dt);
int limit;
int counted_bars = IndicatorCounted();
//---- check for possible errors
if (counted_bars0) counted_bars--;
limit = Bars - counted_bars;
if(counted_bars==0 && Bars>=6 )
{
limit-=6;
}
else if(limit>=2)
{
// limit-=2;
}
double high=0,low=0;
int previousDi=-1,previousDing=-1,HasFirstDing=0,HasFirstDi=0,DingTempState=0,DiTempState=0;
ComputeMacdArea(Bars);//计算MACD面积
for(int i=Bars; i>=1; i--)
{
int FenXing=0;//-1表示底分型 1表示顶分型
if(IsDingFenXing(i) && !IsDiFenXing(i))
{
FenXing=1;
}
else if(IsDiFenXing(i) && !IsDingFenXing(i))
{
FenXing=-1;
}
else if(IsDingFenXing(i) && IsDiFenXing(i)) //即是顶分型又是底分型的时候需要确定用哪一个更合适
{
if(previousDing==-1 || previousDi==-1)//前面没有底或没有顶时取顶
//(为了计算方便,最初限制不太严格,可能不够完美,但对操作没有任何影响)
{
FenXing=1;
}
else //前面既有顶又有底时
{
if(previousDing Low[previousDi]) FenXing=1;
else FenXing=-1;
}
}
}
DingOrDi
=0;
if(NeedPrint(i)) Print("Current Time:",TimeYear(Time
),"-",TimeMonth(Time
),"-",TimeDay(Time
)," ",
TimeHour(Time
),":",TimeMinute(Time
)," number:",i);
if( IsDingFenXing(i)&& FenXing==1)
{
//找到一个顶
DingOrDi
=1;
if(NeedPrint(i))
{
Print("PreviousDi:",TimeHour(Time[previousDi]),":",TimeMinute(Time[previousDi]),",number:",previousDi,",DingOrDi:",DingOrDi[previousDi]);
Print("previousDing:",TimeHour(Time[previousDing]),":",TimeMinute(Time[previousDing]),",number:",previousDing,",DingOrDi:",DingOrDi[previousDing]);
}
if(DingTempState!=0)//顶中间状态找到一个顶
{
if(High
previousDi)//顶前有底,底前又有顶
{
if(previousDi-i+1previousDing ) //连续出现两个顶
)
{
if(High[previousDing]=High
&& previousDi-i=High
&& previousDi-ipreviousDing ) && High[previousDing]=High
))//有缺口且顶分型不比底型低时保留此顶
{
HasFirstDing=1;
previousDing=i;
if(NeedPrint(i)) Print("Ding_9:",i);
}
else //有缺口且顶分型比底型低仍叉掉此顶
{
DingOrDi
=0;
if(NeedPrint(i)) Print("Ding_9_2:",i);
}
}
else if(previousDi!=-1 && (High
-Low[previousDi])High
) break;
}
if(ii==previousDi || previousDi-i>=10)//当前顶分型为笔中的最高点或者够10周期 保留此顶
{
if(NeedPrint(i)) Print("Ding_11:",i);
HasFirstDing=1;
previousDing=i;
}
else //当前顶分型不是笔中的最高点且不够10周期 删除此顶
{
if(NeedPrint(i)) Print("Ding_12:",i);
DingOrDi
=0;
}
}
else//保留此顶
{
if(NeedPrint(i)) Print("Ding_13:",i);
HasFirstDing=1;
previousDing=i;
}
}
}
else if(IsDiFenXing(i) && FenXing==-1)
{
//找到一个底
DingOrDi
=-1;
if(NeedPrint(i))
{
Print("PreviousDing:",TimeHour(Time[previousDing]),":",TimeMinute(Time[previousDing]),",number:",previousDing,",DingOrDi:",DingOrDi[previousDing]);
Print("previousDi:",TimeHour(Time[previousDi]),":",TimeMinute(Time[previousDi]),",number:",previousDi,",DingOrDi:",DingOrDi[previousDi]);
}
if(DiTempState!=0)//底中间状态找到一个底
{
if(Low
>=Low[DiTempState])//当前底比中间状态的底高叉掉当前的底
{
DingOrDi
=0;
if(NeedPrint(i)) Print("Di_0_1:",i);
}
else if(previousDi-i+1previousDing)//底前有顶,顶前又有底
{
if(previousDing-i+1=Low[previousDi])//不够5周期且当前底比前底高叉掉此底
{
DingOrDi
=0;
if(NeedPrint(i)) Print("Di_3:",i);
}
else//不够5周期且当前底比前底低进入底中间状态并叉掉此底
{
DiTempState=i;
DingOrDi
=0;
if(NeedPrint(i)) Print("Di_3_2:",i);
}
}
else//够5周期保留此底
{
if(NeedPrint(i)) Print("Di_4_3:",i);
}
}
else if(HasFirstDi==1 && (HasFirstDing==0||previousDing>previousDi )//连续出现两个底
)
{
if(Low[previousDi]>Low
)
{
DingOrDi[previousDi]=0; //叉掉前面一个底
DingOrDi
=-1;
if(NeedPrint(i)) Print("Di_5:",i);
}
else
{
DingOrDi
=0;//叉掉当前的底
if(NeedPrint(i)) Print("Di_6:",i);
}
}
else
{
DingOrDi
=-1;
if(NeedPrint(i)) Print("Di_7:",i);
}
if(DingOrDi
==-1)
{
if((previousDi!=-1&&DingOrDi[previousDi]==0) || (previousDing!=-1&&DingOrDi[previousDing]==0))//已叉掉前面的顶或底时,保留此底
{
if(NeedPrint(i)) Print("Di_8_0:",i);
HasFirstDi=1;
previousDi=i;
}
else if(previousDing!=-1
// && (previousDing-i)Close[previousDing]||Low
>High[previousDing]
||(Low
>=Low[previousDing] && previousDing-i=High[previousDing] && previousDing-i=High[previousDing]&& previousDing-i=High[previousDing]&& previousDing-ipreviousDi)&& Low[previousDi]>Low
))
{
DingOrDi
=0;
if(NeedPrint(i)) Print("Di_8_1:",i);
}
else //连续出现两个底且前底比当前底高时保留当前底
{
if(NeedPrint(i)) Print("Di_8_2:",i);
HasFirstDi=1;
previousDi=i;
}
}
else if(!(Low
>=Low[previousDing]||High
>=High[previousDing]
// ||High[i+1]>=High[previousDing]||Low[previousDing-1]=10)//当前底分型为笔中的最底点或者够10周期 保留此底
{
if(NeedPrint(i)) Print("Di_11:",i);
HasFirstDi=1;
previousDi=i;
}
else //当前底分型不是笔中的最低点且不够10周期 删除此底
{
if(NeedPrint(i)) Print("Di_12:",i);
DingOrDi
=0;
}
}
else//保留此底
{
HasFirstDi=1;
previousDi=i;
if(NeedPrint(i)) Print("Di_13:",i);
}
}
}
//买卖点计算
// MaiMaiDianJiSuan(i);
}
int k=0;
for(int m=1;m[B]>=High[i+1]&&High
>=High[i-1]&&Low
>=Low[i+1]&&Low
>=Low[i-1])||
if(i>=4)
{
if(iHighest(NULL,0,MODE_HIGH,9,i-4)==i)
{
return (true);
}
else
{
return (false);
}
}
else if(i==3)
{
if(iHighest(NULL,0,MODE_HIGH,8,i-3)==i)
{
return (true);
}
else
{
return (false);
}
}
else if(i==2)
{
if(iHighest(NULL,0,MODE_HIGH,7,i-2)==i)
{
return (true);
}
else
{
return (false);
}
}
else if(i==1)
{
if(iHighest(NULL,0,MODE_HIGH,6,i-1)==i)
{
return (true);
}
else
{
return (false);
}
}
else if(i==0)
{
if(iHighest(NULL,0,MODE_HIGH,5,i-0)==i)
{
return (true);
}
else
{
return (false);
}
}
}
bool IsDiFenXing(int i)
{
//(Low
=4)
{
if(iLowest(NULL,0,MODE_LOW,9,i-4)==i)
{
return (true);
}
else
{
return (false);
}
}
else if(i==3)
{
if(iLowest(NULL,0,MODE_LOW,8,i-3)==i)
{
return (true);
}
else
{
return (false);
}
}
else if(i==2)
{
if(iLowest(NULL,0,MODE_LOW,7,i-2)==i)
{
return (true);
}
else
{
return (false);
}
}
else if(i==1)
{
if(iLowest(NULL,0,MODE_LOW,6,i-1)==i)
{
return (true);
}
else
{
return (false);
}
}
else if(i==0)
{
if(iLowest(NULL,0,MODE_LOW,5,i-0)==i)
{
return (true);
}
else
{
return (false);
}
}
}
int ComputeMacdArea(int nBars)
{
for(int i=nBars; i>=1; i--)
{
//计算MACD红绿柱面积 Begin
MACDAreaBuffer
=0;
double HistogramBuffer1_iplus1,HistogramBuffer1_i,HistogramBuffer2_iplus1,HistogramBuffer2_i;
HistogramBuffer1_iplus1=iCustom(NULL,0,"Ljp_MACD",2,i+1);
HistogramBuffer1_i=iCustom(NULL,0,"Ljp_MACD",2,i);
HistogramBuffer2_iplus1=iCustom(NULL,0,"Ljp_MACD",3,i+1);
HistogramBuffer2_i=iCustom(NULL,0,"Ljp_MACD",3,i);
//计算红柱面积
if(HistogramBuffer1_i>0)//目前是红柱
{
if(HistogramBuffer2_iplus10)//前一个周期是红柱
{
MACDAreaBuffer
=HistogramBuffer2_i;
}
else
{
MACDAreaBuffer
+=HistogramBuffer2_i+MACDAreaBuffer[i+1];
}
}
else //目前没有红绿柱,HistogramBuffer1_i,HistogramBuffer2_i均为0
{
//Print("i=",i,",Time=",Time
,",Bars=",Bars); //经测试发现,只有计算的最初两个柱子红绿柱才会均为0
MACDAreaBuffer
=0;
}
}
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(4);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
//---- indicators
if(type==1)
{
SetIndexStyle(0,DRAW_SECTION,STYLE_DOT);
//SetIndexStyle(0,DRAW_SECTION);
}
else
{
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,161);// 159小圆点 222耳机 114 方框 116菱形 http://www.fx998.com/read.php?tid-15196.html可查看所有箭头形状
}
SetIndexBuffer(0,IndicatorBuffer1);
SetIndexEmptyValue(0,0);
SetIndexBuffer(1,DingOrDi);
SetIndexBuffer(2,MACDAreaBuffer);
SetIndexBuffer(3,MaiMaiDianBuffer);
SetIndexStyle(3,DRAW_ARROW,0,0,Red);
SetIndexArrow(3,159);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("FenBi");
SetIndexLabel(0,"FenBiValue");
SetIndexLabel(1,"DingOrDi");
SetIndexLabel(2,"Area_MACD");
SetIndexLabel(3,"MaiMaiDian");
//Print("Point=",Point,",","Digits=",Digits);
if(Symbol()=="SILVER")
{
Deviation=50;
// Print(Symbol());
}
else if(Symbol()=="GOLD")
{
Deviation=50;
// Print(Symbol());
}
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
int HasGap(int m,int n) //判断是否有缺口
{
for(int i=m;i>n;i--)
{
if(Low
>High[i-1] || High
<Low[i-1])
return (1);
}
return (0);
}
//+------------------------------------------------------------------+
作者:
Bruce_fan
时间:
2018-1-11 13:48
if( TimeYear(Time)==2013
&& TimeMonth(Time)==10
&& TimeDay(Time)==17
&& TimeHour(Time)==20
&& TimeMinute(Time)==45
把这段时间限制语句去掉 在编译就可以了
作者:
lrx813
时间:
2018-1-11 15:04
还是无法编译,请高手继续努力,谢谢
作者:
Kuan_bxO6s
时间:
2018-1-11 16:04
一重缠是一重山
作者:
jiajie
时间:
2018-1-11 17:11
84 error(s), 1 warning(s) 85 2
作者:
linghuchong007
时间:
2018-1-11 17:22
貌似还是不行,帮忙修改回传一个呗,谢谢!
作者:
mahuamin
时间:
2018-1-11 18:20
没看懂啥意思,不懂缠,也不知道对不对,已改正可运行,有指标有图
作者:
linghuchong007
时间:
2018-1-11 19:39
貌似切换时间时指标很卡,是TICK数据蜡烛太多了?
作者:
hanbaoming
时间:
2018-1-11 21:06
好东西支持
作者:
老氓子
时间:
2018-1-11 22:43
学习下学习下
作者:
hellomimi
时间:
2018-1-11 23:45
我也在找能用的缠论分笔指标
作者:
zhangwei
时间:
2018-1-12 00:50
没看懂啥意思,不懂缠,也不知道对不对,已改正可运行,有指标有图
作者:
天翊_o39Z9
时间:
2018-1-12 02:13
不懂,学习
作者:
煙鬥
时间:
2018-1-12 03:52
缠论指标不能用,高手帮忙看看 ...
作者:
吴强
时间:
2018-1-12 04:02
学习一下 看看
欢迎光临 顺水外汇EA交易网MT4 (http://waterforex.com/)
Powered by Discuz! X3.2