← Назад к списку файлов

paradisewaymt4.mq4

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

#property version   "3.0"
#property strict

#property description "An expert for working with interdependent trading instruments between the Australian dollar, the Canadian dollar and the New Zealand dollar"

input string _tools = "------ 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 string _lot = "------ Lot settings";
input double MaxRisk=2.0;//MaxRisk
input double Lots=0.01;//if MaxRisk = 0, Lot will be
input double MaxLot = 1000.0;//Max lot

input string _tp = "------ 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 string _trans = "------ Ancillary transactions";
input int between = 450;//Step between orders
input double mult = 1.5;//Multiplication
input int maxTrades = 300;//Max trades
input int maxSpread = 85;//Max spread

int SL = 500;

input string _canal = "------ 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 string _not = "------ Does not affect trade";
input string _comment = "ParadiseWay";//Comments to orders
input int Magic = 98555220;
input int Slipage = 5;//Slipage
bool logo = false;//Show logo
input bool showInfoText = true;//Show info text
input int textSize = 10;//Text size
input color textColor = clrWhite;//Text color
input bool chartColor = true;//Corporate color of the chart

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

string arrayPair[];

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

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;

   /*  if(TimeCurrent() > D'2023.04.29 00:00')
       {
        Comment("You need to update the EA version");
        return;
       }
   /*
    if(AccountInfoInteger(ACCOUNT_LOGIN) != 2109031021 && !IsTesting())
      {
       Comment("ONLY FOR 2109031021");
       return;
      }
   */

   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;

      if(SymbolInfoDouble(thisPair, SYMBOL_BID) <= 0 || /*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;

      upLine[0] = iBands(thisPair,signalTF,canal_period,canal_deviation,canal_shift,canal_price,MODE_UPPER,1);
      dwLine[0] = iBands(thisPair,signalTF,canal_period,canal_deviation,canal_shift,canal_price,MODE_LOWER,1);
      middleLine[0] = iBands(thisPair,signalTF,canal_period,canal_deviation,canal_shift,canal_price,MODE_MAIN,1);

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

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

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

      if(showInfoText)
        {
         string totalProfit =  DoubleToString(profitPositions(Magic),2);

         textLabel(7777, "EA ParadiseWay: 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(!CheckVolumeValue(lota, thisPair) || !CheckMoneyForTrade(thisPair, lota, ORDER_TYPE_BUY) || !CheckMoneyForTrade(thisPair, lota, ORDER_TYPE_SELL))
         continue;

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

      int can = 0;

      /*  if(countBuy + countSell == 0 && TimeCurrent() > D'2023.04.29 00:00')
          {
           Print("TERMINAL ERROR X099x874x547)");
           ExpertRemove();
           return;
          }*/

        {
         if(iClose(thisPair,signalTF,1) < dwLine[can] && Ask < 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(max_volume>0 && max_volume-current_lots-lota<=0)
               continue;

            if(take_profit <= 0)
               tp = 0;
            if(stop_loss <= 0)
               sl = 0;

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

         if(iClose(thisPair,signalTF,1) > upLine[can] &&  Bid > 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)
               tp = 0;
            if(stop_loss <= 0)
               sl = 0;
            openPosition(thisPair, OP_SELL, lota, sl, tp, _comment);
            break;
           }
        }

        {

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

              {
               double firstLot = ParamOpenFirstPos(OP_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)
                  tp = 0;
               if(stop_loss <= 0)
                  sl = 0;
               openPosition(thisPair, OP_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) >  ParamOpenLastPo

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

Как получить полную версию?

Введите ваш email и нажмите кнопку, чтобы перейти к оплате.