что тех задание надо грамотно оформить.
extern string StartTime = "03:30:30";
//+------------------------------------------------------------------+
//| Delta.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2016, AM2"
#property link "http://www.forexsystems.biz"
#property description "Forex expert advisor"
//--- Inputs
extern int StopLoss = 333; // лось
extern int TakeProfit = 333; // язь
extern int Delta = 33; // расстояние от цены до ордера
extern int BuySell = 0; // 0-оба 1-бай 2-селл
extern int Slip = 3; // проскальзывание ордера
extern int Expiration = 60; // истечение ордера в минутах
extern int TickVolume = 33; // тиковый объем
extern double Lots = 0.3; // объем позиции
extern int Magic = 333; // магик
extern string StartTime = "03:30:30";
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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,TimeCurrent()+Expiration*60,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void DelOrders()
{
bool del=true;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderMagicNumber()==Magic || OrderSymbol()==Symbol())
{
if(OrderType()>3) del=OrderDelete(OrderTicket());
}
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountOrders(int type)
{
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()==type) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| OnTick function |
//+------------------------------------------------------------------+
void OnTick()
{
long v=iVolume(NULL,0,0);
if(CountTrades()<1 && v>TickVolume)
{
if(TimeCurrent()>=StringToTime(StartTime))
{
if((BuySell==1 || BuySell==0) && CountOrders(4)<1)PutOrder(4,Ask+Delta*Point);
if((BuySell==2 || BuySell==0) && CountOrders(5)<1) PutOrder(5,Ask-Delta*Point);
}
}
if(CountTrades()>0) DelOrders();
Comment("\n Volume: ", v,
"\n Time: ", TimeToString(TimeCurrent(),TIME_SECONDS));
}
//+------------------------------------------------------------------+
AM2