0
Если можно вытащить значения из индикатора, сделаю.
avatar

AM2

  • 14 ноября 2015, 20:29
0
Завтра добавлю.
avatar

AM2

  • 14 ноября 2015, 20:26
0
Завтра посмотрю, что можно сделать.
avatar

AM2

  • 14 ноября 2015, 20:26
0
Я сейчас не берусь за платные заказы, с этим вам сюда: www.mql5.com/ru/job
avatar

AM2

  • 13 ноября 2015, 17:43
0
У вас в архиве илан рси, а чем не устраивают иланы с уже добавленными функциями локов?
avatar

AM2

  • 13 ноября 2015, 16:08
0
Еще кое что поправил:


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

//------- Внешние параметры советника --------------------+
extern double Lot     = 0.01;      // Лот buy/sell ордера
extern double Lot1    = 0.02;      // Лот 1-го limit ордера
extern double Lot2    = 0.04;      // Лот 2-го limit ордера
extern double Lot3    = 0.07;      // Лот 3-го limit ордера
extern double Lot4    = 0.15;      // Лот 4-го limit ордера
extern double Lot5    = 0.3;       // Лот 5-го limit ордера
extern double Lot6    = 0.6;       // Лот 6-го limit ордера
extern double Lot7    = 1.2;       // Лот 7-го limit ордера
extern double Lot8    = 2.5;       // Лот 8-го limit ордера
extern double Lot9    = 5.0;       // Лот 9-го limit ордера
extern double Lot10   = 10.0;      // Лот 10-го limit ордера

extern int    Step1   = 50;        // Шаг 1-го limit ордера
extern int    Step2   = 50;        // Шаг 2-го limit ордера
extern int    Step3   = 50;        // Шаг 3-го limit ордера
extern int    Step4   = 50;        // Шаг 4-го limit ордера
extern int    Step5   = 50;        // Шаг 5-го limit ордера
extern int    Step6   = 50;        // Шаг 6-го limit ордера
extern int    Step7   = 50;        // Шаг 7-го limit ордера
extern int    Step8   = 50;        // Шаг 8-го limit ордера
extern int    Step9   = 50;        // Шаг 9-го limit ордера
extern int    Step10  = 50;        // Шаг 10-го limit ордера

extern int    TP      = 30;        // Take profit buy/sell ордера
extern int    TP1     = 30;        // Take profit после 1-го limit ордера
extern int    TP2     = 30;        // Take profit после 2-го limit ордера
extern int    TP3     = 30;        // Take profit после 3-го limit ордера
extern int    TP4     = 30;        // Take profit после 4-го limit ордера
extern int    TP5     = 30;        // Take profit после 5-го limit ордера
extern int    TP6     = 30;        // Take profit после 6-го limit ордера
extern int    TP7     = 30;        // Take profit после 7-го limit ордера
extern int    TP8     = 30;        // Take profit после 8-го limit ордера
extern int    TP9     = 30;        // Take profit после 9-го limit ордера
extern int    TP10    = 30;        // Take profit после 10-го limit ордера

extern int    SL      = 400;       // Stop Loss для всех ордеров
extern int    Slip    = 30;        // Проскальзывание цены
extern int    Magic   = 123;       // Идентификатор ордера

