0
До вашего не добрался еще. 3 заказа висит.
avatar

AM2

  • 11 июня 2016, 22:27
0
После выходных теперь уже.
avatar

AM2

  • 10 июня 2016, 20:14
0
После выходных буду смотреть.
avatar

AM2

  • 10 июня 2016, 20:06
0
Опишите все ТЗ целиком, а то я уже запутался где должен быть какой цвет и как он должен меняться и желательно в читаемом виде не сплошняком как наверху.
avatar

AM2

  • 10 июня 2016, 16:46
0
Первое что заметил, это БУ- он так же устанавливается не цену открытия ордера…


BUPoint сколько у вас стоит?
avatar

AM2

  • 10 июня 2016, 16:27
0
Пока так. на работу нужно собираться.


//+------------------------------------------------------------------+
//|                                                  NonLagMA_v4.mq4 |
//|                                Copyright © 2006, TrendLaboratory |
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |
//|                                   E-mail: igorad2003@yahoo.co.uk |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, TrendLaboratory"
#property link      "http://finance.groups.yahoo.com/group/TrendLaboratory"


#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_width1 2
#property indicator_color2 SkyBlue
#property indicator_width2 2
#property indicator_color3 Tomato
#property indicator_width3 2


//---- input parameters
extern int     Price          = 0;
extern int     Length         = 21;
extern int     Displace       = 0;
extern int     Sdvig=0; // с какой свечи считаем
extern int     Filter         = 0;
extern int     Color          = 1;
extern int     Corner         = 1;
extern int     FontSize       = 14;
extern int     ColorBarBack   = 0;
extern double  Deviation      = 0;
extern color   LableColor     = White;

double Cycle=4;
double OpenVal=0;
//---- indicator buffers
double MABuffer[];
double UpBuffer[];
double DnBuffer[];
double price[];
double trend[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void PutLabel(string text,string name,int x,int y)
  {
   ObjectDelete(0,name);
//--- создадим текстовую метку
   ObjectCreate(0,name,OBJ_LABEL,0,0,0);
//--- установим координаты метки
   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
//--- установим угол графика, относительно которого будут определяться координаты точки
   ObjectSetInteger(0,name,OBJPROP_CORNER,Corner);
//--- установим текст
   ObjectSetString(0,name,OBJPROP_TEXT,text);
//--- установим шрифт текста
   ObjectSetString(0,name,OBJPROP_FONT,"Arial");
//--- установим размер шрифта
   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,FontSize);
//--- установим цвет
   ObjectSetInteger(0,name,OBJPROP_COLOR,LableColor);
  }
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   int ft=0;
   string short_name;
//---- indicator line
   IndicatorBuffers(5);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,MABuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,UpBuffer);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,DnBuffer);
   SetIndexBuffer(3,price);
   SetIndexBuffer(4,trend);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
   short_name="NonLagMA("+Length+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"NLMA");
   SetIndexLabel(1,"Up");
   SetIndexLabel(2,"Dn");
//----
   SetIndexShift(0,Displace);
   SetIndexShift(1,Displace);
   SetIndexShift(2,Displace);

   SetIndexDrawBegin(0,Length*Cycle+Length);
   SetIndexDrawBegin(1,Length*Cycle+Length);
   SetIndexDrawBegin(2,Length*Cycle+Length);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| NonLagMA_v4                                                      |
