//+------------------------------------------------------------------+
//| Для торговли на истории.mq4 |
//| Copyright 2013, MetaQuotes Software Corp. |
//| _http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link "_http://www.metaquotes.net"
extern double sl=25;
extern double tp=100;
extern double Lot=0.1;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
double buylot;
double shelllot;
//----
if (ObjectsTotal()<0&&OrdersTotal()<1)
return(0);
string name="1";
if (ObjectFind(name)>-1)
{
double pr=NormalizeDouble(ObjectGet(name, 1), Digits);
if (pr>Ask)
{
OrderSend(Symbol(),4,Lot,pr,0,pr-sl*Point, pr+tp*Point);
}
if (pr<Ask)
{
OrderSend(Symbol(),2,Lot,pr,0,pr-sl*Point, pr+tp*Point);
}
ObjectDelete(name);
}
name="2";
if (ObjectFind(name)>-1)
{
pr=NormalizeDouble(ObjectGet(name, 1), Digits);
if (pr>Bid)
{
OrderSend(Symbol(),3,Lot,pr,0,pr+sl*Point, pr-tp*Point);
}
if (pr<Bid)
{
OrderSend(Symbol(),5,Lot,pr,0,pr+sl*Point, pr-tp*Point);
}
ObjectDelete(name);
}
buylot=0;
shelllot=0;
for (int i=0;i<=OrdersTotal();i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if (OrderType()==0)
buylot=buylot+OrderLots();
if (OrderType()==1)
shelllot=shelllot+OrderLots();
}
}
Comment("Открыто лотов на продажу _",shelllot," ","на покупку_",buylot);
//----
return(0);
}
//+------------------------------------------------------------------+