int k=0;
int tp[10],step[10];
double lot[10];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   //k=0;
   tp[0]=TP;
   tp[1]=TP1;
   tp[2]=TP2;
   tp[3]=TP3;
   tp[4]=TP4;
   tp[5]=TP5;
   tp[6]=TP6;
   tp[7]=TP7;
   tp[8]=TP8;
   tp[9]=TP9;
   tp[10]=TP10;

   step[0]=Step1;
   step[1]=Step1;
   step[2]=Step2;
   step[3]=Step3;
   step[4]=Step4;
   step[5]=Step5;
   step[6]=Step6;
   step[7]=Step7;
   step[8]=Step8;
   step[9]=Step9;
   step[10]=Step10;

   lot[0]=Lot;
   lot[1]=Lot1;
   lot[2]=Lot2;
   lot[3]=Lot3;
   lot[4]=Lot4;
   lot[5]=Lot5;
   lot[6]=Lot6;
   lot[7]=Lot7;
   lot[8]=Lot8;
   lot[9]=Lot9;
   lot[10]=Lot10;

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason) {  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountTrades()
  {
   int count=0;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY || OrderType()==OP_SELL)
               count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int LastDealResult()
  {
   int result=0;
   if(OrdersHistoryTotal()==0)
     {
      result=0;
     }
   if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
     {
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
        {
         if(OrderProfit()>0)
           {
            result=1;//tp  
           }
         if(OrderProfit()<0)
           {
            result=2;//sl  
           }
        }
     }
   return(result);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int LastDealType()
  {
   int type=0;
   if(OrdersHistoryTotal()==0)
     {
      type=0;
     }
   if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
     {
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
        {
         if(OrderType()==OP_BUY)
           {
            type=1;//buy  
           }
         if(OrderType()==OP_SELL)
           {
            type=2;//sell  
           }
        }
     }
   return(type);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DelBuyLimitOrder()
  {
   bool del;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
        {
         if(OrderMagicNumber()!=Magic || OrderSymbol()!=Symbol()) continue;
           {
            if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
            if(OrderType()==OP_BUYLIMIT) del=OrderDelete(OrderTicket());
           }
        }
     }
   return;
  }
//+------------------------------------------------------------------+
void DelSellLimitOrder()
  {
   bool del;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
        {
         if(OrderMagicNumber()!=Magic || OrderSymbol()!=Symbol()) continue;
           {
            if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
            if(OrderType()==OP_SELLLIMIT) del=OrderDelete(OrderTicket());
           }
        }
     }
   return;
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   int res=0;
   double pr=0;
   if(k>10) k=1;

//когда нет позиций
   if(CountTrades()<1)
     {
      res=OrderSend(Symbol(),OP_BUY,Lot,Ask,Slip,Ask-SL*Point,Ask+TP*Point,"",Magic,0,Blue);
      res=OrderSend(Symbol(),OP_SELL,Lot,Bid,Slip,Bid+SL*Point,Bid-TP*Point,"",Magic,0,Red);
      k++;
      pr=Ask-Step1*Point;
      res=OrderSend(Symbol(),OP_BUYLIMIT,Lot1,pr,0,pr-SL*Point,Ask+TP1*Point,"",Magic,0,Blue);
      pr=Bid+Step1*Point;
      res=OrderSend(Symbol(),OP_SELLLIMIT,Lot1,pr,0,pr+SL*Point,Bid-TP1*Point,"",Magic,0,Red);
      return;
     }

//когда есть позы и sell закрылся по ТП
   if(CountTrades()>0 && LastDealResult()==1 && LastDealType()==2)
     {
      k++;
      DelSellLimitOrder();
      res=OrderSend(Symbol(),OP_SELL,Lot,Bid,Slip,Bid+SL*Point,Bid-TP*Point,"",Magic,0,Red);
      pr=Bid+step[k]*Point;
      res=OrderSend(Symbol(),OP_SELLLIMIT,lot[k],pr,0,pr+SL*Point,pr-tp[k]*Point,"",Magic,0,Red);
      pr=Ask-step[k]*Point;
      res=OrderSend(Symbol(),OP_BUYLIMIT,lot[k],pr,0,pr-SL*Point,pr+tp[k]*Point,"",Magic,0,Blue);      
      return;
     }

//когда есть позы и buy закрылся по ТП
   if(CountTrades()>0 && LastDealResult()==1 && LastDealType()==1)
     {
      k++;
      DelBuyLimitOrder();
      res=OrderSend(Symbol(),OP_BUY,Lot,Ask,Slip,Ask-SL*Point,Ask+TP*Point,"",Magic,0,Blue);
      pr=Ask-step[k]*Point;
      res=OrderSend(Symbol(),OP_BUYLIMIT,lot[k],pr,0,pr-SL*Point,pr+tp[k]*Point,"",Magic,0,Blue);
      pr=Bid+step[k]*Point;
      res=OrderSend(Symbol(),OP_SELLLIMIT,lot[k],pr,0,pr+SL*Point,pr-tp[k]*Point,"",Magic,0,Red);      
      return;
     }
   Comment("\n K:    ",k,
           "\n TP:   ",tp[k],
           "\n Lot:  ",lot[k],
           "\n Step: ",step[k]);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 13 ноября 2015, 09:33
+1
В мой алгоритм не нужно ничего встраивать, никаких индикаторов ни чего, всего лишь чтобы он верно выставлял ордера…


Это вам только кажется что все так просто
avatar

AM2

  • 13 ноября 2015, 08:56
0
У меня сейчас стоит на отладке, первую серию выставляет правильно, смотрю дальше.
avatar

AM2

  • 13 ноября 2015, 08:52
0
Если индикатор дает сигнал, то можно и сопроводить и открыть :) 
avatar

AM2

  • 13 ноября 2015, 08:48
0
Сеточники требуют длительной отладки. Я как то взялся за пятнашку делать то за что другие просили 70-80, вроде простой алгоритм был, так потом заказчик с меня целый месяц не слезал! :D 
avatar

AM2

  • 13 ноября 2015, 06:50
+1
Поправил:


//--------------------------------------------------------------------
// modifystoploss.mq4
// Предназначен для использования в качестве примера в учебнике MQL4.
//--------------------------------------------------------------------
extern int Tral_Stop=100;                        // Дист. преследования
//--------------------------------------------------------------- 1 --
int start() // Спец. функция start
  {
   string Symb=Symbol();                        // Финанс. инструмент

//--------------------------------------------------------------- 2 --
   for(int i=1; i<=OrdersTotal(); i++) // Цикл перебора ордер
     {
      if(OrderSelect(i-1,SELECT_BY_POS)==true) // Если есть следующий
        {                                       // Анализ ордеров:
         int Tip=OrderType();                   // Тип ордера
         if(OrderSymbol()!=Symb||Tip>1)continue;// Не наш ордер
         double SL=OrderStopLoss();             // SL выбранного орд.
         //------------------------------------------------------ 3 --
         while(true) // Цикл модификации
           {
            double TS=Tral_Stop;                // Исходное значение
            int Min_Dist=MarketInfo(Symb,MODE_STOPLEVEL);//Миним. дист
            if(TS<Min_Dist) // Если меньше допуст.
               TS=Min_Dist;                     // Новое значение TS
            //--------------------------------------------------- 4 --
            bool Modify=false;                  // Не назначен к модифи
            switch(Tip)                         // По типу ордера
              {
               case 0 :                         // Ордер Buy
                  if(NormalizeDouble(SL,Digits)<NormalizeDouble(Bid-TS*Point,Digits))// Если ниже желаем.
                    {
                     SL=Bid-TS*Point;           // то модифицируем его
                     if(SL<OrderOpenPrice())
                       {
                        string Text="Buy ";        // Текст для Buy 
                        Modify=true;               // Назначен к модифи.
                       }
                    }
                  break;                        // Выход из switch
               case 1 :                         // Ордер Sell
                  if(NormalizeDouble(SL,Digits)>NormalizeDouble(Ask+TS*Point,Digits) || NormalizeDouble(SL,Digits)==0)//или равно нулю// Если выше желаем.
                    {
                     SL=Ask+TS*Point;           // то модифицируем его
                     if(SL>OrderOpenPrice())
                       {
                        Text="Sell ";              // Текст для Sell 
                        Modify=true;               // Назначен к модифи.
                       }
                    }
              }                                 // Конец switch
            if(Modify==false) // Если его не модифи
               break;                           // Выход из while
            //--------------------------------------------------- 5 --
            double TP    =OrderTakeProfit();    // TP выбранного орд.
            double Price =OrderOpenPrice();     // Цена выбранн. орд.
            int    Ticket=OrderTicket();        // Номер выбранн. орд.

            Alert("Модификация ",Text,Ticket,". Ждём ответ..");
            bool Ans=OrderModify(Ticket,Price,SL,TP,0);//Модифи его!
            //--------------------------------------------------- 6 --
            if(Ans==true) // Получилось <img src='http://opentraders.ru/templates/skin/g6h/images/smilies/002.gif' alt=' :) '> 
              {
               Alert("Ордер ",Text,Ticket," модифицирован<img src='http://opentraders.ru/templates/skin/g6h/images/smilies/002.gif' alt=' :) '> ");
               break;                           // Из цикла модифи.
              }
            //--------------------------------------------------- 7 --
            int Error=GetLastError();           // Не получилось <img src='http://opentraders.ru/templates/skin/g6h/images/smilies/005.gif' alt=' ( '> 
            switch(Error)                       // Преодолимые ошибки
              {
               case 130:Alert("Неправильные стопы. Пробуем ещё раз.");
               RefreshRates();               // Обновим данные
               continue;                     // На след. итерацию
               case 136:Alert("Нет цен. Ждём новый тик..");
               while(RefreshRates()==false)  // До нового тика
                  Sleep(1);                  // Задержка в цикле
               continue;                     // На след. итерацию
               case 146:Alert("Подсистема торгов занята.Пробуем ещё");
               Sleep(500);                   // Простое решение
               RefreshRates();               // Обновим данные
               continue;                     // На след. итерацию
                                             // Критические ошибки
               case 2 : Alert("Общая ошибка.");
               break;                        // Выход из switch
               case 5 : Alert("Старая версия клиентского терминала.");
               break;                        // Выход из switch
               case 64: Alert("Счет заблокирован.");
               break;                        // Выход из switch
               case 133:Alert("Торговля запрещена");
               break;                        // Выход из switch
               default: Alert("Возникла ошибка ",Error);//Др. ошибки
              }
            break;                              // Из цикла модифи.
           }                                    // Конец цикла модифи.
         //------------------------------------------------------ 8 --
        }                                       // Конец анализа орд.
     }                                          // Конец перебора орд.

   if(IsTesting() && OrdersTotal()<1)
     {
     int r=0;
      //r=OrderSend(Symbol(),OP_SELL,0.1,Bid,50,Bid+500*Point,Bid-1500*Point,"",123,0,Red);
      r=OrderSend(Symbol(),OP_BUY,0.1,Ask,50,Ask-500*Point,Ask+1500*Point,"",123,0,Blue);
     }
//--------------------------------------------------------------- 9 --
   return(0);                                      // Выход из start()
  }
//-------------------------------------------------------------- 10 --

avatar

AM2

  • 13 ноября 2015, 00:37
0
Вот эта версия:


//+------------------------------------------------------------------+
//|                                                       Shifer.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 double Lots      = 0.1;      // лот
extern int StopLoss     = 500;      // лось
extern int TakeProfit   = 500;      // язь
extern int BULevel      = 300;      // уровень бу
extern int BUPoint      = 30;       // пункты бу
extern int TrailingStop = 400;      // трал
extern int Slip         = 30;       // реквот
extern int Magic        = 123;      // магик
extern string IndicatorProperties="--------------------";
extern int IndPeriod    = 12;
extern int IndShift     = 3;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Comment("");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//| Check for open order conditions                                  |
//+------------------------------------------------------------------+
void OpenPos()
  {
   int    r=0;
   double sl=0,tp=0;
//--- get Ind
   double FGreen=iCustom(Symbol(),0,"Fisher",IndPeriod,0,1);
   double FRed=iCustom(Symbol(),0,"Fisher",IndPeriod,1,1);
   double ShiftFGreen=iCustom(Symbol(),0,"Fisher",IndPeriod,0,IndShift);
   double ShiftFRed=iCustom(Symbol(),0,"Fisher",IndPeriod,1,IndShift);

//--- sell conditions
   if(FGreen<0 && (LastDealType()==1 || LastDealType()==0))
     {
      if(StopLoss>0) sl=NormalizeDouble(Bid+StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(Bid-TakeProfit*Point,Digits);
      r=OrderSend(Symbol(),OP_SELL,Lots,NormalizeDouble(Bid,Digits),Slip,sl,tp,"",Magic,0,Red);
      return;
     }
//--- buy conditions
   if(FGreen>0 && (LastDealType()==2 || LastDealType()==0))
     {
      if(StopLoss>0) sl=NormalizeDouble(Ask-StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(Ask+TakeProfit*Point,Digits);
      r=OrderSend(Symbol(),OP_BUY,Lots,NormalizeDouble(Ask,Digits),Slip,sl,tp,"",Magic,0,Blue);
      return;
     }
//---
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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(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=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(OrderOpenPrice()<=(Bid-(BULevel+BUPoint)*Point) && OrderOpenPrice()>OrderStopLoss())
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+BUPoint*Point,OrderTakeProfit(),0,Green);
                  return;
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if(OrderOpenPrice()>=(Ask+(BULevel+BUPoint)*Point) && OrderOpenPrice()<OrderStopLoss())
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-BUPoint*Point,OrderTakeProfit(),0,Green);
                  return;
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Check for close order conditions                                 |
//+------------------------------------------------------------------+
void ClosePos()
  {
//--- get Ind
   double FGreen=iCustom(Symbol(),0,"Fisher",IndPeriod,0,1);
   double FRed=iCustom(Symbol(),0,"Fisher",IndPeriod,1,1);
   double ShiftFGreen=iCustom(Symbol(),0,"Fisher",IndPeriod,0,IndShift);
   double ShiftFRed=iCustom(Symbol(),0,"Fisher",IndPeriod,1,IndShift);

   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderMagicNumber()==Magic || OrderSymbol()==Symbol())
           {
            if(OrderType()==OP_BUY)
              {
               if(FGreen<0 && ShiftFGreen>0)
                 {
                  bool c=OrderClose(OrderTicket(),OrderLots(),Bid,Slip,White);
                  return;
                 }
              }
            if(OrderType()==OP_SELL)
              {
               if(FGreen>0 && ShiftFGreen<0)
                 {
                  c=OrderClose(OrderTicket(),OrderLots(),Ask,Slip,White);
                  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 LastDealType()
  {
   int type=0;
   if(OrdersHistoryTotal()==0)
     {
      type=0;
     }
   if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
     {
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
        {
         if(OrderType()==OP_BUY)
           {
            type=1;//buy  
           }
         if(OrderType()==OP_SELL)
           {
            type=2;//sell  
           }
        }
     }
   return(type);
  }
//+------------------------------------------------------------------+
//| OnTick function                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   double FGreen=iCustom(Symbol(),0,"Fisher",IndPeriod,0,1);
   double FRed=iCustom(Symbol(),0,"Fisher",IndPeriod,1,1);

   if(CountTrades()<1) OpenPos();
   if(CountTrades()>0) ClosePos();

   if(BULevel!=0) BU();
   if(TrailingStop!=0) Trailing();

   Comment("\n FGreen: ",FGreen,
           "\n FRed: ",FRed);
//---
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 12 ноября 2015, 22:23
0
Я сейчас только открыл закрыл сделки на двух брокерах альпы и фх клуб. больше не открывает сделок. Посмотрю еще чуть чуть подольше.


avatar

AM2

  • 12 ноября 2015, 22:18
0
Такой был нужен вариант?


//+------------------------------------------------------------------+
//|                                                 FXNewsKiller.mq4 |
//|                                           Copyright © 2014, AM2  |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+

#property copyright "Copyright 2014, AM2"
#property link      "http://www.forexsystems.biz"
#property version   "1.00"
#property strict

extern string TradeTime   = "2015.01.01 00:00";   //Дата и время торгов
extern int    StopLoss    = 1900;//Стоплосс всех ордеров
extern int    TakeProfit  = 350; //Тейкпрофит всех ордеров
extern double BULevel     = 300; //Уровень БУ
extern double BUPoint     = 30;  //Пункты БУ
extern int    Slip        = 0;   //Проскальзывание ордера
extern int    TradingDay  = 5;   //День недели (1-понедельник,...5-Пятница)
extern int    TradingWeak = 1;   //Неделя в месяце (1-я или 2-я)
extern int    StopLimit   = 1;   //Ставим стоповые(0) или лимитные(1) ордера
extern int    StartHour   = 9;   //Час начала торговли(терминальное время)
extern int    StartMin    = 30;  //Минуты начала торговли(терминальное время)
extern int    Distance    = 250; //Расстояние от цены для установки стопового ордера
extern int    Step        = 250; //Шаг установки стоповых ордеров
extern int    Count       = 10;  //Количество устанавливаемых ордеров стоповых или лимитных 
extern int    Expiration  = 300; //Время истечения ордера в минутах
extern double Lots        = 0.1; //Лот
extern int    Magic       = 123; //Магик
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   Comment("");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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;
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   int res=0,i;
   datetime expiration=TimeCurrent()+60*Expiration;
   if(BULevel!=0) BU();
//--------------------------------------------------------------------    
   //if(Hour()==StartHour && Minute()==StartMin && DayOfWeek()==TradingDay && Day()<=7*TradingWeak && OrdersTotal()<=Count)
   if(TimeCurrent()==StringToTime(TradeTime) && OrdersTotal()<=Count)
     {
      for(i=1;i<=Count;i++)
        {
           {
            if(StopLimit==1)
              {
               res=OrderSend(Symbol(),OP_BUYLIMIT,Lots,fND(Ask-(Distance*Point+i*Step*Point)),Slip,fND(Ask-(Distance*Point+i*Step*Point)-StopLoss*Point),fND(Ask-(Distance*Point+i*Step*Point)+TakeProfit*Point),"",Magic,expiration,Blue);
               res=OrderSend(Symbol(),OP_SELLLIMIT,Lots,fND(Bid+(Distance*Point+i*Step*Point)),Slip,fND(Bid+(Distance*Point+i*Step*Point)+StopLoss*Point),fND(Bid+(Distance*Point+i*Step*Point)-TakeProfit*Point),"",Magic,expiration,Red);
              }
            if(StopLimit==0)
              {
               res=OrderSend(Symbol(),OP_BUYSTOP,Lots,fND(Ask+(Distance*Point+i*Step*Point)),Slip,fND(Ask+(Distance*Point+i*Step*Point)-StopLoss*Point),fND(Ask+(Distance*Point+i*Step*Point)+TakeProfit*Point),"",Magic,expiration,Blue);
               res=OrderSend(Symbol(),OP_SELLSTOP,Lots,fND(Bid-(Distance*Point+i*Step*Point)),Slip,fND(Bid-(Distance*Point+i*Step*Point)+StopLoss*Point),fND(Bid-(Distance*Point+i*Step*Point)-TakeProfit*Point),"",Magic,expiration,Red);
              }
            Sleep(3000);
            if(res<0)
              {
               Print("ОШИБКА: ",GetLastError());
                 } else {
               RefreshRates();
              }
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double fND(double d,int n=-1)
  {
   if(n<0) return(NormalizeDouble(d, Digits));
   return(NormalizeDouble(d, n));
  }
//+------------------------------------------------------------------+



Время должно быть в таком формате.

datetime NY=D'2015.01.01 00:00';     // время наступления 2015 года
datetime d1=D'1980.07.19 12:30:27';  // год месяц день часы минуты секунды
datetime d2=D'19.07.1980 12:30:27';  // равнозначно D'1980.07.19 12:30:27';
datetime d3=D'19.07.1980 12';        // равнозначно D'1980.07.19 12:00:00'
datetime d4=D'01.01.2004';           // равнозначно D'01.01.2004 00:00:00'
datetime compilation_date=__DATE__;             // дата компиляции
datetime compilation_date_time=__DATETIME__;    // дата и время компиляции 
datetime compilation_time=__DATETIME__-__DATE__;// время компиляции
//--- примеры объявлений, на которые будут получены предупреждения компилятора
datetime warning1=D'12:30:27';       // равнозначно D'[дата компиляции] 12:30:27'
datetime warning2=D'';               // равнозначно __DATETIME__
avatar

AM2

  • 12 ноября 2015, 21:30
0
Самое главное чтобы хотя бы при своих остались :) 
Это от разных брокеров зависит расположение ордеров в истории. Завтра я посмотрю у себя другую функцию.
avatar

AM2

  • 12 ноября 2015, 20:55
0
А с меня взятки гладки :D 
avatar

AM2

  • 12 ноября 2015, 20:45
0
С вас :D 
avatar

AM2

  • 12 ноября 2015, 20:41