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

paradisewaymt5.mq5

Вы автор или правообладатель?

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

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

О программе

Торговый советник для MetaTrader 5, предназначенный для работы с межзависимыми инструментами австралийского канадского и новозеландского долларов (AUDNZD, NZDCAD, AUDCAD). Советник анализирует ценовые данные с использованием индикатора полос Боллинджера на заданном таймфрейме и открывает позиции при достижении ценой определённых уровней канала.

Поддерживается сеточная торговля с увеличением лота по заданному множителю, а также фиксированные параметры тейк-профита и стоп-лосса. Имеется защита по максимальной просадке, блокирующая открытие новых ордеров при превышении заданного порога, и проверка свободной маржи перед каждой сделкой.

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

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

НастройкаОписание
Work Pairs (workPairs) Рабочие пары — Список торговых пар для работы, разделённых запятыми
Enable one series in this period (oneEpisode) Одна серия в периоде — Включение ограничения на одну серию позиций в периоде
One series of orders in this period (only1timeTF) Таймфрейм серии — Таймфрейм для ограничения серии ордеров
MaxRisk (MaxRisk) Максимальный риск — Максимальный риск в процентах от свободной маржи для расчёта размера лота
if MaxRisk = 0, Lot will be (Lots) Размер лота — Размер лота при нулевом значении MaxRisk
Max lot (MaxLot) Максимальный лот — Максимально допустимый лот
Take profit (take_profit) Тейк-профит — Тейк-профит в пунктах
Stop loss (stop_loss) Стоп-лосс — Стоп-лосс в пунктах
Take profit as a percentage (profitPercent) Процент прибыли — Процент прибыли от баланса для закрытия всех позиций
Drawdown % to block new orders (if > 0) (maxDD) Максимальная просадка — Процент просадки для блокировки новых ордеров (если больше нуля)
Step between orders (between) Шаг между ордерами — Шаг между ордерами сетки в пунктах
Multiplication (mult) Множитель лота — Множитель лота для увеличения размера сеточных позиций
Max trades (maxTrades) Максимальное количество сделок — Максимальное количество сеточных сделок
Max spread (maxSpread) Максимальный спред — Максимально допустимый спред в пунктах для открытия позиций
Signal TF (signalTF) Таймфрейм сигналов — Таймфрейм для формирования торговых сигналов
Canal period (canal_period) Период канала — Период расчёта канала
Canal deviation (canal_deviation) Отклонение канала — Отклонение полос канала
Applied price (canal_price) Применяемая цена — Применяемая цена для расчёта канала
Comments to orders (_comment) Комментарий к ордерам — Комментарий, добавляемый к ордерам
Magic Магический номер — Магический номер для идентификации ордеров советника
Slipage (Slipage) Проскальзывание — Допустимое проскальзывание в пунктах при совершении торговых операций
Chart Style (chartStyle) Стиль графика — Включение стилизации графика (свечи, цвета, сетка)
Show info text (showInfoText) Отображать информационный текст — Отображение информационного текста на графике
Text size (textSize) Размер текста — Размер шрифта информационного текста
Text color (textColor) Цвет текста — Цвет информационного текста на графике
Получить полный код

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

#property version   "3.0"

#property description "An expert for working with interdependent trading instruments between the Australian dollar, the Canadian dollar and the New Zealand dollar"
#include <Trade\PositionInfo.mqh>//AUDNZD, NZDCAD, AUDCAD
#include <Trade\SymbolInfo.mqh>
#include<Trade\Trade.mqh>

CPositionInfo  m_position;                   // trade position object
CSymbolInfo    m_symbol;                     // symbol info object
CHistoryOrderInfo m_history;                 //свойства ордеров из истории

CTrade  trade;

input group "Trader's trading tools"

input string workPairs = "AUDNZD, NZDCAD, AUDCAD";//Work Pairs
input bool oneEpisode = true;//Enable one series in this period
input ENUM_TIMEFRAMES only1timeTF = PERIOD_M1;//One series of orders in this period

