extern int Sdvig = 1; // с какой свечи считаем
с возможностью изменения цвета, размера и места расположения на графике данных значений.
Думал, предельно понятно описал что к чему в техзадании))
//+------------------------------------------------------------------+
//| ProBoy2.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 0.1; // объем позиции
extern int StopLoss = 500; // стоп лосс ордера
extern int TakeProfit = 500; // тейк профит ордера
extern int Expiration = 10; // время истечения ордера
extern int Slip = 30; // реквот
extern int Type = 0; // 0-Stop. 1-Limit
extern int Start = 11; // час торговли
extern int Count = 8; // сколько часов назад
extern int Delta = 100; // расстояние от вершин +
extern int Indent = 100; // расстояние от вершин -
extern int Magic = 333; // магик
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=clrNONE;
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*3600,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()==0 || OrderType()==1) 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);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
datetime OpenTime()
{
datetime t=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) t=OrderOpenTime();
}
}
}
return(t);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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);
}
Sleep(1000);
}
}
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double h=High[iHighest(NULL,0,MODE_HIGH,Count,0)];
double l=Low[iLowest(NULL,0,MODE_LOW,Count,0)];
if(Hour()==Start && CountTrades()<1)
{
if(Type==0)
{
if(CountOrders(4)<1 && h-Bid>Indent*Point) PutOrder(4,h+Delta*Point);
if(CountOrders(5)<1 && Bid-l>Indent*Point) PutOrder(5,l-Delta*Point);
}
if(Type==1)
{
if(CountOrders(2)<1 && h-Bid>Indent*Point) PutOrder(2,l-Delta*Point);
if(CountOrders(3)<1 && Bid-l>Indent*Point) PutOrder(3,h+Delta*Point);
}
}
if(CountTrades()>0 && TimeCurrent()-OpenTime()>Expiration*3600)
{
CloseAll();
}
}
//+------------------------------------------------------------------+
добавьте пожалуйста советнику возможность выбора торговли для ордеров, как в «Hello Lock 2».
BuySell = 0; // направление серии 0-оба. 1-бай. 2-селл.
//+------------------------------------------------------------------+
//| ProBoy2.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 0.1; // объем позиции
extern int StopLoss = 500; // стоп лосс ордера
extern int TakeProfit = 500; // тейк профит ордера
extern int Expiration = 10; // время истечения ордера
extern int Slip = 30; // реквот
extern int Type = 0; // 0-Stop. 1-Limit
extern int Start = 11; // час торговли
extern int Count = 8; // сколько часов назад
extern int Delta = 100; // расстояние от вершин +
extern int Indent = 100; // расстояние от вершин -
extern int Magic = 333; // магик
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=clrNONE;
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*3600,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()==0 || OrderType()==1) 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);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double h=High[iHighest(NULL,0,MODE_HIGH,Count,0)];
double l=Low[iLowest(NULL,0,MODE_LOW,Count,0)];
if(Hour()==Start && CountTrades()<1)
{
if(Type==0)
{
if(CountOrders(4)<1 && h-Bid>Indent*Point) PutOrder(4,h);
if(CountOrders(5)<1 && Bid-l>Indent*Point) PutOrder(5,l);
}
if(Type==1)
{
if(CountOrders(2)<1 && h-Bid>Indent*Point) PutOrder(2,l);
if(CountOrders(3)<1 && Bid-l>Indent*Point) PutOrder(3,h);
}
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Mnogitel.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern int StopLoss = 0;
extern int TakeProfit = 200;
extern int Step = 300;
extern int Slip = 30;
extern int Magic = 123;
extern double Lots = 0.1;
extern double KLot = 2;
extern double MaxLot = 5;
double Price=0,lot=Lots;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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()==OP_BUY || OrderType()==OP_SELL)
count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=clrNONE;
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);
}
if(AccountFreeMarginCheck(Symbol(),type,lot)<=0 || GetLastError()==134)
{
Print("Недостаточно средств!!!");
}
if(GetLastError()==131)
{
Print("Неправильный объем!!!");
}
if(lot>MaxLot) lot=Lots;
r=OrderSend(NULL,type,lot,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
return;
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(Bid>Price+Step*Point || Bid<Price-Step*Point)
{
PutOrder(0,Ask);
PutOrder(1,Bid);
Price=Bid;
lot*=KLot;
}
if(CountTrades()<2)
{
PutOrder(0,Ask);
PutOrder(1,Bid);
Price=Bid;
lot*=KLot;
}
Comment("\n Price: ",Price,"\n Lot: ",lot);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Mnogitel.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern int StopLoss = 0;
extern int TakeProfit = 0;
extern int Step = 300;
extern int Slip = 30;
extern int Magic = 123;
extern double Lots = 0.1;
extern double KLot = 2;
double Price=0, lot=Lots;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=clrNONE;
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;
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//--- sell conditions
if(Bid>Price+Step*Point || Bid<Price-Step*Point)
{
PutOrder(0,Ask);
PutOrder(1,Bid);
Price=Bid;
lot*=KLot;
}
Comment("\n Price: ",Price,"\n Lot: ",lot);
}
//+------------------------------------------------------------------+
В большинстве случаев можно.
AM2