您需要 登录 才可以下载或查看,没有帐号?注册
//+------------------------------------------------------------------+
//| TJW-MACD.mq4 |
//| QQ;9393447 |
//| 15698855297 |
//+------------------------------------------------------------------+
#property copyright QQ;9393447
#property link 15698855297
#property version 1.00
#property strict
//--- input paramete
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int onInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void onDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void onTick(void)
{
double MA1=iMA(Symbol(),0,5,0,MODE_SMA,PRICE_CLOSE,1);
double MA2=iMA(Symbol(),0,10,0,MODE_SMA,PRICE_CLOSE,1);
double SIGNAL=iMACD(Symbol(),0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
double SIGNALP=iMACD(Symbol(),0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
double base=iMACD(Symbol(),0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
double baseP=iMACD(Symbol(),0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
if((baseP SIGNALP) (baseP SIGNALP))
{
buy(0.1,1000,2000, b ,0);
}
if((baseP SIGNALP) (baseP SIGNALP))
{
sell(0.1,300,500, s ,0);
}
//return(0);
}
int buy(double Lots,int sun,int ying,string comment,int magic)
{
int com=0;
int ticket=0;
for(int i=0;i OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if(OrderComment()==comment)
{
com=1;
}
}
}
if(com==0)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,30,Ask-sun*Point,Ask+ying*Point,comment,magic,0,clrRed);
}
return(ticket);
}
int sell(double Lots,int sun,int ying,string comment,int magic)
{
int com=0;
int ticket=0;
for(int i=0;i OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if(OrderComment()==comment)
{
com=1;
}
}
}
if(com==0)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,30,Bid+sun*Point,Bid-ying*Point,comment,magic,0,clrGreen);
}
return(ticket);
}
外汇交易有很大的风险性,本站所有资源均来自网络,请选择使用,如若出现亏损,本站不承担任何责任!