//+------------------------------------------------------------------+
//| kanon_trap.mq4 |
//| kanonxiss |
//| http://blog.livedoor.jp/kanonx/ |
//+------------------------------------------------------------------+
#property copyright "kanonxiss"
#property link "http://blog.livedoor.jp/kanonx/"
extern string notice2 = "ロングなら0、ショートなら1を入力";
extern int LorS = 0;
extern string notice3 = "100pipsなら1、50pipsなら0.5";
extern double nehaba = 0.4;
extern string notice4 = "100pipsなら1、50pipsなら0.5";
extern double stop = 5;
extern double limit = 0.3;
extern string notice5 = "1000通貨は0.01、1万通貨で0.1";
extern double lots = 0.1;
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int MAGIC,magictotal;
double OOP,Sstop,Slimit,Lstop,Llimit;
int start()
{
for(int cnt00 = 0; cnt00 < OrdersTotal(); cnt00++)
{
OrderSelect(cnt00, SELECT_BY_POS, MODE_TRADES);
{
if ( OrderMagicNumber() == MAGIC )
{
magictotal++;
OOP = OrderOpenPrice();
}
}
}
if(LorS == 0)
{
Lstop = Bid - stop;
Llimit = Bid + limit;
if(magictotal == 0)
{
OrderSend(Symbol(),OP_BUY,lots,Ask,3,Lstop,Llimit,"",MAGIC,0,Red);
}
if(magictotal >= 1)
{
if(Bid <= OOP - nehaba )
{
OrderSend(Symbol(),OP_BUY,lots,Ask,3,Lstop,Llimit,"",MAGIC,0,Red);
}
if(Bid >= OOP + nehaba )
{
OrderSend(Symbol(),OP_BUY,lots,Ask,3,Lstop,Llimit,"",MAGIC,0,Red);
}
}
}
if(LorS == 1)
{
Sstop = Ask + stop;
Slimit = Ask - limit;
if(magictotal == 0)
{
OrderSend(Symbol(),OP_SELL,lots,Bid,3,Sstop,Slimit,"",MAGIC,0,Blue);
}
if(magictotal >= 1)
{
if(Ask >= OOP + nehaba )
{
OrderSend(Symbol(),OP_SELL,lots,Bid,3,Sstop,Slimit,"",MAGIC,0,Blue);
}
if(Ask <= OOP - nehaba )
{
OrderSend(Symbol(),OP_SELL,lots,Bid,3,Sstop,Slimit,"",MAGIC,0,Blue);
}
}
}
return(0);
}
//+------------------------------------------------------------------+














