# 郁闷！！！一个简单的MACD交叉却不成交，请各位朋友看看是怎么回事

71

double MACDM0=10*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
double MACDM1=10*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
double MACDS0=10*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
double MACDS1=10*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);

if(_time!=Time[0] && MACDM0>0 && MACDS1<MACDM1 && MACDS0>MACDM0)
{
int SOK=OrderSend(Symbol(),OP_SELL,0.01,Bid,3,Bid+20*Point,Bid-5*Point,"YYY",111,0,Blue);
if(SOK>0) _time=iTime(NULL,Period(),0);
}

double MACDM0=10*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
double MACDM1=10*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,2);
double MACDS0=10*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
double MACDS1=10*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,2);

1635

0 意味着在这个5分钟间隔内，其值不断变化， Close值只有在这5分钟完结后才是确定值。

71

DxdCn 写道 >>

0 意味着在这个5分钟间隔内，其值不断变化， Close值只有在这5分钟完结后才是确定值。

if(StrToTime("2009.11.23 06:49")<Time[0] && StrToTime("2009.11.23 07:00")>Time[0])
if(MACDS1<MACDM1 && MACDS0>MACDM0)
{Print(TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)," MACDS1=",MACDS1," MACDM1=",MACDM1," MACDS0=",MACDS0," MACDM0=",MACDM0);}

//==================打印结果

EURUSD,M5: 2009.11.23 06:57 MACDS1=0.0076 MACDM1=0.008 MACDS0=0.0077 MACDM0=0.0076
EURUSD,M5: 2009.11.23 06:58 MACDS1=0.0076 MACDM1=0.008 MACDS0=0.0077 MACDM0=0.0076
EURUSD,M5: 2009.11.23 06:58 MACDS1=0.0076 MACDM1=0.008 MACDS0=0.0076 MACDM0=0.0075
EURUSD,M5: 2009.11.23 06:58 MACDS1=0.0076 MACDM1=0.008 MACDS0=0.0077 MACDM0=0.0076

171

1635

71

DxdCn 写道 >>

//-----

int intt=MathPow(10,MarketInfo(Symbol(),MODE_DIGITS)+2);
double MACDM0=MathFloor(intt*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0));
double MACDM1=MathFloor(intt*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1));
double MACDS0=MathFloor(intt*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0));
double MACDS1=MathFloor(intt*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1));
//--------

//--------打印结果如下

EURUSD,M5: 2009.11.23 06:57 MACDS1=760 MACDM1=797 MACDS0=765 MACDM0=758
EURUSD,M5: 2009.11.23 06:58 MACDS1=760 MACDM1=797 MACDS0=765 MACDM0=758
EURUSD,M5: 2009.11.23 06:58 MACDS1=760 MACDM1=797 MACDS0=764 MACDM0=750
EURUSD,M5: 2009.11.23 06:58 MACDS1=760 MACDM1=797 MACDS0=765 MACDM0=758
//-------

//----

if(下单条件成立吗）

{下单语句}

178

```int check_direction_big() {
double OsMA[2];
int flag=0;

OsMA[0] = iOsMA(NULL, 0, 12, 26, 9, PRICE_CLOSE, 0);
OsMA[1] = iOsMA(NULL, 0, 12, 26, 9, PRICE_CLOSE, 1);

if (OsMA[1] > 0 && OsMA[0] < 0) flag = -1;
elseif (OsMA[1] < 0 && OsMA[0] > 0) flag = 1;

return(flag);

}

void start() {
int flag;

flag = check_direction_big();
if (flag > 0)
// 买入
else if (flag < 0)
// 卖出

return;
}
```
1635

{Print(TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)," MACDS1=",MACDS1," MACDM1=",MACDM1," MACDS0=",MACDS0," MACDM0=",MACDM0);　//这Print有记录

OrserSend(....);　　//这OrderSend也有记录呀，怎么不提供呢？

}

171

010 写道 >>

//-----

