
//+------------------------------------------------------------------+
//| Pattern.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2016, AM2"
#property link "http://www.forexsystems.biz"
extern int StopLoss = 300; // лось
extern int TakeProfit = 600; // язь
extern int Slip = 50; // реквот
extern int MAPeriod = 9; // период МА
extern int MAMethod = 0; // метод МА
extern int Magic = 123; // магик
extern double Lots = 0.1; // торговый объем
//+------------------------------------------------------------------+
//| Установка ордера |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=Green;
double sl=0,tp=0;
if(type==1 || type==3 || type==5)
{
clr=Red;
if(StopLoss>0) sl=NormalizeDouble(price+StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
if(StopLoss>0) sl=NormalizeDouble(price-StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
}
r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountTrades()
{
int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()<2) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool Star()
{
if(Close[4]>Open[4] && Open[4]-Low[4]<Close[4]-Open[4] && (High[4]-Close[4])/(Close[4]-Open[4])>2 && High[4]>High[3] && High[4]>High[2] && High[4]>High[1] && High[4]>High[5] && High[4]>High[6] && High[4]>High[7]) return(true);
else return(false);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool Hammer()
{
if(Close[4]<Open[4] && High[4]-Open[4]<Open[4]-Close[4] && (Close[4]-Low[4])/(Open[4]-Close[4])>2 && Low[4]<Low[3] && Low[4]<Low[2] && Low[4]<Low[1] && Low[4]<Low[5] && Low[4]<Low[6] && Low[4]<Low[7]) return(true);
else return(false);
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void OnTick()
{
double ma=iMA(NULL,0,MAPeriod,0,MAMethod,0,1);
if(CountTrades()<1)
{
//---- buy
if(Hammer())
{
PutOrder(0,Ask);
}
//---- sell
if(Star())
{
PutOrder(1,Bid);
}
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| DeltaMA.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2016, AM2"
#property link "http://www.forexsystems.biz"
extern int StopLoss = 1200; // лось
extern int TakeProfit = 1400; // язь
extern int Delta = 400; // расстояние открытия
extern int Sigma = 100; // расстояние закрытия
extern int Slip = 50; // реквот
extern int MAPeriod = 9; // период МА
extern int Magic = 123; // магик
extern double Profit = 5; // профит от депо в %
extern double Lots = 0.1; // торговый объем
extern double MaxLot = 5; // аксимальный торговый объем
extern double KLot = 2; // увеличение лота
datetime t=0;
//+------------------------------------------------------------------+
//| Установка ордера |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=Green;
double sl=0,tp=0;
if(type==1 || type==3 || type==5)
{
clr=Red;
if(StopLoss>0) sl=NormalizeDouble(price+StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
if(StopLoss>0) sl=NormalizeDouble(price-StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
}
r=OrderSend(NULL,type,Lot(),NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountTrades()
{
int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()<2) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double FindLastBuyPrice()
{
int oticket,ticketNumber=0;
double oprice=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==OP_BUY)
{
oticket=OrderTicket();
if(oticket>ticketNumber)
{
ticketNumber=oticket;
oprice=OrderOpenPrice();
}
}
}
}
return(oprice);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double FindLastSellPrice()
{
int oticket,ticketNumber=0;
double oprice=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==OP_SELL)
{
oticket=OrderTicket();
if(oticket>ticketNumber)
{
ticketNumber=oticket;
oprice=OrderOpenPrice();
}
}
}
}
return(oprice);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CloseAll()
{
bool cl;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderMagicNumber()==Magic || OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY) cl=OrderClose(OrderTicket(),OrderLots(),Bid,Slip,Blue);
if(OrderType()==OP_SELL) cl=OrderClose(OrderTicket(),OrderLots(),Ask,Slip,Red);
}
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Lot()
{
double lot=Lots;
if(CountTrades()>0) lot=NormalizeDouble(Lots*MathPow(KLot,CountTrades()),2);
if(lot>MaxLot)lot=Lots;
return(lot);
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void OnTick()
{
double ma=iMA(NULL,0,MAPeriod,0,0,0,1);
double BALANCE=AccountInfoDouble(ACCOUNT_BALANCE);
double EQUITY=AccountInfoDouble(ACCOUNT_EQUITY);
double Pr=100*(EQUITY-BALANCE)/BALANCE;
if(t!=Time[0])
{
//---- buy
if(Ask>ma+Delta*Point)
{
PutOrder(0,Ask);
}
//---- sell
if(Bid<ma-Delta*Point)
{
PutOrder(1,Bid);
}
t=Time[0];
}
if((FindLastBuyPrice()>0 && Bid<ma+Sigma*Point) || (FindLastSellPrice()>0 && Bid>ma-Sigma*Point) || (Pr>Profit)) CloseAll();
Comment("\n Equity Profit: ",Pr);
//----
}
//+------------------------------------------------------------------+
Мне не нужны «Поглощение». Используем эти: «Молот», Перевернутый молот", «Утренняя звезда», «Падающая звезда», «Вечерняя звезда», «Повешенный», «Бычье и медвежье харами». Харами даже не обязательно. Принцип один. Появилась разворотная свеча — ждем закрепления цены выше/ниже МАшки. Если закрепилась в течении к примеру 5 свечей — открываем ордер, если нет — игнор.
if(sigma>Sigma*Point)
if(CountTrades()<1 && t!=Time[0])
if(High[3]>High[2] && High[3]>High[1] && High[3]>High[4] && High[3]>High[5])
if(Low[3]<Low[2] && Low[3]<Low[1] && Low[3]<Low[4] && Low[3]<Low[5])
{
if(CountOrders(4)<1) PutOrder(4,High[3]+Delta*Point);
if(CountOrders(5)<1) PutOrder(5,Low[3]-Delta*Point);
t=Time[0];
}
AM2