← К каталогу
Исходный код · ID 606

Setka Limit Loc v4.2

setka limit loc v4.2.mq4
Вы автор или правообладатель?

Сообщите нам, если считаете, что материал размещён без разрешения.

Краткий обзор

О программе

Советник «Setka Limit Loc v4.2» предназначен для автоматической торговли на платформе MetaTrader 4. Он реализует сеточную стратегию размещения отложенных ордеров в обе стороны — на покупку и продажу — с управлением лотами и стоп-уровнями. Advisor работает в пределах заданного временного окна и может закрывать все позиции в конце торговой недели.

Советник размещает лимитные и стоповые ордера с нарастающими уровнями цен и лотами, настраиваемыми пользователем. Он отслеживает открытые позиции и отложенные ордера, модифицируя их стоп-лосс, тейк-профит и активируя трейлинг-стоп при достижении заданного уровня прибыли. Также реализована локальная защита позиций от необратимых убытков.

Встроены средства информирования: вывод информации на график в виде текстовых меток и стрелок, отправка алертов и email-уведомлений. Работа советника защищена проверкой ключа авторизации и ограничением количества одновременно открытых ордеров.

Настройки программы

НастройкаОписание
Buy Покупка — Включает размещение отложенных ордеров на покупку
Sell Продажа — Включает размещение отложенных ордеров на продажу
OrdersLimit Лимит ордеров — Максимальное количество лимитных ордеров в сетке
OrdersStop Стоп ордера — Максимальное количество стоп-ордеров в сетке
OrdersTek Текущие ордера — Допустимое отклонение цены для исполнения ордера
lotLimit Лот лимит — Начальный размер лота для лимитных ордеров
lotStop Лот стоп — Начальный размер лота для стоп-ордеров
PlusLot Плюс лот — Фиксированное увеличение лота между уровнями сетки
K_Lot Коэффициент лота — Множитель увеличения лота между уровнями
MoveStepGread Шаг сдвига сетки — Шаг сдвига цен для пересчёта уровней сетки
FirstStep Первый шаг — Начальный шаг в пунктах от текущей цены
Step Шаг — Фиксированный шаг сетки в пунктах (0 — автоматический расчёт)
SLoss Стоп-лосс — Стоп-лосс в пунктах для новых ордеров
TProfit Тейк-профит — Тейк-профит в пунктах для новых ордеров
NoLoss Без убытка — Минимальный стоп-лосс в пунктах для защиты позиции
TrailingPercentStep Шаг трейлинг-стопа — Шаг трейлинг-стопа в процентах от цены
ProfitStartTrall Прибыль для трейлинга — Уровень прибыли для активации трейлинг-стопа
ProfitStartK Коэффициент старта трейлинга — Коэффициент расчёта начальной цели прибыли
TrailingPercentProfit Процент трейлинг-стопа — Процент трейлинг-стопа от размера прибыли
___________________ Разделитель — Текстовый разделитель групп настроек
SleepTime Время паузы — Пауза между проверками в секундах
magic Магический номер — Магический номер для идентификации ордеров советника
Diapazon Диапазон — Коэффициент диапазона для расчёта шага сетки
__________________ Разделитель — Текстовый разделитель групп настроек
AlertOn Алерты — Включение и выключение звуковых уведомлений
DrawInfo Отрисовка информации — Включение и выключение отрисовки данных на графике
SendMailInfo Email-уведомления — Включение и выключение отправки email-уведомлений
_________________ Разделитель — Текстовый разделитель групп настроек
TimeStart Начало торгового окна — Час начала торгового окна
TimeEnd Конец торгового окна — Час окончания торгового окна
________________ Разделитель — Текстовый разделитель групп настроек
CloseEndWeek Закрытие в конце недели — Автоматическое закрытие позиций в конце торговой недели
HourClose Час закрытия — Час закрытия позиций в конце недели
Lok Локальные стопы — Количество уровней локальных стопов
LokNoLoss Локальная защита от убытка — Включение локальной защиты позиций от необратимых убытков
Получить полный код