//+------------------------------------------------------------------+
int start()
  {
   int    i,shift,counted_bars=IndicatorCounted(),limit;
   double alfa,beta,t,Sum,Weight,g;
   double pi=3.1415926535;

   double Coeff=3*pi;
   int Phase=Length-1;
   double Len=Length*Cycle+Phase;

   if(counted_bars>0) limit=Bars-counted_bars;
   if( counted_bars < 0 )  return(0);
   if(counted_bars==0) limit=Bars-Len-1;
   if(counted_bars<1)

      for(i=1;i<Length*Cycle+Length;i++)
        {
         MABuffer[Bars-i]=0;
         UpBuffer[Bars-i]=0;
         DnBuffer[Bars-i]=0;
        }

   for(shift=limit;shift>=Sdvig;shift--)
     {
      Weight=0; Sum=0; t=0;

      for(i=0;i<=Len-1;i++)
        {
         g=1.0/(Coeff*t+1);
         if(t<= 0.5) g = 1;
         beta = MathCos(pi*t);
         alfa = g * beta;
         //if (shift>=1) price[i] = iMA(NULL,0,Per,Displace,Mode,Price,shift+i); 
         //else 
         price[i]=iMA(NULL,0,1,0,MODE_SMA,Price,shift+i);
         Sum+=alfa*price[i];
         Weight+=alfa;
         if(t<1) t+=1.0/(Phase-1);
         else if(t<Len-1) t+=(2*Cycle-1)/(Cycle*Length-1);
        }

      if(Weight>0) MABuffer[shift]=(1.0+Deviation/100)*Sum/Weight;

      if(Filter>0)
        {
         if(MathAbs(MABuffer[shift]-MABuffer[shift+1])<Filter*Point) MABuffer[shift]=MABuffer[shift+1];
        }

      if(Color>0)
        {
         trend[shift]=trend[shift+1];
         if(MABuffer[shift]-MABuffer[shift+1] > Filter*Point) trend[shift]= 1;
         if(MABuffer[shift+1]-MABuffer[shift] > Filter*Point) trend[shift]=-1;

         if(trend[shift]>0)
           {
            UpBuffer[shift]=MABuffer[shift];
            if(trend[shift+ColorBarBack]<0) UpBuffer[shift+ColorBarBack]=MABuffer[shift+ColorBarBack];
            DnBuffer[shift]=EMPTY_VALUE;
           }

         if(trend[shift]<0)
           {
            DnBuffer[shift]=MABuffer[shift];
            if(trend[shift+ColorBarBack]>0) DnBuffer[shift+ColorBarBack]=MABuffer[shift+ColorBarBack];
            UpBuffer[shift]=EMPTY_VALUE;
           }
        }
     }
     
   if(Corner==0)
     {
      PutLabel("На предыдущей: "+DoubleToString(MABuffer[1],Digits),"1",20,20);
      if(MABuffer[1]>MABuffer[0]) ObjectSetInteger(0,"1",OBJPROP_COLOR,Red);
      if(MABuffer[1]<MABuffer[0]) ObjectSetInteger(0,"1",OBJPROP_COLOR,Blue);
      if(Bid==Open[0])
        {
         PutLabel("На открытии:       "+DoubleToString(MABuffer[0],Digits),"2",20,50);
         OpenVal=MABuffer[0];
        }
      if(MABuffer[1]>OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,Blue);
      if(MABuffer[1]<OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,Red);
      if(MABuffer[1]==OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,White);

      PutLabel("На текущей:         "+DoubleToString(MABuffer[0],Digits),"3",20,80);
     }
     
   if(Corner==1)
     {
      PutLabel("На предыдущей: "+DoubleToString(MABuffer[1],Digits),"1",280,20);
      if(MABuffer[1]>MABuffer[0]) ObjectSetInteger(0,"1",OBJPROP_COLOR,Red);
      if(MABuffer[1]<MABuffer[0]) ObjectSetInteger(0,"1",OBJPROP_COLOR,Blue);
      if(Bid==Open[0])
        {
         PutLabel("На открытии:       "+DoubleToString(MABuffer[0],Digits),"2",280,50);
         OpenVal=MABuffer[0];
        }
      if(MABuffer[1]>OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,Blue);
      if(MABuffer[1]<OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,Red);
      if(MABuffer[1]==OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,White);

      PutLabel("На текущей:         "+DoubleToString(MABuffer[0],Digits),"3",280,80);
     }

   if(Corner==2)
     {
      PutLabel("На предыдущей: "+DoubleToString(MABuffer[1],Digits),"1",20,90);
      if(MABuffer[1]>MABuffer[0]) ObjectSetInteger(0,"1",OBJPROP_COLOR,Red);
      if(MABuffer[1]<MABuffer[0]) ObjectSetInteger(0,"1",OBJPROP_COLOR,Blue);
      if(Bid==Open[0])
        {
         PutLabel("На открытии:       "+DoubleToString(MABuffer[0],Digits),"2",20,60);
         OpenVal=MABuffer[0];
        }
      if(MABuffer[1]>OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,Blue);
      if(MABuffer[1]<OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,Red);
      if(MABuffer[1]==OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,White);

      PutLabel("На текущей:         "+DoubleToString(MABuffer[0],Digits),"3",20,30);
     }
     
   if(Corner==3)
     {
      PutLabel("На предыдущей: "+DoubleToString(MABuffer[1],Digits),"1",280,90);
      if(MABuffer[1]>MABuffer[0]) ObjectSetInteger(0,"1",OBJPROP_COLOR,Red);
      if(MABuffer[1]<MABuffer[0]) ObjectSetInteger(0,"1",OBJPROP_COLOR,Blue);
      if(Bid==Open[0])
        {
         PutLabel("На открытии:       "+DoubleToString(MABuffer[0],Digits),"2",280,60);
         OpenVal=MABuffer[0];
        }
      if(MABuffer[1]>OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,Blue);
      if(MABuffer[1]<OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,Red);
      if(MABuffer[1]==OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,White);

      PutLabel("На текущей:         "+DoubleToString(MABuffer[0],Digits),"3",280,30);
     }    
                
   return(0);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 10 июня 2016, 11:44
0
Я пока не соображу как сделать универсальную формулу для всех углов *think* 
avatar

AM2

  • 10 июня 2016, 11:23
+1
Пока так, смотрим на крестики и на индюк слоуп. Когда слишком большой тренд в одну сторону противоположные позы не открываем.
www.opentraders.ru/downloads/1204/


avatar

AM2

  • 10 июня 2016, 10:10
0
Можно но в отдельном топике.
avatar

AM2

  • 10 июня 2016, 09:19
0
Я вот сейчас сижу и репу чешу как мне реализовать все что вы мне тут понаписали *think* 
avatar

AM2

  • 10 июня 2016, 08:29
0
Я прошу ссылку на предыдущую версию индикатора в базе: www.opentraders.ru/downloads/
avatar

AM2

  • 10 июня 2016, 08:14
0
Дайте ссылку в базе на предыдущий, я обновлю.
avatar

AM2

  • 10 июня 2016, 07:59
0
Перенес.


//+------------------------------------------------------------------+
//|                                                  NonLagMA_v4.mq4 |
//|                                Copyright © 2006, TrendLaboratory |
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |
//|                                   E-mail: igorad2003@yahoo.co.uk |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, TrendLaboratory"
#property link      "http://finance.groups.yahoo.com/group/TrendLaboratory"


#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_width1 2
#property indicator_color2 SkyBlue
#property indicator_width2 2
#property indicator_color3 Tomato
#property indicator_width3 2


//---- input parameters
extern int     Price          = 0;
extern int     Length         = 21;
extern int     Displace       = 0;
extern int     Sdvig=0; // с какой свечи считаем
extern int     Filter         = 0;
extern int     Color          = 1;
extern int     Corner         = 1;
extern int     FontSize       = 14;
extern int     ColorBarBack   = 0;
extern double  Deviation      = 0;
extern color   LableColor     = White;

double Cycle=4;
double OpenVal=0;
//---- indicator buffers
double MABuffer[];
double UpBuffer[];
double DnBuffer[];
double price[];
double trend[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void PutLabel(string text,string name,int x,int y)
  {
   if(Corner==0 || Corner==2) x-=200;
   ObjectDelete(0,name);
//--- создадим текстовую метку
   ObjectCreate(0,name,OBJ_LABEL,0,0,0);
//--- установим координаты метки
   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
//--- установим угол графика, относительно которого будут определяться координаты точки
   ObjectSetInteger(0,name,OBJPROP_CORNER,Corner);
//--- установим текст
   ObjectSetString(0,name,OBJPROP_TEXT,text);
//--- установим шрифт текста
   ObjectSetString(0,name,OBJPROP_FONT,"Arial");
//--- установим размер шрифта
   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,FontSize);
//--- установим цвет
   ObjectSetInteger(0,name,OBJPROP_COLOR,LableColor);
  }
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   int ft=0;
   string short_name;
//---- indicator line
   IndicatorBuffers(5);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,MABuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,UpBuffer);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,DnBuffer);
   SetIndexBuffer(3,price);
   SetIndexBuffer(4,trend);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
   short_name="NonLagMA("+Length+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"NLMA");
   SetIndexLabel(1,"Up");
   SetIndexLabel(2,"Dn");
