0
Опишите все подробно, желательно с картинками.
avatar

AM2

  • 26 ноября 2015, 07:24
0
Вот нашел подобный советник: zakaz.opentraders.ru/28083.html
Вспомнил свой коммент в в том топике:
Шпильки пускаешь?

Набрал в поиске, только так и нашел! :D 
avatar

AM2

  • 26 ноября 2015, 06:10
0
Это совсем не то. Тут придется долго репу чесать как это сделать.
avatar

AM2

  • 25 ноября 2015, 15:06
0
Нет не нашел, ни названия ни заказчика не помню уже. А где окси советник?
avatar

AM2

  • 25 ноября 2015, 14:38
0
Я помню тоже делал подобный, только не найду наверное.
avatar

AM2

  • 25 ноября 2015, 14:30
0
Раз в день.



//--- Inputs
extern int    StopLoss      = 500; //стоплосс отложенного ордера
extern int    TakeProfit    = 500; //тейкпрофит  отложенного ордера
extern int    BULevel       = 300; //уровень БУ
extern int    BUPoint       = 30;  //пункты БУ
extern int    TrailingStop  = 300; //трал
extern int    Delta         = 100; //расстояние от лоу или хая
extern int    CloseHour     = 23;  //время удаления отложек
extern double Lots          = 0.1; //лот
extern double Risk          = 5;   //если риск > 0 то лот динамичный
extern int    Slip          = 100; //проскальзывание ордеров
extern int    Magic         = 123; //магик

int res=0,day=0;
double sl=0,tp=0;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   Comment("");
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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);
  }
//+------------------------------------------------------------------+
int CountBSOrders()
  {
   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_BUYSTOP) count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
