首页学院交易策略EA智能交易文章详细

外汇EA编程入门【第六课】:阴阳太极

外汇网2021-06-17 09:40:21 46
汇外网 - 全球专业的黄金外汇门户导航行情资讯网站

首先教你第一招:阴阳太极

打开你的metaeditor

打开你的my1ea002

我先用中文编撰一次

你就明白我们等下要编撰什么

我们要编撰。

假使(

没有任何单

和 青bar //上升的趋势

){可下方注买上的单}

假使(

没有任何单

和 红bar //代表下滑低趋势

){可下方注买下的单}

ok就这么简单

你还记得要要求ea的编撰方程式吗?

对,就是

if(){}

编撰结果如下:

//+------------------------------------------------------------------+

//| my1ea.mq4 |

//|http://www.mt4ea,com |

//+------------------------------------------------------------------+

#property copyright "Copyright ?2009, 柒侠伍义"

#property link "http://www.mt4ea,com"

//+------------------------------------------------------------------+

//| expert initialization function |

//+------------------------------------------------------------------+

int init()

{

//----

//----

return(0);

}//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert start function |

//+------------------------------------------------------------------+

int start()

{

//----

if(

OrdersTotal()==0

amp;& Close[0]>Open[0]

){

OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green);

}

if(

OrdersTotal()==0

amp;& Close[0]

){

OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"macd sample",16384,0,Red);

}

//----

return(0);

}

//+------------------------------------------------------------------+ 

OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"macd sample",16384,0,Red);

OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green);

以上两个OrderSend是从macd sample

copy & press 过来的

还没有终结。

把这两个改一改就可以了

OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"macd sample",16384,0,Red);

OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green);

Lots改成1

TakeProfit改成200

0 改成Bid+200*Point

0 改成Ask-200*Point

变成

OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid-+200*Point,Bid-200*Point,"macd sample",16384,0,Red);

OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-200*Point,Ask+200*Point,"macd sample",16384,0,Green);

按《编撰》

假使0错误 0警示

你的my1ea002成功了

标签:

随机快审展示
加入快审,优先展示

加入VIP