//----
   SetIndexShift(0,Displace);
   SetIndexShift(1,Displace);
   SetIndexShift(2,Displace);

   SetIndexDrawBegin(0,Length*Cycle+Length);
   SetIndexDrawBegin(1,Length*Cycle+Length);
   SetIndexDrawBegin(2,Length*Cycle+Length);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| NonLagMA_v4                                                     |
//+------------------------------------------------------------------+
int start()
  {
   int    i,shift,counted_bars=IndicatorCounted(),limit;
   double alfa,beta,t,Sum,Weight,g;
   double pi=3.1415926535;

   double Coeff=3*pi;
   int Phase=Length-1;
   double Len=Length*Cycle+Phase;

   if(counted_bars>0) limit=Bars-counted_bars;
   if( counted_bars < 0 )  return(0);
   if(counted_bars==0) limit=Bars-Len-1;
   if(counted_bars<1)

      for(i=1;i<Length*Cycle+Length;i++)
        {
         MABuffer[Bars-i]=0;
         UpBuffer[Bars-i]=0;
         DnBuffer[Bars-i]=0;
        }

   for(shift=limit;shift>=Sdvig;shift--)
     {
      Weight=0; Sum=0; t=0;

      for(i=0;i<=Len-1;i++)
        {
         g=1.0/(Coeff*t+1);
         if(t<= 0.5) g = 1;
         beta = MathCos(pi*t);
         alfa = g * beta;
         //if (shift>=1) price[i] = iMA(NULL,0,Per,Displace,Mode,Price,shift+i); 
         //else 
         price[i]=iMA(NULL,0,1,0,MODE_SMA,Price,shift+i);
         Sum+=alfa*price[i];
         Weight+=alfa;
         if(t<1) t+=1.0/(Phase-1);
         else if(t<Len-1) t+=(2*Cycle-1)/(Cycle*Length-1);
        }

      if(Weight>0) MABuffer[shift]=(1.0+Deviation/100)*Sum/Weight;

      if(Filter>0)
        {
         if(MathAbs(MABuffer[shift]-MABuffer[shift+1])<Filter*Point) MABuffer[shift]=MABuffer[shift+1];
        }

      if(Color>0)
        {
         trend[shift]=trend[shift+1];
         if(MABuffer[shift]-MABuffer[shift+1] > Filter*Point) trend[shift]= 1;
         if(MABuffer[shift+1]-MABuffer[shift] > Filter*Point) trend[shift]=-1;

         if(trend[shift]>0)
           {
            UpBuffer[shift]=MABuffer[shift];
            if(trend[shift+ColorBarBack]<0) UpBuffer[shift+ColorBarBack]=MABuffer[shift+ColorBarBack];
            DnBuffer[shift]=EMPTY_VALUE;
           }

         if(trend[shift]<0)
           {
            DnBuffer[shift]=MABuffer[shift];
            if(trend[shift+ColorBarBack]>0) DnBuffer[shift+ColorBarBack]=MABuffer[shift+ColorBarBack];
            UpBuffer[shift]=EMPTY_VALUE;
           }
        }
     }

   PutLabel("На предыдущей: "+DoubleToString(MABuffer[1],Digits),"2",280,50);
   if(MABuffer[1]>MABuffer[0]) ObjectSetInteger(0,"1",OBJPROP_COLOR,Red);
   if(MABuffer[1]<MABuffer[0]) ObjectSetInteger(0,"1",OBJPROP_COLOR,Blue);
   if(Bid==Open[0])
     {
      PutLabel("На открытии:       "+DoubleToString(MABuffer[0],Digits),"3",280,80);
      OpenVal=MABuffer[0];
     }
   if(MABuffer[0]>OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,Blue);
   if(MABuffer[0]<OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,Red);
   if(MABuffer[0]==OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,White);

   PutLabel("На текущей:         "+DoubleToString(MABuffer[0],Digits),"1",280,110);

   return(0);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 10 июня 2016, 07:32
0
Посмотрите, вроде похоже на правду:




//+------------------------------------------------------------------+
//|                                                  NonLagMA_v4.mq4 |
//|                                Copyright © 2006, TrendLaboratory |
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |
//|                                   E-mail: igorad2003@yahoo.co.uk |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, TrendLaboratory"
#property link      "http://finance.groups.yahoo.com/group/TrendLaboratory"


#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_width1 2
#property indicator_color2 SkyBlue
#property indicator_width2 2
#property indicator_color3 Tomato
#property indicator_width3 2


//---- input parameters
extern int     Price          = 0;
extern int     Length         = 21;
extern int     Displace       = 0;
extern int     Sdvig=0; // с какой свечи считаем
extern int     Filter         = 0;
extern int     Color          = 1;
extern int     Corner         = 1;
extern int     FontSize       = 14;
extern int     ColorBarBack   = 0;
extern double  Deviation      = 0;
extern color   LableColor     = White;

double Cycle=4;
double OpenVal=0;
//---- indicator buffers
double MABuffer[];
double UpBuffer[];
double DnBuffer[];
double price[];
double trend[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void PutLabel(string text,string name,int x,int y)
  {
   if(Corner==0 || Corner==2) x-=200;
//--- создадим текстовую метку
   if(ObjectFind(name)<0)
     {
      if(!ObjectCreate(0,name,OBJ_LABEL,0,0,0))
        {
         Print(__FUNCTION__,": не удалось создать текстовую метку! Код ошибки = ",GetLastError());
        }
     }
//--- установим координаты метки
   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
//--- установим угол графика, относительно которого будут определяться координаты точки
   ObjectSetInteger(0,name,OBJPROP_CORNER,Corner);
//--- установим текст
   ObjectSetString(0,name,OBJPROP_TEXT,text);
//--- установим шрифт текста
   ObjectSetString(0,name,OBJPROP_FONT,"Arial");
//--- установим размер шрифта
   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,FontSize);
//--- установим цвет
   ObjectSetInteger(0,name,OBJPROP_COLOR,LableColor);
  }
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   int ft=0;
   string short_name;
//---- indicator line
   IndicatorBuffers(5);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,MABuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,UpBuffer);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,DnBuffer);
   SetIndexBuffer(3,price);
   SetIndexBuffer(4,trend);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
   short_name="NonLagMA("+Length+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"NLMA");
   SetIndexLabel(1,"Up");
   SetIndexLabel(2,"Dn");