Поиск по коду файла

extern bool Buy = TRUE;
extern bool Sell = TRUE;
extern int OrdersLimit = 5;
extern int OrdersStop = 10;
extern int OrdersTek = 4;
extern double lotLimit = 0.1;
extern double lotStop = 0.4;
extern double PlusLot = 0.1;
extern double K_Lot = 1.0;
extern int MoveStepGread = 10;
extern int FirstStep = 0;
extern int Step = 0;
extern int SLoss = 0;
extern int TProfit = 0;
extern double NoLoss = 0.0;
extern double TrailingPercentStep = 0.0;
extern double ProfitStartTrall = 0.0;
extern double ProfitStartK = 0.3;
extern double TrailingPercentProfit = 30.0;
extern string ___________________ = "";
extern int SleepTime = 0;
extern int magic = 1000;
extern double Diapazon = 1.0;
extern string __________________ = "";
extern bool AlertOn = TRUE;
extern bool DrawInfo = TRUE;
extern bool SendMailInfo = FALSE;
extern string _________________ = "";
extern int TimeStart = 0;
extern int TimeEnd = 24;
extern string ________________ = "";
extern bool CloseEndWeek = TRUE;
extern int HourClose = 18;
extern int Key = *;
extern int Lok = 4;
extern bool LokNoLoss = TRUE;
string gs_276 = "Setka Limit Loc v4.2 ";
string g_str_concat_284;
bool g_bool_292;
bool gi_296 = TRUE;
bool gi_300;
bool gi_304;
bool gi_308;
bool gi_312;
int gi_316 = 3256;
int g_stoplevel_320;
int g_acc_number_324;
int gi_328;
int gi_332;
double gd_336;
double gda_344[100];
double gda_348[100];
double gda_352[100];
double gda_356[100];
double gda_360[100];
double gda_364[100];
double gd_368;
double gd_376;
string g_str_concat_384;
string g_str_concat_392;
string g_str_concat_400;
string g_str_concat_408;
string g_var_name_416;
double g_maxlot_424;
double gd_432;
double gd_440;

int init() {
      // код доступен только после оплаты
   }