int CountSSOrders()
  {
   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_SELLSTOP) count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double fND(double d,int n=-1)
  {
   if(n<0) return(NormalizeDouble(d, Digits));
   return(NormalizeDouble(d, n));
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DelAllOrders()
  {
   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()==OP_BUYSTOP) del=OrderDelete(OrderTicket());
            if(OrderType()==OP_SELLSTOP) del=OrderDelete(OrderTicket());
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void PutOtlOrder()
  {
   double price;
   double ASK=MarketInfo(NULL,MODE_ASK);
   double BID=MarketInfo(NULL,MODE_BID);

   double Middle=(iHigh(Symbol(),PERIOD_D1,1)+iLow(Symbol(),PERIOD_D1,1))/2;
//--- sellstop 
   if(BID>iLow(Symbol(),PERIOD_D1,1))
     {
      if(CountSSOrders()<1)
        {
         price=fND(iLow(Symbol(),PERIOD_D1,1)-Delta*Point);
         if(StopLoss>0)   sl=price+StopLoss*Point;
         if(TakeProfit>0) tp=price-TakeProfit*Point;
         res=OrderSend(Symbol(),OP_SELLSTOP,Lot(),fND(price),0,fND(sl),fND(tp),"ОРДЕР SELLSTOP",Magic,0,Red);
        }
     }
//--- buystop 
   if(ASK<iHigh(Symbol(),PERIOD_D1,1))
     {
      if(CountBSOrders()<1)
        {
         price=fND(iHigh(Symbol(),PERIOD_D1,1)+Delta*Point);
         if(StopLoss>0)   sl=price-StopLoss*Point;
         if(TakeProfit>0) tp=price+TakeProfit*Point;
         res=OrderSend(Symbol(),OP_BUYSTOP,Lot(),fND(price),0,fND(sl),fND(tp),"ОРДЕР BUYSTOP",Magic,0,Blue);
        }
     }
   return;
  }
//+------------------------------------------------------------------+
void Trailing()
  {
   bool mod;
   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(TrailingStop>0)
                 {
                  if(Bid-OrderOpenPrice()>TrailingStop*Point)
                    {
                     if(OrderStopLoss()<Bid-TrailingStop*Point)
                       {
                        mod=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),0,Yellow);
                        return;
                       }
                    }
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if(TrailingStop>0)
                 {
                  if((OrderOpenPrice()-Ask)>TrailingStop*Point)
                    {
                     if((OrderStopLoss()>(Ask+TrailingStop*Point)) || (OrderStopLoss()==0))
                       {
                        mod=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*Point,OrderTakeProfit(),0,Yellow);
                        return;
                       }
                    }
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void BU()
  {
   bool m;
   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(OrderOpenPrice()<=Bid-BULevel*Point && OrderOpenPrice()>OrderStopLoss())
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+BUPoint*Point,OrderTakeProfit(),0,Green);
                  return;
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if(OrderOpenPrice()>=Ask+BULevel*Point && OrderOpenPrice()<OrderStopLoss())
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-BUPoint*Point,OrderTakeProfit(),0,Green);
                  return;
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Lot()
  {
   double lot=Lots;
   if(Risk>0)
     {
      lot=fND(AccountBalance()*Risk/100000,2);
     }
   if(lot==0)lot=Lots;
   return(lot);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetProfitFromDate(datetime date=0)
  {
   double profit=0;

   for(int i=0;i<OrdersHistoryTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
        {
         if(OrderSymbol()==Symbol())
           {
            if(OrderType()==OP_BUY || OrderType()==OP_SELL)
              {
               if(date<OrderCloseTime()) profit+=OrderProfit()+OrderCommission()+OrderSwap();
              }
           }
        }
     }
   return(profit);
  }
//+------------------------------------------------------------------+
//| OnTick function                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(BULevel>0) BU();
   if(Hour()==0) day=0;
   if(TrailingStop>0) Trailing();
   if(CountTrades()>0 || Hour()==CloseHour) DelAllOrders();
   if(CountTrades()<1 && day<1)
     {
      PutOtlOrder();
      day++;
     }

   Comment("\n   Account Name: ",AccountInfoString(ACCOUNT_NAME),
           "\n   Account Number: ",AccountInfoInteger(ACCOUNT_LOGIN),
           "\n   Account Balance: ",AccountInfoDouble(ACCOUNT_BALANCE),
           "\n   Account Equity: ",AccountInfoDouble(ACCOUNT_EQUITY),
           "\n   Профит за неделю: "+DoubleToString(GetProfitFromDate(TimeCurrent()-24*60*60*7),2),
           "\n   Профит за месяц: "+DoubleToString(GetProfitFromDate(TimeCurrent()-24*60*60*30),2),
           "\n   Текущее время: ",TimeToString(TimeCurrent(),TIME_DATE));
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 25 ноября 2015, 14:22
0
Сговорились что ли? :D  zakaz.opentraders.ru/29104.html
avatar

AM2

  • 25 ноября 2015, 13:35
0
Нарисуйте на скрине подробнее.
avatar

AM2

  • 25 ноября 2015, 13:31
0
Убрал время. добавил панельку:



//--- Inputs
extern int    StopLoss      = 500; //стоплосс отложенного ордера
extern int    TakeProfit    = 500; //тейкпрофит  отложенного ордера
extern int    BULevel       = 300; //уровень БУ
extern int    BUPoint       = 30;  //пункты БУ
extern int    TrailingStop  = 300; //трал
extern int    Delta         = 100; //расстояние от лоу или хая
extern int    CloseHour     = 23;  //время удаления отложек
extern double Lots          = 0.1; //лот
extern double Risk          = 5;   //если риск > 0 то лот динамичный
extern int    Count         = 1;   //количество ордеров
extern int    Slip          = 100; //проскальзывание ордеров
extern int    Magic         = 123; //магик

int res=0;
double sl=0,tp=0;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   Comment("");
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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);
  }
//+------------------------------------------------------------------+
int CountBSOrders()
  {
   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_BUYSTOP) count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
