или скажите как это можно сделать самому
if(CountTrades()<2)...
//+------------------------------------------------------------------+
//| Pattern.mq4 |
//| Copyright 2017, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2017, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
extern double Lots = 0.1; // торговый объем
extern int StopLoss = 300; // лось
extern int TakeProfit = 600; // язь
extern int StartHour = 0; // час начала торговли
extern int StartMin = 30; // минута начала торговли
extern int EndHour = 23; // час окончания торговли
extern int EndMin = 30; // минута окончания торговли
extern int Expiration = 3; // время истечения ордера в часах
extern int Slip = 50; // реквот
extern int Width = 1; // толщина линии
extern color Supp = Red; // цвет сопротивления
extern color Res = Blue; // цвет поддержки
extern int Magic = 123; // магик
//+------------------------------------------------------------------+
//| 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=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*3600,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool isTradeTimeInt(int hb=0,int mb=0,int he=0,int me=0)
{
datetime db, de; // Время начала и окончания работы
int hc; // Часы текущего времени торгового сервера
db=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+(string)hb+":"+(string)mb);
de=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+(string)he+":"+(string)me);
hc=TimeHour(TimeCurrent());
if(db>=de)
{
if(hc>=he) de+=24*60*60; else db-=24*60*60;
}
if(TimeCurrent()>=db && TimeCurrent()<=de) return(True);
else return(False);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutTrendLine(double pr,datetime t1,datetime t2,int width,color clr)
{
const string name="TrendLine"+TimeToStr(Time[0]);
ObjectCreate(0,name,OBJ_TREND,0,t1,pr,t2,pr);
//--- установим цвет линии
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим стиль отображения линии
ObjectSetInteger(0,name,OBJPROP_STYLE,0);
//--- установим толщину линии
ObjectSetInteger(0,name,OBJPROP_WIDTH,width);
//--- включим (true) или отключим (false) режим продолжения отображения линии вправо
ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,false);
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void OnTick()
{
if(CountTrades()<1 && isTradeTimeInt(StartHour,StartMin,EndHour,EndMin))
{
//---- buy limit
if(Close[0]>Open[0] && Close[2]<Open[2] && Bid>Open[2] && (Open[1]-Low[1])/(Close[1]-Open[1])>2 && (Open[1]-Low[1])/(High[1]-Close[1])>2)
{
if(CountOrders(2)<1) PutOrder(2,Open[2]);
PutTrendLine(Open[2],Time[10],Time[0],Width,Res);
}
//---- sell limit
if(Close[0]<Open[0] && Close[2]>Open[2] && Bid<Open[2]/**/ && (High[1]-Close[1])/(Open[1]-Close[1])>2 && (High[1]-Close[1])/(Close[1]-Low[1])>2)
{
if(CountOrders(3)<1) PutOrder(3,Open[2]);
PutTrendLine(Open[2],Time[10],Time[0],Width,Supp);
}
}
}
//+------------------------------------------------------------------+
Тогда добавьте для усреднения отдельные настройки лота, чтоб усреднение начиналось с другим лотом.
//+------------------------------------------------------------------+
//| Sovet.mq4 |
//| Copyright 2017, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
extern int HMA_period=10;
extern int HMA_price=PRICE_MEDIAN;
extern int HMA_mode=MODE_LWMA;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double ma1=iMA(NULL,0,HMA_period,0,HMA_mode,HMA_price,1);
double ma2=iMA(NULL,0,(int)MathRound(HMA_period/2),0,HMA_mode,HMA_price,1);
double ma3=(2*ma2)-(ma1);
Comment("\n MA1: ",ma1,
"\n MA2: ",ma2,
"\n MA3: ",ma3);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| HullMA.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "www.metaquotes.net"
#property indicator_chart_window
//#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Yellow
//---- input parameters
extern int HMA_period=10;
extern int HMA_price=PRICE_MEDIAN;
extern int HMA_mode=MODE_LWMA;
double ExtMapBuffer1[];
double ExtMapBuffer2[];
int draw_begin0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
IndicatorBuffers(2);
Print("cannot set indicator buffers!");
// ArraySetAsSeries(ind_buffer1,true);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
draw_begin0=HMA_period+MathFloor(MathSqrt(HMA_period));
SetIndexDrawBegin(0,draw_begin0);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("HMA("+HMA_period+")");
SetIndexLabel(0,"Hull Moving Average");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
double d1;
double d2;
int limit;
//----
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(int i=0; i<limit; i++)
{
d1=iMA(NULL,0,HMA_period,0,HMA_mode,HMA_price,i);
d2=iMA(NULL,0,MathRound(HMA_period/2),0,HMA_mode,HMA_price,i);
ExtMapBuffer2[i]=(2*d2)-(d1);
}
for(i=0; i<limit; i++)
ExtMapBuffer1[i]=iMAOnArray(ExtMapBuffer2,0,MathSqrt(HMA_period),0,MODE_LWMA,i);
//----
return(0);
}
//+------------------------------------------------------------------+
Это простая функция усреднения, как у советника Иланов, только в обе стороны.
AM2