2016年1月17日日曜日

あのEA清水寺をEURUSDでうごかすと...☆☆☆☆

一番良いEAに全額突っ込めれば男なのですが、なかなかそうもいきません。
リスク分散がなんたらと言うと兵頭会長に怒られそうですが、
分散思考で通貨を変えてみました。
あらwUSDJPYより成績がいいw
設定だけ微妙に調整しましたがあとは同じです。

#property copyright "Copyright 2016/1/17,TACA"
#property link      "http://mt4kyoto.blogspot.jp/"
#define MAGIC 20160117
int BandUpP = 20;  
int BandDownP = 20;
double TSProfitU = 170;
double TSProfitD =250;
double ProfitU = 110;
double ProfitD = 150;
double TSMaxRange = 0 ;
double StopLossU = 140;
double StopLossD =140;
int Spread =5 ;
extern double Lots = 0.01;          
string Comments = "Bands USDJPY m1"; // Comments
datetime TimeOld;
int Ticket = 0;
int d;
int init()
{TimeOld = Time[0];TSMaxRange = Close[0];
if (OrderSelect(0,SELECT_BY_POS) == 1)
   {if (OrderComment() == Comments){Ticket = OrderTicket();}}
return(0);}
int start()
{if (Time[0] != TimeOld){TimeOld = Time[0];
if (OrdersTotal() == 0){Ticket = 0;}
if (Ticket <=0){TSMaxRange = Close[0];}
if(OrderSelect(Ticket,SELECT_BY_TICKET) == True)
{if(OrderType()==0)
   {if (TSMaxRange < Close[0]){TSMaxRange = Close[0];}
    if (TSMaxRange - TSProfitU * Point > Close[0]){Exit();}
    else  if(OrderOpenPrice() - StopLossU * Point > Close[0]){Exit();}
          else if(OrderOpenPrice()+ProfitU*Point < Close[0]){Exit();}
   Comment("Long");}
else
   {if (TSMaxRange > Close[0]){TSMaxRange = Close[0];}
    if (TSMaxRange + TSProfitD * Point < Close[0]){Exit();}
    else  if(OrderOpenPrice() + StopLossD *Point < Close[0]){Exit();}
          else if(OrderOpenPrice()-ProfitD*Point > Close[0]){Exit();}
   Comment("Short");}
}  
   if( TBandUp(2,2) >= Close[2] && TBandUp(2,1) < Close[1] ){EntryShort();}
   if( TBandDown(2,2) <= Close[2] && TBandDown(2,1) > Close[1] ){EntryLong();}    

}    
return(0);}
int Exit()
{if (OrderClose(Ticket,Lots,OrderClosePrice(),5,Blue) == 1){Ticket = 0 ;}
   else{Exit();}
return(0);}
int EntryLong()
{if (Ticket <= 0 && MarketInfo(Symbol(),MODE_SPREAD) <= Spread)
{Ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,5,Ask - StopLossD * Point,0,Comments,MAGIC,0,Red);}
return(0);}
int EntryShort()
{if (Ticket <= 0 && MarketInfo(Symbol(),MODE_SPREAD) <= Spread)
{Ticket = OrderSend(Symbol(),OP_SELL,Lots,Bid,5,Bid + StopLossU * Point,0,Comments,MAGIC,0,Blue);}
return(0);}
double TBandDown(double Dev,int Shift){return(iBands(NULL,0,BandDownP,Dev,0,0,2,Shift));}
double TBandUp(double Dev,int Shift){return(iBands(NULL,0,BandUpP,Dev,0,0,1,Shift));}

0 件のコメント:

コメントを投稿