int CountSSOrders()
  {
   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_SELLSTOP) count++;
           }
        }
     }
   return(count);
  }  
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double fND(double d,int n=-1)
  {
   if(n<0) return(NormalizeDouble(d, Digits));
   return(NormalizeDouble(d, n));
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DelAllOrders()
  {
   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()==OP_BUYSTOP) del=OrderDelete(OrderTicket());
            if(OrderType()==OP_SELLSTOP) del=OrderDelete(OrderTicket());
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void PutOtlOrder()
  {
   double price;
   double ASK=MarketInfo(NULL,MODE_ASK);
   double BID=MarketInfo(NULL,MODE_BID);

   double Middle=(iHigh(Symbol(),PERIOD_D1,1)+iLow(Symbol(),PERIOD_D1,1))/2;
//--- sellstop 
   if(BID>iLow(Symbol(),PERIOD_D1,1))
     {
      if(CountSSOrders()<1)
        {
         price=fND(iLow(Symbol(),PERIOD_D1,1)-Delta*Point);
         if(StopLoss>0)   sl=price+StopLoss*Point;
         if(TakeProfit>0) tp=price-TakeProfit*Point;
         res=OrderSend(Symbol(),OP_SELLSTOP,Lot(),fND(price),0,fND(sl),fND(tp),"ОРДЕР SELLSTOP",Magic,0,Red);
        }
     }
//--- buystop 
   if(ASK<iHigh(Symbol(),PERIOD_D1,1))
     {
      if(CountBSOrders()<1)
        {
         price=fND(iHigh(Symbol(),PERIOD_D1,1)+Delta*Point);
         if(StopLoss>0)   sl=price-StopLoss*Point;
         if(TakeProfit>0) tp=price+TakeProfit*Point;
         res=OrderSend(Symbol(),OP_BUYSTOP,Lot(),fND(price),0,fND(sl),fND(tp),"ОРДЕР BUYSTOP",Magic,0,Blue);
        }
     }
   return;
  }
//+------------------------------------------------------------------+
void Trailing()
  {
   bool mod;
   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(TrailingStop>0)
                 {
                  if(Bid-OrderOpenPrice()>TrailingStop*Point)
                    {
                     if(OrderStopLoss()<Bid-TrailingStop*Point)
                       {
                        mod=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),0,Yellow);
                        return;
                       }
                    }
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if(TrailingStop>0)
                 {
                  if((OrderOpenPrice()-Ask)>TrailingStop*Point)
                    {
                     if((OrderStopLoss()>(Ask+TrailingStop*Point)) || (OrderStopLoss()==0))
                       {
                        mod=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*Point,OrderTakeProfit(),0,Yellow);
                        return;
                       }
                    }
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void BU()
  {
   bool m;
   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(OrderOpenPrice()<=Bid-BULevel*Point && OrderOpenPrice()>OrderStopLoss())
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+BUPoint*Point,OrderTakeProfit(),0,Green);
                  return;
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if(OrderOpenPrice()>=Ask+BULevel*Point && OrderOpenPrice()<OrderStopLoss())
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-BUPoint*Point,OrderTakeProfit(),0,Green);
                  return;
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Lot()
  {
   double lot=Lots;
   if(Risk>0)
     {
      lot=fND(AccountBalance()*Risk/100000,2);
     }
   if(lot==0)lot=Lots;
   return(lot);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetProfitFromDate(datetime date=0)
  {
   double profit=0;

   for(int i=0;i<OrdersHistoryTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
        {
         if(OrderSymbol()==Symbol())
           {
            if(OrderType()==OP_BUY || OrderType()==OP_SELL)
              {
               if(date<OrderCloseTime())  profit+=OrderProfit()+OrderCommission()+OrderSwap();
              }
           }
        }
     }
   return(profit);
  }  
//+------------------------------------------------------------------+
//| OnTick function                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(BULevel>0) BU();
   if(TrailingStop>0) Trailing();
   if(CountTrades()>0 || Hour()==CloseHour) DelAllOrders();
   if(CountTrades()<1) PutOtlOrder();

   Comment("\n   Account Name: ",AccountInfoString(ACCOUNT_NAME),
           "\n   Account Number: ",AccountInfoInteger(ACCOUNT_LOGIN),
           "\n   Account Balance: ",AccountInfoDouble(ACCOUNT_BALANCE),
           "\n   Account Equity: ",AccountInfoDouble(ACCOUNT_EQUITY),
           "\n   Профит за неделю: "+DoubleToString(GetProfitFromDate(TimeCurrent()-24*60*60*7),2),
           "\n   Профит за месяц: "+DoubleToString(GetProfitFromDate(TimeCurrent()-24*60*60*30),2),
           "\n   Текущее время: ",TimeToString(TimeCurrent(),TIME_DATE));
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 25 ноября 2015, 13:27
0
как это?
avatar

AM2

  • 25 ноября 2015, 13:10
0
6) вроде по настройкам и ордерам все)) теперь на инфопанеле, на валютной паре, где работает советник. если можно выводить следующую информацию: а) номер аккаунта, фамилия имя кому аккаунт принадлежит! б) время терминала! в) баланс и эквити! г) прибыль за месяц, за неделю!


Вот это по времени займет больше чем сам советник.
avatar

AM2

  • 25 ноября 2015, 13:04
0
Это не мой это цмиллионовский
avatar

AM2

  • 25 ноября 2015, 12:19
0
В базе найдите подобные моего производства для правки.
avatar

AM2

  • 25 ноября 2015, 11:23