//----
   SetIndexShift(0,Displace);
   SetIndexShift(1,Displace);
   SetIndexShift(2,Displace);

   SetIndexDrawBegin(0,Length*Cycle+Length);
   SetIndexDrawBegin(1,Length*Cycle+Length);
   SetIndexDrawBegin(2,Length*Cycle+Length);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| NonLagMA_v4                                                     |
//+------------------------------------------------------------------+
int start()
  {
   int    i,shift,counted_bars=IndicatorCounted(),limit;
   double alfa,beta,t,Sum,Weight,g;
   double pi=3.1415926535;

   double Coeff=3*pi;
   int Phase=Length-1;
   double Len=Length*Cycle+Phase;

   if(counted_bars>0) limit=Bars-counted_bars;
   if( counted_bars < 0 )  return(0);
   if(counted_bars==0) limit=Bars-Len-1;
   if(counted_bars<1)

      for(i=1;i<Length*Cycle+Length;i++)
        {
         MABuffer[Bars-i]=0;
         UpBuffer[Bars-i]=0;
         DnBuffer[Bars-i]=0;
        }

   for(shift=limit;shift>=Sdvig;shift--)
     {
      Weight=0; Sum=0; t=0;

      for(i=0;i<=Len-1;i++)
        {
         g=1.0/(Coeff*t+1);
         if(t<= 0.5) g = 1;
         beta = MathCos(pi*t);
         alfa = g * beta;
         //if (shift>=1) price[i] = iMA(NULL,0,Per,Displace,Mode,Price,shift+i); 
         //else 
         price[i]=iMA(NULL,0,1,0,MODE_SMA,Price,shift+i);
         Sum+=alfa*price[i];
         Weight+=alfa;
         if(t<1) t+=1.0/(Phase-1);
         else if(t<Len-1) t+=(2*Cycle-1)/(Cycle*Length-1);
        }

      if(Weight>0) MABuffer[shift]=(1.0+Deviation/100)*Sum/Weight;

      if(Filter>0)
        {
         if(MathAbs(MABuffer[shift]-MABuffer[shift+1])<Filter*Point) MABuffer[shift]=MABuffer[shift+1];
        }

      if(Color>0)
        {
         trend[shift]=trend[shift+1];
         if(MABuffer[shift]-MABuffer[shift+1] > Filter*Point) trend[shift]= 1;
         if(MABuffer[shift+1]-MABuffer[shift] > Filter*Point) trend[shift]=-1;

         if(trend[shift]>0)
           {
            UpBuffer[shift]=MABuffer[shift];
            if(trend[shift+ColorBarBack]<0) UpBuffer[shift+ColorBarBack]=MABuffer[shift+ColorBarBack];
            DnBuffer[shift]=EMPTY_VALUE;
           }

         if(trend[shift]<0)
           {
            DnBuffer[shift]=MABuffer[shift];
            if(trend[shift+ColorBarBack]>0) DnBuffer[shift+ColorBarBack]=MABuffer[shift+ColorBarBack];
            UpBuffer[shift]=EMPTY_VALUE;
           }
        }
     }

   PutLabel("На текущей:         "+DoubleToString(MABuffer[0],Digits),"1",280,50);
   PutLabel("На предыдущей: "+DoubleToString(MABuffer[1],Digits),"2",280,80);
   if(MABuffer[1]>MABuffer[0]) ObjectSetInteger(0,"1",OBJPROP_COLOR,Red);
   if(MABuffer[1]<MABuffer[0]) ObjectSetInteger(0,"1",OBJPROP_COLOR,Blue);
   if(Bid==Open[0])
     {
      PutLabel("На открытии:     "+DoubleToString(MABuffer[0],Digits),"3",280,110);
      OpenVal=MABuffer[0];
     }
   if(MABuffer[0]>OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,Blue);
   if(MABuffer[0]<OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,Red);
   if(MABuffer[0]==OpenVal) ObjectSetInteger(0,"3",OBJPROP_COLOR,White);

   return(0);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 10 июня 2016, 07:15
0
Экспирацию можно поставить большое значение например 5555. Сейчас отложки удаляются при обратном сигнале, нужно закрывать позиции?
avatar

AM2

  • 10 июня 2016, 06:53
0
Я еще его для МТ5 переписал на мкл наверное будет через день два.
avatar

AM2

  • 9 июня 2016, 19:21
0
Посмотрю сегодня.
avatar

AM2

  • 9 июня 2016, 18:01
0
Да я это с другого грида переделывал.


//+------------------------------------------------------------------+
//|                                                       Grider.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 Lot          = 0.1;      // Trade volume
extern double KLot         = 1.3;      // Lot increase
extern double MaxLot       = 5;        // Maximum lot
extern int StopLoss        = 0;        // Order sroploss
extern int TakeProfit      = 0;        // Order takeprofit
extern int TrailingStop    = 0;        // Trailing stop
extern int TrailingStep    = 0;        // Trailing step
extern int Count           = 5;        // Orders count
extern int Expiration      = 55;       // The expiry of the order in hours
extern int Step            = 100;      // Order step
extern int Delta           = 100;      // Distance from the price
extern int Slip            = 3;        // Slippage
extern int RSIPer          = 14;       // Period of RSI indicator
extern int UpLevel         = 55;       // Up level of RSI indicator
extern int DnLevel         = 45;       // Dn level of RSI indicator
extern int Magic           = 123;      // Magic number
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   if(!IsTradeAllowed())Alert("Allow the EA to trade!");
   if(!IsLibrariesAllowed())Alert("Allow DLL import!");
   if(!IsExpertEnabled()) Alert("Allow startup advisors!");

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
  {
   int r=0,err=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(type),NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,TimeCurrent()+Expiration*3600,clr);
   return;
  }