int intt=MathPow(10,MarketInfo(Symbol(),MODE_DIGITS)+2);
double MACDM0=MathFloor(intt*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0));
double MACDM1=MathFloor(intt*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1));
double MACDS0=MathFloor(intt*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0));
double MACDS1=MathFloor(intt*iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1));
//--------

//--------打印结果如下

EURUSD,M5: 2009.11.23 06:57 MACDS1=760 MACDM1=797 MACDS0=765 MACDM0=758
EURUSD,M5: 2009.11.23 06:58 MACDS1=760 MACDM1=797 MACDS0=765 MACDM0=758
EURUSD,M5: 2009.11.23 06:58 MACDS1=760 MACDM1=797 MACDS0=764 MACDM0=750
EURUSD,M5: 2009.11.23 06:58 MACDS1=760 MACDM1=797 MACDS0=765 MACDM0=758
//-------

//----

if(下单条件成立吗）

{下单语句}

if(_time!=Time[0] && MACDM0>0 && MACDS1<MACDM1 && MACDS0>MACDM0)

if(下单条件成立吗）

{

if（是检测的时间吗）

{

print

}

}

171

71

xfxyldj 写道 >>

xfxyldj 谢谢您的回复

/---

/---------------以下是我在判断句内外都加上打印后的日志：

11:10:52 TestGenerator: unmatched data error (volume limit 70 at 2009.11.23 10:05 exceeded)
11:10:52 ABC started for testing
11:10:52 2009.11.23 00:00 ABC EURUSD,M5: open #1 sell 0.01 EURUSD at 1.4855 sl: 1.4875 tp: 1.4850 ok
11:10:52 2009.11.23 00:00 ABC EURUSD,M5: 2009.11.23 00:00
11:10:52 2009.11.23 00:00 ABC EURUSD,M5:
11:10:52 2009.11.23 00:18 Tester: take profit #1 at 1.4850 (1.4848 / 1.4850)
11:10:52 2009.11.23 01:50 ABC EURUSD,M5: open #2 sell 0.01 EURUSD at 1.4855 sl: 1.4875 tp: 1.4850 ok
11:10:52 2009.11.23 01:50 ABC EURUSD,M5: 2009.11.23 01:50
11:10:52 2009.11.23 01:50 ABC EURUSD,M5:
11:10:52 2009.11.23 01:55 ABC EURUSD,M5: open #3 sell 0.01 EURUSD at 1.4860 sl: 1.4880 tp: 1.4855 ok
11:10:52 2009.11.23 01:55 ABC EURUSD,M5: 2009.11.23 01:55
11:10:52 2009.11.23 01:55 ABC EURUSD,M5:
11:10:52 2009.11.23 02:00 Tester: stop loss #2 at 1.4875 (1.4873 / 1.4875)
11:10:52 2009.11.23 02:04 Tester: stop loss #3 at 1.4880 (1.4878 / 1.4880)
11:10:52 2009.11.23 03:05 ABC EURUSD,M5: open #4 sell 0.01 EURUSD at 1.4894 sl: 1.4914 tp: 1.4889 ok
11:10:52 2009.11.23 03:05 ABC EURUSD,M5: 2009.11.23 03:05
11:10:52 2009.11.23 03:05 ABC EURUSD,M5:
11:10:52 2009.11.23 03:15 Tester: take profit #4 at 1.4889 (1.4887 / 1.4889)
11:10:53 2009.11.23 04:50 ABC EURUSD,M5: open #5 sell 0.01 EURUSD at 1.4919 sl: 1.4939 tp: 1.4914 ok
11:10:53 2009.11.23 04:50 ABC EURUSD,M5: 2009.11.23 04:50
11:10:53 2009.11.23 04:50 ABC EURUSD,M5:
11:10:53 2009.11.23 05:56 Tester: stop loss #5 at 1.4939 (1.4937 / 1.4939)
11:10:53 2009.11.23 06:57 ABC EURUSD,M5: 2009.11.23 06:57
11:10:53 2009.11.23 06:58 ABC EURUSD,M5: 2009.11.23 06:58
11:10:53 2009.11.23 06:58 ABC EURUSD,M5: 2009.11.23 06:58
11:10:53 2009.11.23 06:58 ABC EURUSD,M5: 2009.11.23 06:58
11:10:53 2009.11.23 08:21 ABC EURUSD,M5: open #6 sell 0.01 EURUSD at 1.4935 sl: 1.4955 tp: 1.4930 ok
11:10:53 2009.11.23 08:21 ABC EURUSD,M5: 2009.11.23 08:21
11:10:53 2009.11.23 08:21 ABC EURUSD,M5:
11:10:53 2009.11.23 08:37 Tester: take profit #6 at 1.4930 (1.4928 / 1.4930)
11:10:54 2009.11.23 10:00 ABC EURUSD,M5: open #7 sell 0.01 EURUSD at 1.4956 sl: 1.4976 tp: 1.4951 ok
11:10:54 2009.11.23 10:00 ABC EURUSD,M5: 2009.11.23 10:00
11:10:54 2009.11.23 10:00 ABC EURUSD,M5:
11:10:54 2009.11.23 10:08 Tester: stop loss #7 at 1.4976 (1.4974 / 1.4976)
11:10:55 2009.11.24 01:55 ABC EURUSD,M5: open #8 sell 0.01 EURUSD at 1.4961 sl: 1.4981 tp: 1.4956 ok
11:10:55 2009.11.24 01:55 ABC EURUSD,M5: 2009.11.24 01:55
11:10:55 2009.11.24 01:55 ABC EURUSD,M5:
11:10:55 2009.11.24 01:59 Tester: take profit #8 at 1.4956 (1.4953 / 1.4955)
11:11:02 2009.11.24 12:15 ABC EURUSD,M5: open #9 sell 0.01 EURUSD at 1.4935 sl: 1.4955 tp: 1.4930 ok
11:11:02 2009.11.24 12:15 ABC EURUSD,M5: 2009.11.24 12:15
11:11:02 2009.11.24 12:15 ABC EURUSD,M5:
11:11:02 2009.11.24 12:46 Tester: stop loss #9 at 1.4955 (1.4953 / 1.4955)
11:11:02 2009.11.24 15:05 ABC EURUSD,M5: open #10 sell 0.01 EURUSD at 1.4977 sl: 1.4997 tp: 1.4972 ok
11:11:02 2009.11.24 15:05 ABC EURUSD,M5: 2009.11.24 15:05
11:11:02 2009.11.24 15:05 ABC EURUSD,M5:
11:11:02 2009.11.24 15:14 Tester: take profit #10 at 1.4972 (1.4969 / 1.4971)
11:11:03 2009.11.24 16:10 ABC EURUSD,M5: open #11 sell 0.01 EURUSD at 1.4979 sl: 1.4999 tp: 1.4974 ok
11:11:03 2009.11.24 16:10 ABC EURUSD,M5: 2009.11.24 16:10
11:11:03 2009.11.24 16:10 ABC EURUSD,M5:
11:11:03 2009.11.24 16:22 Tester: take profit #11 at 1.4974 (1.4972 / 1.4974)
11:11:04 2009.11.24 20:50 ABC EURUSD,M5: open #12 sell 0.01 EURUSD at 1.4963 sl: 1.4983 tp: 1.4958 ok
11:11:04 2009.11.24 20:50 ABC EURUSD,M5: 2009.11.24 20:50
11:11:04 2009.11.24 20:50 ABC EURUSD,M5:
11:11:04 2009.11.24 21:07 Tester: stop loss #12 at 1.4983 (1.4981 / 1.4983)
11:11:04 2009.11.24 21:35 ABC EURUSD,M5: open #13 sell 0.01 EURUSD at 1.4972 sl: 1.4992 tp: 1.4967 ok
11:11:04 2009.11.24 21:35 ABC EURUSD,M5: 2009.11.24 21:35
11:11:04 2009.11.24 21:35 ABC EURUSD,M5:
11:11:04 2009.11.24 22:13 Tester: take profit #13 at 1.4967 (1.4965 / 1.4967)