0
Дайте ссылку на то что вы нашли на пробой дня, чтобы мне немного править было?
avatar

AM2

  • 25 ноября 2015, 11:02
0
Вы автор обратите внимание что даже на скрине видно селевые сделки когда фильтр сделок находиться в красной зоне а Ультра сигнал в синей

Автор говорил о небольшом количестве сделок. В текстовом варианте входов сигналом было совпадение цветов а на рисунке смена цвета верхнего индикатора плюс подтверждение на нижнем. Сначала сделал вариант как на рисунке, сейчас в базе лежит по совпадению цветов и закрытие при смене цвета верхнего индикатора.
avatar

AM2

  • 25 ноября 2015, 00:32
0
Вот набросок, здесь только входы и трал.


//+------------------------------------------------------------------+
//|                                                         ZiZi.mq4 |
//|                                              Copyright 2015, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2015, AM2"
#property link      "http://www.forexsystems.biz"
#property description "Simple expert advisor"

//--- Inputs
extern int    StopLoss     = 500; // лось
extern int    TakeProfit   = 500; // язь
extern int    TrailingStop = 300; // трал
extern int    Slip         = 30;  // реквот
extern int    Magic        = 123; // магик
extern double Lots         = 0.1; // лот
//----
extern int InpDepth        = 12;
extern int InpDeviation    = 5;
extern int InpBackstep     = 3;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Check for open order conditions                                  |
//+------------------------------------------------------------------+
void OpenPos()
  {
   int r=0;
   double sl=0,tp=0,pr=0;
//--- get Ind
   double ZZ0=GetExtremumZZPrice(NULL,0,0,InpDepth,InpDeviation,InpBackstep);
   double ZZ1=GetExtremumZZPrice(NULL,0,1,InpDepth,InpDeviation,InpBackstep);
   double ZZ2=GetExtremumZZPrice(NULL,0,2,InpDepth,InpDeviation,InpBackstep);
   double ZZ3=GetExtremumZZPrice(NULL,0,3,InpDepth,InpDeviation,InpBackstep);
   double ZZ4=GetExtremumZZPrice(NULL,0,4,InpDepth,InpDeviation,InpBackstep);

//--- sell conditions
   if(ZZ0>ZZ1 && ZZ1<ZZ3 && ZZ2<ZZ4)
     {
      pr=ZZ2-(ZZ2-ZZ1)/3;
      if(StopLoss>0) sl=NormalizeDouble(pr+StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(pr-TakeProfit*Point,Digits);
      r=OrderSend(Symbol(),OP_SELLSTOP,Lots,NormalizeDouble(pr,Digits),Slip,sl,tp,"",Magic,0,Red);
     }
//--- buy conditions
   if(ZZ0<ZZ1 && ZZ1>ZZ3 && ZZ2>ZZ4)
     {
      pr=ZZ2+(ZZ1-ZZ2)/3;
      if(StopLoss>0) sl=NormalizeDouble(pr-StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(pr+TakeProfit*Point,Digits);
      r=OrderSend(Symbol(),OP_BUYSTOP,Lots,NormalizeDouble(pr,Digits),Slip,sl,tp,"",Magic,0,Blue);
     }
//---
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Trailing()
  {
   bool mod;
   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(TrailingStop>0)
                 {
                  if(Bid-OrderOpenPrice()>TrailingStop*Point)
                    {
                     if(OrderStopLoss()<Bid-TrailingStop*Point)
                       {
                        mod=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),0,Yellow);
                        return;
                       }
                    }
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if(TrailingStop>0)
                 {
                  if((OrderOpenPrice()-Ask)>TrailingStop*Point)
                    {
                     if((OrderStopLoss()>(Ask+TrailingStop*Point)) || (OrderStopLoss()==0))
                       {
                        mod=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*Point,OrderTakeProfit(),0,Yellow);
                        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()==OP_BUY || OrderType()==OP_SELL) count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
int CountOrders()
  {
   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_BUYSTOP || OrderType()==OP_SELLSTOP) count++;
           }
        }
     }
   return(count);
  }
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 07.10.2006                                                     |
//|  Описание : Возвращает экстремум ЗигЗага по его номеру.                    |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (NULL или "" - текущий символ)          |
//|    tf - таймфрейм                  (      0     - текущий ТФ)              |
//|    ne - номер экстремума           (      0     - последний)               |
//|    dp - ExtDepth                                                           |
//|    dv - ExtDeviation                                                       |
//|    bs - ExtBackstep                                                        |
//+----------------------------------------------------------------------------+
double GetExtremumZZPrice(string sy="",int tf=0,int ne=0,int dp=12,int dv=5,int bs=3)
  {
   if(sy=="" || sy=="0") sy=Symbol();
   double zz;
   int    i,k=iBars(sy,tf),ke=0;

   for(i=1; i<k; i++)
     {
      zz=iCustom(sy,tf,"ZigZag",dp,dv,bs,0,i);
      if(zz!=0)
        {
         ke++;
         if(ke>ne) return(zz);
        }
     }
   Print("GetExtremumZZPrice(): Экстремум ЗигЗага номер ",ne," не найден");
   return(0);
  }