//+------------------------------------------------------------------+
//| Ступенчатый трал               if(TrailingStop>0) Trailing();    |
//+------------------------------------------------------------------+
void Trailing()
  {
   bool mod;
   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)
              {
               if(Bid-OrderOpenPrice()>TrailingStop*Point)
                 {
                  if(OrderStopLoss()<Bid-(TrailingStop+TrailingStep-1)*Point)
                    {
                     mod=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-TrailingStop*Point,Digits),OrderTakeProfit(),0,Yellow);
                    }
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if((OrderOpenPrice()-Ask)>TrailingStop*Point)
                 {
                  if(OrderStopLoss()>Ask+(TrailingStop+TrailingStep-1)*Point || OrderStopLoss()==0)
                    {
                     mod=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+TrailingStop*Point,Digits),OrderTakeProfit(),0,Yellow);
                    }
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Закрытие позиции по типу ордера                                  |
//+------------------------------------------------------------------+
void CloseAll(int ot=-1)
  {
   bool cl;
   int err=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 && (ot==0 || ot==-1))
              {
               RefreshRates();
               cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),Slip,White);
              }
            if(OrderType()==1 && (ot==1 || ot==-1))
              {
               RefreshRates();
               cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),Slip,White);
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Подсчет ордеров по типу                                          |
//+------------------------------------------------------------------+
int CountOrders(int type=-1)
  {
   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 || (OrderType()>=0 && type==-1)) count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//| Профит всех ордеров по типу ордера                               |