input group "Lot settings"
input double MaxRisk=1.5;//MaxRisk
input double Lots=0.01;//if MaxRisk = 0, Lot will be
input double MaxLot = 1000.0;//Max lot

input group "TP & SL"
input int take_profit = 350;//Take profit
input int stop_loss = 0;//Stop loss
input double profitPercent = 6.0;//Take profit as a percentage
input double maxDD = 0;//Drawdown % to block new orders (if > 0)

input group "Ancillary transactions"
input int between = 450;//Step between orders
input double mult = 1.5;//Multiplication
input int maxTrades = 300;//Max trades
input int maxSpread = 30;//Max spread

int SL = 500;
input group "Canal settings"
input ENUM_TIMEFRAMES signalTF = PERIOD_D1;//Signal TF
input  int                 canal_period = 3;//Canal period
int                 canal_shift = 0;//Смещение индикатора по горизонтали
input double              canal_deviation = 0.5;//Canal deviation
input ENUM_APPLIED_PRICE  canal_price = PRICE_MEDIAN;//Applied price
int  candleCanal = 3;

input group "Does not affect trade"
input string _comment = "MagicWay";//Comments to orders
input int Magic = 9514401;
input int Slipage = 5;//Slipage
bool logo = false;//Show logo
input bool chartStyle = true;// Chart Style
input bool showInfoText = true;//Show info text
input int textSize = 10;//Text size
input color textColor = clrWhite;//Text color

string logoObjectName="objLogo";
string          InpFile="::Images\\logoF.bmp"; // Имя файла с картинкой

string arrayPair[];

string znak=",";
ushort u_sep = -1;
string firstPairs = "";
double balance = 0;
datetime timez[];
int handles[];
int kz = 0;
double upLine[];
double dwLine[];
double middleLine[];

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