//+------------------------------------------------------------------+
//| OnTick function                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   double ZZ0=GetExtremumZZPrice(NULL,0,0,InpDepth,InpDeviation,InpBackstep);
   double ZZ1=GetExtremumZZPrice(NULL,0,1,InpDepth,InpDeviation,InpBackstep);
   double ZZ2=GetExtremumZZPrice(NULL,0,2,InpDepth,InpDeviation,InpBackstep);
   double ZZ3=GetExtremumZZPrice(NULL,0,3,InpDepth,InpDeviation,InpBackstep);
   double ZZ4=GetExtremumZZPrice(NULL,0,4,InpDepth,InpDeviation,InpBackstep);

   if(CountTrades()<1 && CountOrders()<1)
     {
      OpenPos();
     }

   if(TrailingStop>0) Trailing();

   Comment("\n ZZ0: ",ZZ0,
           "\n ZZ1: ",ZZ1,
           "\n ZZ2: ",ZZ2,
           "\n ZZ3: ",ZZ3,
           "\n ZZ4: ",ZZ4);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 24 ноября 2015, 12:31
0






Талисман? :D 
avatar

AM2

  • 24 ноября 2015, 11:12
0
Все есть: www.opentraders.ru/downloads/944/




//+------------------------------------------------------------------+
//|                                                    ZeroPoint.mq5 |
//|                                              Copyright 2015, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, AM2"
#property link      "http://www.forexsystems.biz"
#property version   "1.02"

#include <Trade\Trade.mqh>             // Подключаем торговый класс CTrade

//--- входные параметры эксперта
input int      TakeProfit = 500;       // Тейкпрофит
input int      StopLoss   = 500;       // Стоплосс
input int      BULevel    = 200;       // Уровень БУ
input int      BUPoint    = 20;        // Пункты БУ
input int      BuySell    = 1;         // 0-не торгуем 1-Buy 2-Sell
input int      AllSymbols = 1;         // 0-символ графика 1-все символы
input int      Slip       = 50;        // Проскальзывание
input double   Lot        = 0.1;       // Количество лотов для торговли 
input long     Magic      = 123;       // Магик

