www.opentraders.ru/downloads/906/

//+------------------------------------------------------------------+
//| Laban.mq4 |
//| Copyright 2015, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2015, AM2"
#property link "http://www.forexsystems.biz"
#property description "Simple expert advisor"
extern int StopLoss=200;
extern int TakeProfit=200;
extern int Slip=20;
extern int Hour_Start=8;
extern int Hour_Stop =17;
extern int Ma1 = 9;
extern int Ma2 = 22;
extern double Lots=0.01;
extern double KLot=2;
extern double KStop=2;
extern double MaxLot=5;
extern int Magic=8;
int mode=0;
bool b=true,s=true;
double stop=0,take=0;
//+------------------------------------------------------------------+
void OnTick()
{
//----
int p=0,r=0;
//---- get Indicatorrs
double ma1=iMA(NULL,0,Ma1,0,MODE_EMA,PRICE_CLOSE,1);
double ma2=iMA(NULL,0,Ma2,0,MODE_EMA,PRICE_CLOSE,1);
//----
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS)==true)
{
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue;
if(OrderType()==OP_BUY || OrderType()==OP_SELL) p++;
}
}
//---- buy
if(ma1>ma2 && b && p<1)
{
if(Hour()>=Hour_Start && Hour()<Hour_Stop)
{
r=OrderSend(Symbol(),OP_BUY,Lot(),Ask,3,Ask-stop*Point,Ask+take*Point,"",Magic,0,Blue);
b=false;
s=true;
}
}
//---- sell
if(ma1<ma2 && s && p<1)
{
if(Hour()>=Hour_Start && Hour()<Hour_Stop)
{
r=OrderSend(Symbol(),OP_SELL,Lot(),Bid,3,Bid+stop*Point,Bid-take*Point,"",Magic,0,Red);
b=true;
s=false;
}
}
Comment("\n stop: ",stop,"\n take: ",take);
//----
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Lot()
{
double lot=0;
if(OrdersHistoryTotal()==0)
{
lot=Lots;
take=TakeProfit;
stop=StopLoss;
}
if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderProfit()>0)
{
lot=Lots;
take=TakeProfit;
stop=StopLoss;
}
if(OrderProfit()<0)
{
lot=OrderLots()*KLot;
take=MathAbs((OrderOpenPrice()-OrderTakeProfit())/Point)*KStop;
stop=MathAbs((OrderOpenPrice()-OrderStopLoss())/Point)*KStop;
}
}
if(lot>MaxLot)lot=Lots;
return(lot);
}
//+------------------------------------------------------------------+
Да да, про таймфрейм еще не забудь!
AM2