//+------------------------------------------------------------------+
//| TJW-MACD.mq4 |
//| QQ;9393447 |
//| 15698855297 |
//+------------------------------------------------------------------+
#property copyright "QQ;9393447"
#property link "15698855297"
#property version "1.00"
#property strict
//--- input paramete
/*input int 快线=12;
input int 慢线=26;
input int 信号线=9;
input int 均线1=5;
input int 均线2=10;*/
//+------------------------------------------------------------------+
//| 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))
{
/*if(OrdersTotal()>0)
{
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()==OP_BUY)
break;
if(OrderType()==OP_SELL)
bool CL=OrderClose(OrderTicket(),OrderLots(),Ask,30,Blue);
}
}
}*/
buy(0.1,1000,2000,"b",0);
}
if((BASEP>SIGNALP)&&(BASEP<SIGNALP))
{
/*if(OrdersTotal()>0)
{
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()==OP_SELL)
break;
if(OrderType()==OP_BUY)
bool CL=OrderClose(OrderTicket(),OrderLots(),Bid,30,Blue);
}
}
}*/
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);
}
|