CTrade trade;                          // Используем торговый класс CTrade
long m=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OpenBuy()
  {
// Лучшее предложение на покупку
   double Ask=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
// Лучшее предложение на продажу                           
   double Bid=SymbolInfoDouble(_Symbol,SYMBOL_BID);
//--- готовим запрос 
   MqlTradeRequest request={0};
   request.action = TRADE_ACTION_DEAL;                                 // немедленное исполнение
   request.price = NormalizeDouble(Ask,_Digits);                       // последняя цена ask
   request.sl = NormalizeDouble(Ask - StopLoss*_Point,_Digits);        // Stop Loss
   request.tp = NormalizeDouble(Ask + TakeProfit*_Point,_Digits);      // Take Profit
   request.symbol= _Symbol;                                            // символ
   request.volume = Lot;                                               // количество лотов для торговли
   request.magic = Magic;                                              // Magic Number
   request.type = ORDER_TYPE_BUY;                                      // ордер на покупку
   request.type_filling = ORDER_FILLING_FOK;                           // тип исполнения ордера - все или ничего
   request.deviation=Slip;                                             // проскальзывание от текущей цены
//--- отправим торговый приказ 
   MqlTradeResult result={0};
   if(OrderSend(request,result))
//--- выведем в лог ответ сервера   
   Print(__FUNCTION__,":",result.comment); 
   if(result.retcode==10016) Print(result.bid,result.ask,result.price);    
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OpenSell()
  {
// Лучшее предложение на покупку
   double Ask=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
// Лучшее предложение на продажу                           
   double Bid=SymbolInfoDouble(_Symbol,SYMBOL_BID);
//--- готовим запрос 
   MqlTradeRequest request={0};
   request.action = TRADE_ACTION_DEAL;                                 // немедленное исполнение
   request.price = NormalizeDouble(Bid,_Digits);                       // последняя цена ask
   request.sl = NormalizeDouble(Bid + StopLoss*_Point,_Digits);        // Stop Loss
   request.tp = NormalizeDouble(Bid - TakeProfit*_Point,_Digits);      // Take Profit
   request.symbol= _Symbol;                                            // символ
   request.volume = Lot;                                               // количество лотов для торговли
   request.magic = Magic;                                              // Magic Number
   request.type = ORDER_TYPE_SELL;                                     // ордер на продажу
   request.deviation=Slip;                                             // проскальзывание от текущей цены
//--- отправим торговый приказ 
   MqlTradeResult result={0};
   if(OrderSend(request,result))
//--- выведем в лог ответ сервера   
   Print(__FUNCTION__,":",result.comment); 
   if(result.retcode==10016) Print(result.bid,result.ask,result.price); 
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OpenPos()
  {
// Лучшее предложение на покупку
   double Ask=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
// Лучшее предложение на продажу                           
   double Bid=SymbolInfoDouble(_Symbol,SYMBOL_BID);

//--- Стопы
   double stop=0,take=0;
//--- Buy
   if(PositionsTotal()<1 && BuySell==1)
     {
      //--- Вычисляем стопы
      if(StopLoss>0)   stop=Ask-StopLoss*_Point;
      if(TakeProfit>0) take=Ask+TakeProfit*_Point;
      //--- Открываем ордер на покупку
      //trade.PositionOpen(_Symbol,ORDER_TYPE_BUY,Lot,NormalizeDouble(Ask,_Digits),NormalizeDouble(stop,_Digits),NormalizeDouble(take,_Digits));
      OpenBuy();
     }
//--- Sell
   if(PositionsTotal()<1 && BuySell==2)
     {
      //--- Вычисляем стопы
      if(StopLoss>0)   stop=Bid+StopLoss*_Point;
      if(TakeProfit>0) take=Bid-TakeProfit*_Point;
      //--- Открываем ордер на продажу
      //trade.PositionOpen(_Symbol,ORDER_TYPE_SELL,Lot,NormalizeDouble(Bid,_Digits),NormalizeDouble(stop,_Digits),NormalizeDouble(take,_Digits));
      OpenSell();
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void BU()
  {
// Лучшее предложение на покупку
   double Ask=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
// Лучшее предложение на продажу                           
   double Bid=SymbolInfoDouble(_Symbol,SYMBOL_BID);
   double sl=0,tp=0;

   for(int i=PositionsTotal()-1;i>=0;i--)
     {
      string Symb=Symbol();
      if(AllSymbols==1)Symb=PositionGetSymbol(i);
      if(PositionSelect(Symb))
        {
         if(PositionGetInteger(POSITION_MAGIC)==Magic)
           {
            m=PositionGetInteger(POSITION_MAGIC);
            if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
              {
               if(PositionGetDouble(POSITION_PRICE_OPEN)<=Bid-BULevel*_Point)
                 {
                  if(PositionGetDouble(POSITION_PRICE_OPEN)>PositionGetDouble(POSITION_SL))
                    {
                     sl = PositionGetDouble(POSITION_PRICE_OPEN)+BUPoint*_Point;
                     tp = PositionGetDouble(POSITION_PRICE_OPEN)+TakeProfit*_Point;
                     trade.PositionModify(Symb,sl,tp);
                    }
                 }
              }

            if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL)
              {
               if(PositionGetDouble(POSITION_PRICE_OPEN)>=Ask+BULevel*_Point)
                 {
                  if(PositionGetDouble(POSITION_SL)>PositionGetDouble(POSITION_PRICE_OPEN))
                    {
                     sl = PositionGetDouble(POSITION_PRICE_OPEN)-BUPoint*_Point;
                     tp = PositionGetDouble(POSITION_PRICE_OPEN)-TakeProfit*_Point;
                     trade.PositionModify(Symb,sl,tp);
                    }
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(BuySell>0) OpenPos();
   if(BULevel>0) BU();

   Comment("\n Pos: ",PositionsTotal(),
           "\n Symb1: ",PositionGetSymbol(0),
           "\n Symb2: ",PositionGetSymbol(1),
           "\n Magic: ",m);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 24 ноября 2015, 05:01