void OnDeinit(const int reason)
  {

   kz = 0;
   Comment("");
   ObjectDelete(0,logoObjectName);
   ObjectsDeleteAll(0,"infoLabel");

   znak=",";
   u_sep = -1;
   firstPairs = "";
   balance = 0;
   kz = 0;
   Comment("");
  }

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

   string pairs="";
   double size = 0;

   for(int d=0; d<kz; d++)
     {
      firstPairs = arrayPair[0];
      string thisPair = arrayPair[d];
      StringReplace(thisPair," ","");

      if(iTime(thisPair,only1timeTF,1) != timez[d])
         timez[d] = iTime(thisPair,only1timeTF,1);
      else
         continue;
      /* Print("TimeCurrent() : ", thisPair, " - ", TimeCurrent());
       return;*/
      if(!SymbolInfoInteger(thisPair, SYMBOL_EXIST) || /*iVolume(thisPair,PERIOD_CURRENT,0) > 1*/ thisPair == "") // проверка на существование символа и работа на открытии свечи
         continue;

      double equity = AccountInfoDouble(ACCOUNT_EQUITY);

      if(profitPercent > 0 && equity >= balance + (balance / 100 * profitPercent))
        {
         CloseAllPosition(Magic);
         balance = AccountInfoDouble(ACCOUNT_BALANCE);
        }

      if(oneEpisode && iBarShift(firstPairs,only1timeTF,getLastBarLastClosePos(Magic)) == 0 && CalculatePositions(-1, firstPairs, Magic) == 0)
         return;

      CopyBuffer(handles[d],UPPER_BAND,0,candleCanal+3,upLine);
      CopyBuffer(handles[d],LOWER_BAND,0,candleCanal+3,dwLine);
      CopyBuffer(handles[d],BASE_LINE,0,candleCanal+3,middleLine);

      ArraySetAsSeries(upLine,true);
      ArraySetAsSeries(dwLine,true);
      ArraySetAsSeries(middleLine,true);

      int countBuys = CalculatePositions(POSITION_TYPE_BUY, "", Magic);
      int countSells = CalculatePositions(POSITION_TYPE_SELL, "", Magic);//&& iOpen(thisPair,signalTF,1) > iClose(thisPair,signalTF,1)  && (countBuy + countSell)  % 2 == 0
      int countBuy = CalculatePositions(POSITION_TYPE_BUY,thisPair, Magic);
      int countSell = CalculatePositions(POSITION_TYPE_SELL, thisPair, Magic);

      if(countBuy > 0 && iClose(thisPair,PERIOD_M1,1) > middleLine[1]  + SymbolInfoInteger(thisPair,SYMBOL_SPREAD) * SymbolInfoDouble(thisPair,SYMBOL_POINT))
         CloseAllPosition(Magic,POSITION_TYPE_BUY,thisPair);
      if(countSell > 0 && iClose(thisPair,PERIOD_M1,1) < middleLine[1]  - SymbolInfoInteger(thisPair,SYMBOL_SPREAD) * SymbolInfoDouble(thisPair,SYMBOL_POINT))
         CloseAllPosition(Magic,POSITION_TYPE_SELL,thisPair);

      if(showInfoText)
        {
         string totalProfit =  DoubleToString(profitPositions(Magic),2);
         textLabel(7777, "EA MagicWay: current profit: " + totalProfit, 50, 20, 0, textColor, "Arial", textSize+3);
         string info = ": " + DoubleToString(SymbolInfoDouble(thisPair,SYMBOL_BID), SymbolInfoInteger(thisPair,SYMBOL_DIGITS)) + " | Spread: " + SymbolInfoInteger(thisPair,SYMBOL_SPREAD) + " | Profit: " + DoubleToString(profitPositions(thisPair, Magic),2);

         textLabel(d, thisPair + info, 55, 50+ (20*d), 0, textColor, "Arial", textSize);
        }

      if(maxDD > 0)
        {
         double bala = AccountInfoDouble(ACCOUNT_BALANCE);
         double eqva = AccountInfoDouble(ACCOUNT_EQUITY);
         double dd = 100*(eqva - bala)/bala;

         if(0-maxDD > dd)
           {
            string ddd = "The drawdown is exceeded. Orders will not be opened";

            textLabel(2000, ddd, 55, 50+ (20*(d+1)), 0, clrRed, "Arial", textSize);
            break;
           }
         else
           {
            ObjectDelete(0,"infoLabel2000");
           }
        }

      double lota=Lots;

      if(MaxRisk > 0)
         lota = LotByRisk(thisPair);

      if(lota>MaxLot)
         lota = MaxLot;

      if(lota<SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN))
         lota = SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);

      if(lota>SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX))
         lota = SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);

      lota = checkLotMinMax(thisPair, lota);

      if(!CheckVolumeValue(lota, thisPair) || !CheckMoneyForTrade(thisPair, lota, ORDER_TYPE_BUY) || !CheckMoneyForTrade(thisPair, lota, ORDER_TYPE_SELL))
         continue;

      if(SymbolInfoInteger(thisPair,SYMBOL_SPREAD) > maxSpread)
         continue;

      int freeze = 2;

      int can = 1;
        {
         if(iClose(thisPair,signalTF,1) < dwLine[can] && iOpen(thisPair,signalTF,1) < dwLine[can]  && iClose(thisPair,PERIOD_M1,1)  < dwLine[can] &&  countBuy == 0)
           {
            double max_volume=SymbolInfoDouble(thisPair,SYMBOL_VOLUME_LIMIT);
            double current_lots=getAllVolume(thisPair);

            double tp = SymbolInfoDouble(thisPair,SYMBOL_ASK) + take_profit * SymbolInfoDouble(thisPair,SYMBOL_POINT);
            double sl = SymbolInfoDouble(thisPair,SYMBOL_ASK) - stop_loss * SymbolInfoDouble(thisPair,SYMBOL_POINT);

            if(take_profit > 0)
              {
               double spra = (double) SymbolInfoInteger(thisPair,SYMBOL_SPREAD) * SymbolInfoDouble(thisPair,SYMBOL_POINT) * freeze;
               if(tp - SymbolInfoDouble(thisPair,SYMBOL_ASK) <  spra)
                  tp = 0;

               if(SymbolInfoInteger(thisPair,SYMBOL_TRADE_FREEZE_LEVEL) > 0 && take_profit < SymbolInfoInteger(thisPair,SYMBOL_TRADE_FREEZE_LEVEL))
                  tp = 0;
              }
            if(take_profit <= 0)
               tp = 0;

            if(stop_loss > 0)
              {
               double spra = (double) SymbolInfoInteger(thisPair,SYMBOL_SPREAD) * SymbolInfoDouble(thisPair,SYMBOL_POINT) * freeze;
               if(SymbolInfoDouble(thisPair,SYMBOL_ASK) - sl <  spra)
                  sl = 0;

               if(SymbolInfoInteger(thisPair,SYMBOL_TRADE_FREEZE_LEVEL) > 0 && stop_loss < SymbolInfoInteger(thisPair,SYMBOL_TRADE_FREEZE_LEVEL))
                  sl = 0;
              }

            if(stop_loss <= 0)
               sl = 0;

            if(max_volume>0 && max_volume-current_lots-lota<=0)
               continue;

            openPosition(thisPair, POSITION_TYPE_BUY, lota, sl, tp, _comment);
            break;
           }

         if(iClose(thisPair,signalTF,1) > upLine[can] && iOpen(thisPair,signalTF,1) > upLine[can] && iClose(thisPair,PERIOD_M1,1)  > upLine[can]  && countSell == 0)
           {
            double max_volume=SymbolInfoDouble(thisPair,SYMBOL_VOLUME_LIMIT);
            double current_lots=getAllVolume(thisPair);

            if(max_volume>0 && max_volume-current_lots-lota<=0)
               continue;

            double tp = SymbolInfoDouble(thisPair,SYMBOL_BID) - take_profit * SymbolInfoDouble(thisPair,SYMBOL_POINT);
            double sl = SymbolInfoDouble(thisPair,SYMBOL_BID) + stop_loss * SymbolInfoDouble(thisPair,SYMBOL_POINT);

            if(take_profit > 0)
              {
               double spra = (double) SymbolInfoInteger(thisPair,SYMBOL_SPREAD) * SymbolInfoDouble(thisPair,SYMBOL_POINT) * freeze;
               if(SymbolInfoDouble(thisPair,SYMBOL_BID) - tp <  spra)
                  tp = 0;
              }

            if(SymbolInfoInteger(thisPair,SYMBOL_TRADE_FREEZE_LEVEL) > 0 && take_profit < SymbolInfoInteger(thisPair,SYMBOL_TRADE_FREEZE_LEVEL))
               tp = 0;

            if(take_profit <= 0)
               tp = 0;

            if(stop_loss > 0)
              {
               double spra = (double) SymbolInfoInteger(thisPair,SYMBOL_SPREAD) * SymbolInfoDouble(thisPair,SYMBOL_POINT) * freeze;
               if(sl - SymbolInfoDouble(thisPair,SYMBOL_BID) <  spra)
                  sl = 0;

               if(SymbolInfoInteger(thisPair,SYMBOL_TRADE_FREEZE_LEVEL) > 0 && stop_loss < SymbolInfoInteger(thisPair,SYMBOL_TRADE_FREEZE_LEVEL))
                  sl = 0;
              }

            if(stop_loss <= 0)
               sl = 0;

            openPosition(thisPair, POSITION_TYPE_SELL, lota, sl, tp, _comment);
            break;
           }
        }

        {

           {
            if(countBuy < maxTrades && countBuy > 0 && iClose(thisPair,PERIOD_M1,1)  < dwLine[can] &&
               (iClose(thisPair,PERIOD_M1,1)  < ParamOpenLastPos(POSITION_TYPE_BUY,thisPair, Magic,1) - between  * SymbolInfoDouble(thisPair,SYMBOL_POINT)) &&
               (SymbolInfoDouble(thisPair,SYMBOL_ASK)  < ParamOpenLastPos(POSITION_TYPE_BUY,thisPair, Magic,1) - between  * SymbolInfoDouble(thisPair,SYMBOL_POINT))
              ) //||

              {
               double firstLot = ParamOpenFirstPos(POSITION_TYPE_BUY,thisPair, Magic, 2); // лот первой сделки

               double lotF = firstLot*MathPow(mult,countBuy);

               lotF = NormalizeDouble(lotF,2);
               if(!CheckVolumeValue(lotF,thisPair) || !CheckMoneyForTrade(thisPair, lotF, ORDER_TYPE_BUY))
                  continue;

               double max_volume=SymbolInfoDouble(thisPair,SYMBOL_VOLUME_LIMIT);
               double current_lots=getAllVolume(thisPair);
               if(max_volume>0 && max_volume-current_lots-lotF<=0)
                  continue;

               double tp = SymbolInfoDouble(thisPair,SYMBOL_ASK) + take_profit  * SymbolInfoDouble(thisPair,SYMBOL_POINT);
               double sl = SymbolInfoDouble(thisPair,SYMBOL_ASK) - stop_loss * SymbolInfoDouble(thisPair,SYMBOL_POINT);

               if(take_profit > 0)
                 {
                  double spra = (double) SymbolInfoInteger(thisPair,SYMBOL_SPREAD) * SymbolInfoDouble(thisPair,SYMBOL_POINT) * freeze;
                  if(tp - SymbolInfoDouble(thisPair,SYMBOL_ASK) <  spra)
                     tp = 0;

                  if(SymbolInfoInteger(thisPair,SYMBOL_TRADE_FREEZE_LEVEL) > 0 && take_profit < SymbolInfoInteger(thisPair,SYMBOL_TRADE_FREEZE_LEVEL))
                     tp = 0;
                 }
               if(take_profit <= 0)
                  tp = 0;

               if(stop_loss > 0)
                 {
                  double spra = (double) SymbolInfoInteger(thisPair,SYMBOL_SPREAD) * SymbolInfoDouble(thisPair,SYMBOL_POINT) * freeze;
                  if(SymbolInfoDouble(thisPair,SYMBOL_ASK) - sl <  spra)
                     sl = 0;

                  if(SymbolInfoInteger(thisPair,SYMBOL_TRADE_FREEZE_LEVEL) > 0 && stop_loss < SymbolInfoInteger(thisPair,SYMBOL_TRADE_FREEZE_LEVEL))
                     tp = 0;
                 }

               if(stop_loss <= 0)
                  sl = 0;

               openPosition(thisPair, POSITION_TYPE_BUY,  NormalizeDouble(lotF,2), sl, tp, _comment);
               break;
              }
           }

           {
            if(countSell < maxTrades && countSell > 0 && iClose(thisPair,PERIOD_M1,1)  > upLine[can]
               && (iClose(thisPair,PERIOD_M1,1) >  ParamOpenLastPos(POSITION_TYPE_SELL,thisPair, Magic,1) + between * SymbolInfoDouble(thisPair,SYMBOL_POINT))
               && (SymbolInfoDouble(thisPair,SYMBOL_BID) >  ParamOpenLastPos(POSITION_TYPE_SELL,thisPair, Magic,1) + between * SymbolInfoDouble(thisPair,SYMBOL_POINT))
              ) //||

              {
               double firstLot = ParamOpenFirstPos(

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

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

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

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

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

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

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