//+------------------------------------------------------------------+
double AllProfit(int ot=-1)
  {
   double pr=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 && (ot==0 || ot==-1))
              {
               pr+=OrderProfit()+OrderCommission()+OrderSwap();
              }

            if(OrderType()==1 && (ot==1 || ot==-1))
              {
               pr+=OrderProfit()+OrderCommission()+OrderSwap();
              }
           }
        }
     }
   return(pr);
  }
//+------------------------------------------------------------------+
//| Лот для усреднителя                                              |
//+------------------------------------------------------------------+
double Lots(int type)
  {
   double lots=Lot;
   lots=NormalizeDouble(Lot*MathPow(KLot,CountOrders(type)),2);
   if(lots>MaxLot)lots=Lot;
   return(lots);
  }
//+------------------------------------------------------------------+
//| Удаление отложенных ордеров                                      |
//+------------------------------------------------------------------+
void DelOrder(int type)
  {
   bool del;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==type) del=OrderDelete(OrderTicket());
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   double rsi1=iRSI(NULL,0,RSIPer,PRICE_CLOSE,1);
   double rsi2=iRSI(NULL,0,RSIPer,PRICE_CLOSE,2);

   if(TrailingStop>0) Trailing();

   if(CountOrders(-1)<1)
     {
      for(int i=0; i<Count;i++)
        {         
         if(rsi2<DnLevel && rsi1>DnLevel) {DelOrder(5); PutOrder(4,Bid+Delta*Point+Step*Point*i);}//buystop
         if(rsi2>UpLevel && rsi1<UpLevel) {DelOrder(4); PutOrder(5,Bid-Delta*Point-Step*Point*i);}//sellstop  
        }
     }

   Comment("\n All Profit: ",AllProfit(-1),
           "\n Buy Profit:  ",AllProfit(0),
           "\n Sell Profit: ",AllProfit(1),
           "\n Buy Positions:  ",CountOrders(0),
           "\n Sell Positions: ",CountOrders(1),
           "\n All Positions:  ",CountOrders(0)+CountOrders(1));
  }
//+------------------------------------------------------------------+




avatar

AM2

  • 9 июня 2016, 17:51
0
Я еще посмотрю вечером отличаются или нет значения закрытия и открытия.
avatar

AM2

  • 9 июня 2016, 12:10