我想上吊 发表于 2011-12-4 13:30:23

向柒侠请教CLOSEBUY。

这些日子拜读了您老的贴子后,不懂一点编程的我若有所悟,自己用您的模版试着表达了一下我的意思,意思很简单,只用三条均线,
MA1=5,MA2=10,MA3=30
当MA1上穿MA2,且MA2在MA3之上时做多。
当MA2下穿MA2,且MA2在MA3之下时做空。

当MA1上穿MA2时先平掉多仓,
当MA2下穿MA2先平掉空仓。

可是发现怎么也调用不了CloseBuy和CloseSell,
整个代码如下,望老师指点。。


//+------------------------------------------------------------------+
//|                                                         kkkk.mq4 |
//|                                                         mengtong |
//|                                    http://www.hahahahahahaha.net |
//+------------------------------------------------------------------+
#property copyright \"mengtong\"
#property link      \"http://www.hahahahahahaha.net\"

extern double ma1=5,ma2=10,ma3=30;
double ma1now,ma1now2,ma2now,ma2now2,ma3now,ma3now2,ma1bnow,ma2bnow,ma3bnow;
////////////////////////
extern string _资金管理_ =\"任选一个\";
extern bool zijiguanli1= true;//false true、、
extern bool zijiguanli2= false;//false true、、
extern bool zijiguanli3= false;//false true、、
///////////////////////////////////
extern double cheng=1;
int cnt;
int i;
string text=\"\";
double TrailingStop=0;
double aa=0;
int s=0,b=0;
double CurrentBasket=0;
double LotMM=0;
double lotstart=0;
double LotsMax=100;
extern double lotab=0.1;
double lots=0;
double TP=0,TPP=0,SL=0,SLL=0;
int slip=6;
///////////////////////////////////////
double mode=0;
double LastOrderType;
double LastPricesell;
double LastPricebuy;
double LastPrice;
double OpenSells;
double OpenSellStops;
double OpenBuys;
double OpenBuyStops;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
jiancha();//检查判断
MoneyManagement();//资金管理
ma();//指标管理
zhangchang();//战场管理
TrailingStop();
CloseBuy();
CloseSell();
xianshi();
//----
return(0);
}
//+------------------------------------------------------------------+
void jiancha()
{

b=0;s=0;
for (int cnt=0; cntma3now
&& ma1now20) { SLL=Ask-SL*Point; }
OrderSend(Symbol(),OP_BUY,LotMM,Ask,slip,SLL,TPP,\"M\"+Period()+\"\",0,0,Violet);

return(0); }
//+------------------------------------------------------------------+
void sellme(){
if (TP==0) { TPP=0; } if(TP>0) { TPP=Bid-(TP*Point); }
if (SL==0) { SLL=0; } if(SL>0) { SLL=Bid+(SL*Point); }
OrderSend(Symbol(),OP_SELL,LotMM,Bid,2,SLL,TPP,\"M\"+Period()+\"\",0,0,GreenYellow);
return(0); }
//+------------------------------------------------------------------+

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

void TrailingStop()
{
for(cnt=OrdersTotal();cnt>=0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() )//&& OrderMagicNumber()==MAGICMA)
{
if (OrderType()==OP_SELL)
{
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}

if (OrderType()==OP_BUY)
{
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss() 0 )
{
for(i=OrdersTotal()-1;i 0 )
{
for(i=OrdersTotal()-1;i

偏远城市 发表于 2012-11-21 22:58:35

说的不错

小妹er 发表于 2012-11-21 22:58:35

呵呵 高高实在是高~~~~~

咬人知己 发表于 2012-11-21 22:58:35

请发一个试试,谢谢!RongYuanQiong@163.com 。。。

不要找他 发表于 2012-11-22 01:12:18

晕死也不多加点分

和其正 发表于 2012-11-22 01:12:18

支持一下吧

一招 发表于 2013-6-14 10:51:04

支持一下吧

ishnlnmt 发表于 2014-12-12 20:12:55

谢谢分享!!!!!

diamonddust77 发表于 2015-1-20 14:30:18

多谢分享 看看是什么

老张 发表于 2015-2-5 05:33:11

想学EA,拜师,谁收了我吧
页: [1] 2 3
查看完整版本: 向柒侠请教CLOSEBUY。