[求助]谁能帮我改改这个EA???
以下EA是MACD类型的,我想将它改成画线EA,意思就是我在图表上画一条线(这条线能设置正40点和负40点的幅度,点数能自己设置),当价格在画线的幅度范围内EA才运行,如果不画线或者价格没有在画线范围内EA不运行,当然最好能支持画两条线的。
先谢谢各位了
//+------------------------------------------------------------------+
//| MACD-ea.mq4 |
//| MACD-ea |
//| MACD-ea |
//+------------------------------------------------------------------+
#property copyright "MACD-ea"
#property link "MACD-ea"
/*
*/
extern int 魔术号=1;
enum 做单方向
{
多空都开=0, 开多=1,开空=2,
};
extern 做单方向 开仓方向=0;
extern int 建仓时段=5;
extern double 下单手数=0.01;
extern double 止损点数=800;
extern double 止盈点数=2000;
extern double 滑点=50;
extern bool 是否启用追踪止损=false;
extern double 追踪止损点数=600;
string 注释="MACD-ea";
int sj;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
int Ticket;
if(持仓单数量()!=0&&开空()){平买仓();}
if(持仓单数量()!=0&&开多()){平卖仓();}
if(开多()&&sj!=iTime(NULL,建仓时段,0)&&持仓单数量()==0&&(开仓方向==0||开仓方向==1))
{
Ticket=OrderSend(Symbol(),OP_BUY,下单手数,Ask,滑点,Ask-止损点数*Point,Ask+止盈点数*Point,注释,魔术号,0,Red);
if(Ticket<0)
{
Print("多单入场失败"+GetLastError());
}
if(Ticket>0)
{
}
}
if(开空()&&sj!=iTime(NULL,建仓时段,0)&&持仓单数量()==0&&(开仓方向==0||开仓方向==2))
{
Ticket=OrderSend(Symbol(),OP_SELL,下单手数,Bid,滑点,Bid+止损点数*Point,Bid-止盈点数*Point,注释,魔术号,0,Blue);
if(Ticket<0)
{
Print("空单入场失败"+GetLastError());
}
if(Ticket>0)
{
}
}
if(是否启用追踪止损)移动止损();
//----
return(0);
}
//+------------------------------------------------------------------+
bool 开多()
{
double zhu1=iMACD(NULL,建仓时段,23,52,18,PRICE_CLOSE,MODE_MAIN,1);
double zhu2=iMACD(NULL,建仓时段,23,52,18,PRICE_CLOSE,MODE_MAIN,2);
double zhu3=0;
if(zhu1>zhu3&&zhu2zhu3)return(true);
else return(false);}
int 持仓单数量()
{ int k=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if( OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==魔术号)
{k++;}
}
} return(k);
}
void 平买仓()
{
int total = OrdersTotal();
for(int i=total-1;i>=0;i--)
{
if( OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){
if(OrderSymbol()==Symbol()&&OrderType()==OP_BUY&&OrderMagicNumber()==魔术号){
bool result = false;
result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 30, Red );
if(result) Print(Symbol()+"平多单成功!!");
if(result == false)
{
Print("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
}
}}}
}
void 平卖仓()
{
int total = OrdersTotal();
for(int i=total-1;i>=0;i--)
{
if( OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){
if(OrderSymbol()==Symbol()&&OrderType()==OP_SELL&&OrderMagicNumber()==魔术号){
bool result = false;
result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 30, Red );
if(result) Print(Symbol()+"平空单成功!!");
if(result == false)
{
Print("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
}
}}}
}
void 移动止损()
{
for (int cnt=0;cnt=OrderOpenPrice())
{
if (Bid-OrderStopLoss()>Point*追踪止损点数||OrderStopLoss()==0)
{
bool chenggong= OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*追踪止损点数,OrderTakeProfit(),0,CLR_NONE);
if (chenggong)Print("单号:"+OrderTicket()+"移动止损成功");
}}
}
if (OrderType()==OP_SELL)
{
if(Ask<=OrderOpenPrice())
{
if (OrderStopLoss()-Ask>Point*追踪止损点数||OrderStopLoss()==0){
chenggong= OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*追踪止损点数,OrderTakeProfit(),0,CLR_NONE);
if (chenggong)Print("单号:"+OrderTicket()+"移动止损成功");
}}}
}
}
}
}
2楼
没人会吗???麻烦会的帮我改一改……
韬客社区www.talkfx.co