//+------------------------------------------------------------------+
//| Test_RSI-80-20.mq4 |
//| 168魏巍 |
//| WeChat:fxea2020 |
//+------------------------------------------------------------------+
#property copyright ">>>点击在线咨询作者微信:929652338<<<"
#property link "http://wpa.qq.com/msgrd?v=3&uin=929652338&site=qq&menu=yes"
#property strict
input double lots=0.01; //交易手数
input int SL=500; //止损点数
input int TP=350; //止盈点数
extern string 观摩说明 = "建议登陆观摩做一个对比,实盘观摩同步,请大家不要盲目跟单";
extern string 服务器 = "ECMarkets-Live01";
extern string 观摩账户 = "8156003";
extern string 观摩密码 = "qwe888";
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
datetime time=D'2027.2.1 00:00';
if(TimeCurrent()>time)
{
Alert("时间到期请联系微信:929652338");
ExpertRemove();
return 0;
}
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
int buys=0; //多单持仓有几笔
int sells=0; //空单持仓有几笔
int signal=signal();
for(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==111 && OrderType()==OP_BUY)
{
buys++;
if(signal<0)
{
bool res=OrderClose(OrderTicket(),OrderLots(),Bid,0);
if(res)
{
Print("订单平仓成功");
}
return;
}
if(OrderStopLoss()==0)
{
bool res=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-SL*Point,OrderOpenPrice()+TP*Point,0);
if(res)
Print("订单修改成功");
}
}
if(OrderSymbol()==Symbol() && OrderMagicNumber()==111 && OrderType()==OP_SELL)
{
sells++;
if(OrderStopLoss()==0)
{
bool res=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+SL*Point,OrderOpenPrice()-TP*Point,0);
if(res)
Print("订单修改成功");
}
if(signal>0)
{
bool res=OrderClose(OrderTicket(),OrderLots(),Ask,0);
if(res)
{
Print("订单平仓成功");
}
return;
}
}
}
}
//---
if(signal>0 && buys==0)
{
int ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,3,0,0,"My buy order",111,0,clrGreen);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
}
else
{
Print("OrderSend placed successfully");
}
}
if(signal<0 && sells==0)
{
int ticket=OrderSend(Symbol(),OP_SELL,lots,Bid,3,0,0,"My sell order",111,0,clrRed);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
}
else
{
Print("OrderSend placed successfully");
}
}
}
//+------------------------------------------------------------------+
int signal()
{
int res=0;
//获取指标值
double rsi=iRSI(NULL,0,6,PRICE_CLOSE,1);
if(rsi<15)
{
res=1;
}
if(rsi>85)
{
res=-1;
}
return(res);
}
//+------------------------------------------------------------------+
下载的源码内容,纯纯广告码!!!! |