游戏王卡牌力量6 好感:MT4 单手测试模板
#define MAGICMA 20120117
extern double Lots = 1;
extern double MovingPeriod1 = 22;
extern double MovingPeriod2 = 5;
extern double MovingPeriod3 = 55;
extern double MovingShift = 0;
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void CheckForOpen()
{
double ma22;
double ma5h;
double ma5l;
double ma22y;
double ma5hy;
double ma5ly;
double ma55;
double ma5;
int res;
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//---- get Moving Average
ma5=iMA(NULL,0,MovingPeriod2,MovingShift,MODE_EMA,PRICE_CLOSE,0);
ma22=iMA(NULL,0,MovingPeriod1,MovingShift,MODE_EMA,PRICE_CLOSE,0);
ma5h=iMA(NULL,0,MovingPeriod2,MovingShift,MODE_EMA,PRICE_HIGH,0);
ma5l=iMA(NULL,0,MovingPeriod2,MovingShift,MODE_EMA,PRICE_LOW,0);
ma22y=iMA(NULL,0,MovingPeriod1,MovingShift,MODE_EMA,PRICE_CLOSE,1);
ma5hy=iMA(NULL,0,MovingPeriod2,MovingShift,MODE_EMA,PRICE_HIGH,1);
ma5ly=iMA(NULL,0,MovingPeriod2,MovingShift,MODE_EMA,PRICE_LOW,1);
ma55=iMA(NULL,0,MovingPeriod3,MovingShift,MODE_EMA,PRICE_CLOSE,0);
//---- sell conditions
if(ma5l
res=OrderSend(Symbol
(),OP_SELL,Lots,Bid,3,0,0,"",MAGICMA,0,MediumSpringGreen);
return;
}
//---- buy conditions
if(ma5l>ma55&&ma5ly
{
res=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"",MAGICMA,0,Red);
return;
}
//----
}
//+------------------------------------------------------------------+
//| Check for close order conditions |
//+------------------------------------------------------------------+
void CheckForClose()
{
double ma10l;
double ma10h;
double ma22;
double ma22l;
double ma22h;
double ma5l;
double ma5h;
double ma55l;
double ma55h;
double TDSX;
double TDXX;
double ZDZS;
double ZKZS;
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//---- get Moving Average
ma22l=iMA(NULL,0,MovingPeriod1,MovingShift,MODE_EMA,PRICE_LOW,0);
ma5h=iMA(NULL,0,MovingPeriod2,MovingShift,MODE_EMA,PRICE_HIGH,0);
ma5l=iMA(NULL,0,MovingPeriod2,MovingShift,MODE_EMA,PRICE_LOW,0);
TDSX=iCustom(NULL,0,"TD",22,22,22,0,0,0);
TDXX=iCustom(NULL,0,"TD",22,22,22,0,1,0);
ZDZS=Low[iLowest(NULL,0,PRICE_LOW,3,0)];
ZKZS=High[iHighest(NULL,0,MODE_HIGH,3,0)];
ma10h=iMA(NULL,0,10,MovingShift,MODE_EMA,PRICE_HIGH,0);
ma10l=iMA(NULL,0,10,MovingShift,MODE_EMA,PRICE_LOW,0);
///----
for(int i=0;i
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)
break;
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol())
continue;
//---- check order type
if(OrderType()==OP_BUY)
{
if(Close[0]
(),OrderLots(),Bid,3,White);
}
if(OrderType()==OP_SELL)
{
if(Close[0]>|| Close[0]>TDXX) OrderClose(OrderTicket
(),OrderLots(),Ask,3,White);
}
}
//----
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void start()
{
//---- check for history and trading
if(Bars<100 || IsTradeAllowed()==false) return;
//----
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==false)
CheckForOpen();
else
CheckForClose();
//----
}
//+------------------------------------------------------------------+