bool f0_0() {
   double ihigh_0;
   double ilow_8;
   double ld_20;
   double ld_28;
   double ld_36;
   int magic_44;
   int cmd_48;
   if (GlobalVariableCheck(g_str_concat_392) && GlobalVariableCheck(g_str_concat_400) && GlobalVariableCheck(g_str_concat_408)) {
      gd_432 = GlobalVariableGet(g_str_concat_392);
      gd_440 = GlobalVariableGet(g_str_concat_400);
      gd_336 = GlobalVariableGet(g_str_concat_408);
   } else {
      if (Step == 0) {
         for (int li_16 = 0; li_16 < 30; li_16++) {
            ihigh_0 = iHigh(NULL, PERIOD_D1, li_16);
            ilow_8 = iLow(NULL, PERIOD_D1, li_16);
            if (ihigh_0 == 0.0 || ilow_8 == 0.0) continue;
            if (gd_336 < (ihigh_0 - ilow_8) / OrdersLimit) gd_336 = (ihigh_0 - ilow_8) / OrdersLimit * Diapazon;
         }
      } else gd_336 = Step * Point;
      if (gd_336 == 0.0) return (FALSE);
      for (li_16 = OrdersTotal() - 1; li_16 >= 0; li_16--) {
         if (OrderSelect(li_16, SELECT_BY_POS, MODE_TRADES)) {
            magic_44 = OrderMagicNumber();
            cmd_48 = OrderType();
            if (OrderSymbol() == Symbol() && magic_44 >= magic && magic_44 <= magic + 100) {
               ld_36 = NormalizeDouble(OrderOpenPrice(), Digits);
               if (cmd_48 == OP_BUYLIMIT)
                  if (ld_20 < ld_36) ld_20 = ld_36;
               if (cmd_48 == OP_SELLLIMIT)
                  if (ld_28 > ld_36 || ld_28 == 0.0) ld_28 = ld_36;
            }
         }
      }
      if (ld_20 == 0.0 && ld_28 == 0.0) {
         if (FirstStep < MarketInfo(Symbol(), MODE_STOPLEVEL)) {
            gd_432 = Ask + gd_336;
            gd_440 = Bid - gd_336;
         } else {
            gd_432 = Ask + FirstStep * Point;
            gd_440 = Bid - FirstStep * Point;
         }
      } else {
         gd_432 = ld_28;
         gd_440 = ld_20;
      }
      GlobalVariableSet(g_str_concat_392, gd_432);
      GlobalVariableSet(g_str_concat_400, gd_440);
      GlobalVariableSet(g_str_concat_408, gd_336);
   }
   gi_328 = gd_336 / Point;
   gi_332 = NormalizeDouble(gi_328 * TrailingPercentStep / 100.0, 0);
   if (Sell) gda_352[1] = NormalizeDouble(gd_432, Digits);
   if (Buy) gda_356[1] = NormalizeDouble(gd_440, Digits);
   for (li_16 = 2; li_16 <= OrdersLimit; li_16++) {
      if (Sell) gda_352[li_16] = NormalizeDouble(gda_352[li_16 - 1] + gd_336, Digits);
      if (Buy) gda_356[li_16] = NormalizeDouble(gda_356[li_16 - 1] - gd_336, Digits);
   }
   if (Buy) gda_360[Lok] = NormalizeDouble(gd_440, Digits);
   if (Sell) gda_364[Lok] = NormalizeDouble(gd_432, Digits);
   for (li_16 = Lok + 1; li_16 <= Lok + OrdersStop; li_16++) {
      if (Buy) gda_360[li_16] = NormalizeDouble(gda_360[li_16 - 1] - gd_336, Digits);
      if (Sell) gda_364[li_16] = NormalizeDouble(gda_364[li_16 - 1] + gd_336, Digits);
   }
   g_acc_number_324 = AccountNumber();
   g_str_concat_284 = StringConcatenate("????????????? ????????? ", gs_276);
   if (IsDemo()) g_str_concat_284 = StringConcatenate(g_str_concat_284, " ???? ");
   else g_str_concat_284 = StringConcatenate(g_str_concat_284, " ???? ");
   g_str_concat_284 = StringConcatenate(g_str_concat_284, " ???? ", g_acc_number_324, 
   "\n");
   if (SLoss != 0) g_str_concat_284 = StringConcatenate(g_str_concat_284, "???????? ", SLoss, " \\ ");
   if (TProfit != 0) g_str_concat_284 = StringConcatenate(g_str_concat_284, "?????????? ", TProfit, " \\ ");
   if (TrailingPercentStep != 0.0) g_str_concat_284 = StringConcatenate(g_str_concat_284, "TrailingStop ", TrailingPercentStep, "% ", gi_332, " ? \\ ");
   if (NoLoss > 0.0) g_str_concat_284 = StringConcatenate(g_str_concat_284, "????????? ", NoLoss, " ? \\ ");
   g_str_concat_284 = StringConcatenate(g_str_concat_284, "??? ", DoubleToStr(gda_344[1], 2));
   if (PlusLot != 0.0) g_str_concat_284 = StringConcatenate(g_str_concat_284, " \\ PlusLot ", DoubleToStr(PlusLot, 2));
   if (K_Lot != 1.0) g_str_concat_284 = StringConcatenate(g_str_concat_284, " \\ K_Lot ", DoubleToStr(K_Lot, 2));
   if (FirstStep != 0) g_str_concat_284 = StringConcatenate(g_str_concat_284, " \\ FirstStep ", FirstStep);
   g_str_concat_284 = StringConcatenate(g_str_concat_284, " \\ ?????  ", gi_328, " ? ? ", OrdersLimit, " + Lok Stop ", OrdersStop, "\\ ");
   if (Step == 0) g_str_concat_284 = StringConcatenate(g_str_concat_284, " Diapazon ", Diapazon, " \\ ");
   if (TrailingPercentProfit == 0.0) g_str_concat_284 = StringConcatenate(g_str_concat_284, "?????? ??? ???????? " + DoubleToStr(ProfitStartTrall, 2), g_str_concat_384, " \\ ");
   else {
      if (ProfitStartTrall > 0.0) {
         g_str_concat_284 = StringConcatenate(g_str_concat_284, "???????? ????? = " + DoubleToStr(ProfitStartTrall, 2), g_str_concat_384, "  ", TrailingPercentProfit, "% ????? = " +
            DoubleToStr(gd_376, 2), g_str_concat_384, " \\ ");
      } else {
         g_str_concat_284 = StringConcatenate(g_str_concat_284, "???????? ????? ????????? ", TrailingPercentProfit, "% ????? \\ ");
         if (ProfitStartK != 1.0) g_str_concat_284 = StringConcatenate(g_str_concat_284, " ? ??????? ??????? ", DoubleToStr(ProfitStartK, 2), " \\ ");
      }
   }
   g_str_concat_284 = StringConcatenate(g_str_concat_284, 
   "\n??????? ????? ??????? ", SleepTime, " ???. \\ ");
   g_str_concat_284 = StringConcatenate(g_str_concat_284, "????? ??????????? ??????? ? ", TimeStart, ":00 ?? ", TimeEnd, ":00");
   if (CloseEndWeek) g_str_concat_284 = StringConcatenate(g_str_concat_284, " \\ ????????? ?????? ? ??????? ? ", HourClose, ":00");
   g_str_concat_284 = StringConcatenate(g_str_concat_284, " \\ Lok ????? ", Lok, " ?????? \n");
   return (TRUE);
}

