+1
Вчера начал делать разгонный советник, пока что он нацелен на один примитивный паттерн. Результат с начала года.


avatar

AM2

  • 21 февраля 2016, 21:16
+1
Это первый вариант:




//+------------------------------------------------------------------+
//|                                                  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;

//---- 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",250,50);
     PutLabel("На предыдущей: "+DoubleToString(MABuffer[1],Digits),"2",250,70);
     if(MABuffer[1]>MABuffer[0]) ObjectSetInteger(0,"1",OBJPROP_COLOR,Red);
     if(MABuffer[1]<MABuffer[0]) ObjectSetInteger(0,"1",OBJPROP_COLOR,Blue);
     
   return(0);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 21 февраля 2016, 20:45
0
У вас в этом месяце уже есть один заказ, но один из вариантов могу сделать. Выбирайте какой.
avatar

AM2

  • 21 февраля 2016, 19:10
0
Нет, не так. Разогнал несколько счетов, один убил. И т.д. В итоге хороший плюс — романтика!


На истории можно проверить если есть четкие входы и выходы?
avatar

AM2

  • 21 февраля 2016, 18:19
0
Отлично! Так понял, советник будет открывать ордер в дополнение к открытому?


Будет открывать если нет открытых позиций. Если нужно чтобы открыл еще одну позу меняйте магик.

В терминале по мимо этого советника ещё будет стоять клиент копировщика сигналов и свои лось и язь ему не нужны…


Ставьте стопы в 0 и их не будет.
avatar

AM2

  • 21 февраля 2016, 15:23
0
Сделал с полями:


//+------------------------------------------------------------------+
//|                                                       LotExp.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.01;     // минимальный лот
extern double Depo1     = 1000;     // депо
extern double Lot1      = 0.1;      // лот
extern double Depo2     = 2000;     // депо
extern double Lot2      = 0.2;      // лот
extern double Depo3     = 3000;     // депо
extern double Lot3      = 0.3;      // лот
extern double Depo4     = 4000;     // депо
extern double Lot4      = 0.4;      // лот
extern double Depo5     = 5000;     // депо
extern double Lot5      = 0.5;      // лот
extern double Depo6     = 6000;     // депо
extern double Lot6      = 0.6;      // лот
extern double Depo7     = 7000;     // депо
extern double Lot7      = 0.7;      // лот
extern double Depo8     = 8000;     // депо
extern double Lot8      = 0.8;      // лот
extern double Depo9     = 9000;     // депо
extern double Lot9      = 0.9;      // лот
extern double Depo10    = 10000;    // депо
extern double Lot10     = 1;        // лот


extern int StopLoss     = 500;      // лось
extern int TakeProfit   = 500;      // язь
extern int Slip         = 30;       // реквот
extern int BuySell      = 1;        // 1-buy 2-sell 0-off
extern int Magic        = 123;      // магик
//+------------------------------------------------------------------+
//| 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()<2) count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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,Lot(),NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Lot()
  {
   double lot=Lots;
   if(AccountBalance()<Depo1) lot=Lots;
   if(AccountBalance()>=Depo1 && AccountBalance()<Depo2) lot=Lot1;
   if(AccountBalance()>=Depo2 && AccountBalance()<Depo3) lot=Lot2;
   if(AccountBalance()>=Depo3 && AccountBalance()<Depo4) lot=Lot3;
   if(AccountBalance()>=Depo4 && AccountBalance()<Depo5) lot=Lot4;
   if(AccountBalance()>=Depo5 && AccountBalance()<Depo6) lot=Lot5;
   if(AccountBalance()>=Depo6 && AccountBalance()<Depo7) lot=Lot6;
   if(AccountBalance()>=Depo7 && AccountBalance()<Depo8) lot=Lot7;
   if(AccountBalance()>=Depo8 && AccountBalance()<Depo9) lot=Lot8;
   if(AccountBalance()>=Depo9 && AccountBalance()<Depo10) lot=Lot9;
   if(AccountBalance()>=Depo10) lot=Lot10;
   
   return(lot);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(CountTrades()<1)
     {
      if(BuySell==1) PutOrder(0,Ask);
      if(BuySell==2) PutOrder(1,Bid);
     }

   Comment("\n Balance: ",DoubleToString(AccountBalance(),2),
           "\n Lots: ",Lot());
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 21 февраля 2016, 14:21
0
Сейчас набросаю с полями.
avatar

AM2

  • 21 февраля 2016, 14:06
0
Здесь я делал точно такой же советник: zakaz.opentraders.ru/30200.html
avatar

AM2

  • 21 февраля 2016, 13:43
0
Укажите конкретно что должно быть в этих 10 полях? Опишите все максимально подробно, сейчас ТЗ очень расплывчатое.
avatar

AM2

  • 21 февраля 2016, 13:10
0
Я посмотрел, просто поправить тут точно не получится. Для нескольких ордеров все нужно переписывать заново. Сейчас попробую, если получится быстро сделать, будет советник :) 
avatar

AM2

  • 21 февраля 2016, 13:01
+2
Добавил общий тейк и стоп: www.opentraders.ru/downloads/1059/
Дальнейшие доработки в следующем топике, а то это будет бесконечно :) 

avatar

AM2

  • 21 февраля 2016, 11:15
0
Немного изменил закрытие. Посмотрите как будет работать: www.opentraders.ru/downloads/934/

avatar

AM2

  • 21 февраля 2016, 10:52
0
Как показывает опыт переписать заново намного проще чем править чужой код. У вас есть один заказ в этом месяце, если разместите ТЗ в следующем, тогда я буду смотреть что можно сделать.
avatar

AM2

  • 21 февраля 2016, 10:34
+1
Я свой первый усреднитель делал по по подобному уроку.
avatar

AM2

  • 21 февраля 2016, 10:19
0
Сначала делаю заказчикам от 3-го уровня и если останется свободное время остальные смотрю.
avatar

AM2

  • 21 февраля 2016, 09:47
0
Значит получается функция int CountTrades(string symb)
считает ордера отдельно по каждому символу?

В мультике да.
avatar

AM2

  • 20 февраля 2016, 20:07
0
А как прописать подсчёт ордеров для каждого символа по отдельности.


В тексте статьи все есть.
avatar

AM2

  • 20 февраля 2016, 17:03
0
Извините меня, но вы можете хоть что то отвечать когда вас просят о чем то, хотя бы да или нет.

У меня тоже выходные есть :) 
avatar

AM2

  • 20 февраля 2016, 17:01
0
Прошу Вас еще раз доработать уже доработанный Вами индикатор


Это будет уже другой заказ.
avatar

AM2

  • 20 февраля 2016, 13:00
0
2.2016.02.19 19:43:57.284 MultiHello2 USDJPYm,M1: unknown symbol name EURJPY for OrderSend function


Может с точкой надо? USDJPY.m
avatar

AM2

  • 19 февраля 2016, 20:45