int deinit() {
   if (IsTesting()) {
      GlobalVariableDel(g_str_concat_392);
      GlobalVariableDel(g_str_concat_400);
      GlobalVariableDel(g_str_concat_408);
   }
   ObjectDelete("Balance");
   ObjectDelete("Equity");
   ObjectDelete("Profit");
   ObjectDelete("ProfitB");
   ObjectDelete("ProfitS");
   ObjectDelete("FreeMargin");
   ObjectDelete("Copyright");
   ObjectDelete("ProfitStartTrall");
   ObjectDelete("comment2");
   return (0);
}

int start() {
      // код доступен только после оплаты
   }
   bool li_4;
   double ld_16;
   double ld_24;
   double ld_32;
   double ld_40;
   double price_48;
   double price_56;
   double ld_64;
   double ld_72;
   double order_lots_80;
   double price_88;
   double price_96;
   double price_104;
   double price_112;
   double price_120;
   double price_128;
   int li_136;
   int li_140;
   int cmd_144;
   int magic_148;
   int li_152;
   int li_156;
   int li_160;
   int li_164;
   double ld_172;
   double ld_180;
   double ld_188;
   string str_concat_208;
   int ticket_216;
   double price_228;
   if (!IsTradeAllowed()) {
      ObjectSetText("comment2", "???????? ?????????", 8, "Arial", Red);
      return (0);
   }
   ObjectSetText("comment2", "???????? ?????????", 8, "Arial", Green);
   int hour_0 = Hour();
   if (TimeStart < TimeEnd && hour_0 >= TimeStart && hour_0 < TimeEnd) li_4 = TRUE;
   else {
      if (TimeStart > TimeEnd && hour_0 >= TimeStart || hour_0 < TimeEnd) li_4 = TRUE;
      else li_4 = FALSE;
   }
   g_stoplevel_320 = MarketInfo(Symbol(), MODE_STOPLEVEL);
   for (int pos_168 = OrdersTotal() - 1; pos_168 >= 0; pos_168--) {
      if (OrderSelect(pos_168, SELECT_BY_POS, MODE_TRADES)) {
         magic_148 = OrderMagicNumber();
         if (OrderSymbol() == Symbol() && magic_148 >= magic && magic_148 <= magic + 100) {
            price_96 = NormalizeDouble(OrderOpenPrice(), Digits);
            cmd_144 = OrderType();
            order_lots_80 = OrderLots();
            if (cmd_144 == OP_BUY) {
               if (price_104 < price_96 || price_104 == 0.0) price_104 = price_96;
               if (price_120 > price_96 || price_120 == 0.0) price_120 = price_96;
               ld_64 += price_96 * order_lots_80;
               li_136++;
               ld_32 += order_lots_80;
               ld_24 += OrderProfit() + OrderSwap() + OrderCommission();
            }
            if (cmd_144 == OP_SELL) {
               if (price_112 > price_96 || price_112 == 0.0) price_112 = price_96;
               if (price_128 < price_96 || price_128 == 0.0) price_128 = price_96;
               ld_72 += price_96 * order_lots_80;
               li_140++;
               ld_40 += order_lots_80;
               ld_16 += OrderProfit() + OrderSwap() + OrderCommission();
            }
            if (cmd_144 == OP_BUYLIMIT) li_152++;
            if (cmd_144 == OP_SELLLIMIT) li_156++;
            if (cmd_144 == OP_BUYSTOP) li_164++;
            if (cmd_144 == OP_SELLSTOP) li_160++;
         }
      }
   }
   if (MoveStepGread != 0 && li_136 + li_140 == 0) {
      if (FirstStep < MarketInfo(Symbol(), MODE_STOPLEVEL)) {
         ld_172 = Ask + gd_336;
         ld_180 = Bid - gd_336;
      } else {
         ld_172 = Ask + FirstStep * Point;
         ld_180 = Bid - FirstStep * Point;
      }
      if (MoveStepGread < (ld_180 - gda_356[1]) / Point && Buy && (!Sell)) {
         GlobalVariableSet(g_str_concat_400, gda_356[1] + MoveStepGread * Point);
         f0_0();
      }
      if (MoveStepGread < (gda_352[1] - ld_172) / Point && (!Buy) && Sell) {
         GlobalVariableSet(g_str_concat_392, gda_352[1] - MoveStepGread * Point);
         f0_0();
      }
   }
   double ld_8 = ld_16 + ld_24;
   if (li_152 == 0 && li_156 == 0 && li_160 == 0 && li_164 == 0) {
      GlobalVariableDel(g_str_concat_392);
      GlobalVariableDel(g_str_concat_400);
      GlobalVariableDel(g_str_concat_408);
      f0_0();
   }
   ObjectDelete("SLb");
   ObjectDelete("SLs");
   if (li_136 > 0) {
      price_48 = NormalizeDouble(ld_64 / ld_32, Digits);
      ObjectCreate("SLb", OBJ_ARROW, 0, Time[0], price_48, 0, 0, 0, 0);
      ObjectSet("SLb", OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
      ObjectSet("SLb", OBJPROP_COLOR, Blue);
      if (li_156 > 0) f0_4(OP_SELLLIMIT);
   }
   if (li_140 > 0) {
      price_56 = NormalizeDouble(ld_72 / ld_40, Digits);
      ObjectCreate("SLs", OBJ_ARROW, 0, Time[0], price_56, 0, 0, 0, 0);
      ObjectSet("SLs", OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
      ObjectSet("SLs", OBJPROP_COLOR, Red);
      if (li_152 > 0) f0_4(OP_BUYLIMIT);
   }
   if (LokNoLoss && (ld_24 > ld_16 && ld_32 >= ld_40) || (ld_24 < ld_16 && ld_32 <= ld_40)) {
      for (pos_168 = OrdersTotal() - 1; pos_168 >= 0; pos_168--) {
         if (OrderSelect(pos_168, SELECT_BY_POS, MODE_TRADES)) {
            magic_148 = OrderMagicNumber();
            if (OrderSymbol() == Symbol() && magic_148 >= magic && magic_148 <= magic + 100) {
               cmd_144 = OrderType();
               ld_188 = NormalizeDouble(OrderStopLoss(), Digits);
               price_96 = NormalizeDouble(OrderOpenPrice(), Digits);
               if (cmd_144 == OP_BUY) {
                  price_88 = NormalizeDouble(Bid - gi_328 * Point, Digits);
                  if (price_88 >= price_96) {
                     if (price_96 > ld_188)
                        if (OrderModify(OrderTicket(), price_96, price_96, OrderTakeProfit(), 0, White)) Print("??????? ???????? -------------------- ??????? LokNoLoss");
                  }
               }
               if (cmd_144 == OP_SELL) {
                  price_88 = NormalizeDouble(Ask + gi_328 * Point, Digits);
                  if (price_88 <= price_96) {
                     if (price_96 < ld_188 || ld_188 == 0.0)
                        if (OrderModify(OrderTicket(), price_96, price_96, OrderTakeProfit(), 0, White)) Print("??????? ???????? -------------------- ??????? LokNoLoss");
                  }
               }
            }
         }
      }
   }
   if (NoLoss >= g_stoplevel_320 && NoLoss != 0.0) {
      for (pos_168 = OrdersTotal() - 1; pos_168 >= 0; pos_168--) {
         if (OrderSelect(pos_168, SELECT_BY_POS, MODE_TRADES)) {
            magic_148 = OrderMagicNumber();
            if (OrderSymbol() == Symbol() && magic_148 >= magic && magic_148 <= magic + 100) {
               cmd_144 = OrderType();
               ld_188 = NormalizeDouble(OrderStopLoss(), Digits);
               price_96 = NormalizeDouble(OrderOpenPrice(), Digits);
               if (cmd_144 == OP_BUY && price_48 != 0.0) {
                  price_88 = NormalizeDouble(Bid - NoLoss * Point, Digits);
                  if (price_88 >= price_48) {
                     if (price_48 > ld_188)
                        if (OrderModify(OrderTicket(), price_96, price_48, OrderTakeProfit(), 0, White)) Print("??????? ???????? ====================== ??????? NoLoss");
                  }
               }
               if (cmd_144 == OP_SELL && price_56 != 0.0) {
                  price_88 = NormalizeDouble(Ask + NoLoss * Point, Digits);
                  if (price_88 <= price_56) {
                     if (price_56 < ld_188 || ld_188 == 0.0)
                        if (OrderModify(OrderTicket(), price_96, price_56, OrderTakeProfit(), 0, White)) Print("??????? ???????? ====================== ??????? NoLoss");
                  }
               }
            }
         }
      }
   }
   if (gi_332 >= g_stoplevel_320 && gi_332 != 0) {
      for (pos_168 = OrdersTotal() - 1; pos_168 >= 0; pos_168--) {
         if (OrderSelect(pos_168, SELECT_BY_POS, MODE_TRADES)) {
            magic_148 = OrderMagicNumber();
            if (OrderSymbol() == Symbol() && magic_148 >= magic && magic_148 <= magic + 100) {
               cmd_144 = OrderType();
               ld_188 = NormalizeDouble(OrderStopLoss(), Digits);
               price_96 = NormalizeDouble(OrderOpenPrice(), Digits);
               if (cmd_144 == OP_BUY && price_48 != 0.0) {
                  price_88 = NormalizeDouble(Bid - gi_332 * Point, Digits);
                  if (price_88 > price_48 || price_88 < price_48 - gi_328 * 2 * Point) {
                     if (price_88 > ld_188 && price_88 > price_96 || price_88 > price_48)
                        if (OrderModify(OrderTicket(), price_96, price_88, OrderTakeProfit(), 0, White)) Print("??????? ???????? ====================== ??????? TrailingStop");
     

Показано первые 50% кода (символов: 27743)

Открыть по тарифу

Купите тариф с пакетом открытий или войдите, если тариф уже есть. Открытый файл останется в вашем кабинете навсегда.

Разовая покупка файла

На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.

Чтобы оформить заказ, введите email и перейдите к оплате.

Стоимость полного кода
2 774,30₽ ≈ $33.91