0
входы не менял. в настройках все прописано четко:


   bool buy = lim!=EMPTY_VALUE && vin<-Level;
   bool sell = red!=EMPTY_VALUE && vin>Level;
avatar

AM2

  • 7 сентября 2021, 20:01
0
сейчас есть входы с несколькими ордерами и закрытие по профиту серии. как вообще туда впишется трал по зигзагу?




//+------------------------------------------------------------------+
//|                                                          ZZ2.mq4 |
//|                                              Copyright 2020, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, AM2"
#property link      "http://www.forexsystems.biz"
#property version   "1.00"
#property strict

//--- Inputs
extern double Lots       = 0.1;      // лот
extern double KLot       = 1;        // умножение лота
extern double MaxLot     = 5;        // максимальный лот
extern double Profit     = 10;       // профит
extern int StopLoss      = 0;        // лось
extern int TakeProfit    = 0;        // язь
extern int Slip          = 30;       // реквот
extern int Magic         = 123;      // магик

extern int Depth         = 12;
extern int Dev           = 5;
extern int Back          = 3;

bool buy=1, sell=1;
double zz0=0,zz1=0,zz2=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Comment("");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
  {
   int r=0;
   color clr=Green;
   double sl=0,tp=0;

   if(type==1 || type==3 || type==5)
     {
      clr=Red;
      if(StopLoss>0)
         sl=NormalizeDouble(price+StopLoss*Point,Digits);
      if(TakeProfit>0)
         tp=NormalizeDouble(price-TakeProfit*Point,Digits);
     }

   if(type==0 || type==2 || type==4)
     {
      clr=Blue;
      if(StopLoss>0)
         sl=NormalizeDouble(price-StopLoss*Point,Digits);
      if(TakeProfit>0)
         tp=NormalizeDouble(price+TakeProfit*Point,Digits);
     }

   r=OrderSend(NULL,type,Lot(),NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
   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()<2)
               count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Lot()
  {
   double lot=Lots;
   for(int i=OrdersHistoryTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
        {
         if(OrderProfit()>0)
            break;
         if(OrderProfit()<0)
           {
            lot=OrderLots()*KLot;
            break;
           }
        }
     }
   if(lot>MaxLot)
      lot=Lots;
   return(lot);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double ZZPrice(int n=0)
  {
   double zz=0;
   int k=0;

   for(int i=0; i<1111; i++)
     {
      zz=iCustom(NULL,0,"ZigZag",Depth,Dev,Back,0,i);
      if(zz!=0)
        {
         k++;
         if(k>n)
            return(zz);
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
//| Профит всех ордеров по типу ордера                               |
//+------------------------------------------------------------------+
double AllProfit(int ot=-1)
  {
   double pr=0;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==0 && (ot==0 || ot==-1))
              {
               pr+=OrderProfit()+OrderCommission()+OrderSwap();
              }

            if(OrderType()==1 && (ot==1 || ot==-1))
              {
               pr+=OrderProfit()+OrderCommission()+OrderSwap();
              }
           }
        }
     }
   return(pr);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseAll(int ot=-1)
  {
   bool cl;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==0 && (ot==0 || ot==-1))
              {
               RefreshRates();
               cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,_Digits),Slip,White);
              }
            if(OrderType()==1 && (ot==1 || ot==-1))
              {
               RefreshRates();
               cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,_Digits),Slip,White);
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   zz0=ZZPrice(0);
   zz1=ZZPrice(1);
   zz2=ZZPrice(2);

   if(AllProfit(0)>Profit && Profit>0)
      CloseAll(0);

   if(AllProfit(1)>Profit && Profit>0)
      CloseAll(1);

   if(zz0>zz1 && buy)
     {
      PutOrder(0,Ask);
      buy=0;
      sell=1;
     }

   if(zz0<zz1  && sell)
     {
      PutOrder(1,Bid);
      buy=1;
      sell=0;
     }

   Comment("\n ZZ0: ",zz0,
           "\n ZZ1: ",zz1,
           "\n ZZ2: ",zz2,
           "\n Buy Profit: ",AllProfit(0),
           "\n Sell Profit: ",AllProfit(1));
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 7 сентября 2021, 18:29
0
покажите на скрине где входы выходы и что это за трал по зигзагу в положительной зоне?
avatar

AM2

  • 7 сентября 2021, 16:17
0
Сделку открывать на каждом экстремуме Zig-Zagа
сможете это объяснить машине? я нет
avatar

AM2

  • 7 сентября 2021, 16:14
0
смотрите вариант:


//+------------------------------------------------------------------+
//|                                                          AA8.mq4 |
//|                                              Copyright 2021, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, AM2"
#property link      "http://www.forexsystems.biz"
#property version   "1.00"
#property strict

//--- Inputs
extern double Lots       = 0.1;      // лот
extern double KLot       = 1;        // умножение лота
extern double MaxLot     = 5;        // максимальный лот
extern double Profit     = 10;       // профит
extern int StopLoss      = 0;        // лось
extern int TakeProfit    = 0;        // язь
extern int Slip          = 30;       // реквот
extern int Magic         = 123;      // магик

extern int Depth         = 12;
extern int Dev           = 5;
extern int Back          = 3;

double z=0,zz0=0,zz1=0,zz2=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   z=zz0;
   Comment("");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
  {
   int r=0;
   color clr=Green;
   double sl=0,tp=0;

   if(type==1 || type==3 || type==5)
     {
      clr=Red;
      if(StopLoss>0)
         sl=NormalizeDouble(price+StopLoss*_Point,_Digits);
      if(TakeProfit>0)
         tp=NormalizeDouble(price-TakeProfit*_Point,_Digits);
     }

   if(type==0 || type==2 || type==4)
     {
      clr=Blue;
      if(StopLoss>0)
         sl=NormalizeDouble(price-StopLoss*_Point,_Digits);
      if(TakeProfit>0)
         tp=NormalizeDouble(price+TakeProfit*_Point,_Digits);
     }

   r=OrderSend(NULL,type,Lot(),NormalizeDouble(price,_Digits),Slip,sl,tp,"",Magic,0,clr);
   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()<2)
               count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Lot()
  {
   double lot=Lots;
   for(int i=OrdersHistoryTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
        {
         if(OrderProfit()>0)
            break;
         if(OrderProfit()<0)
           {
            lot=OrderLots()*KLot;
            break;
           }
        }
     }
   if(lot>MaxLot)
      lot=Lots;
   return(lot);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double ZZPrice(int ne=0)
  {
   double zz;
   int    i,k=iBars(NULL,0),ke=0;

   for(i=1; i<k; i++)
     {
      zz=iCustom(NULL,0,"ZigZag",Depth,Dev,Back,0,i);
      if(zz!=0)
        {
         ke++;
         if(ke>ne)
            return(zz);
        }
     }
   Print("GetExtremumZZPrice(): Экстремум ЗигЗага номер ",ne," не найден");
   return(0);
  }
//+------------------------------------------------------------------+
//| Профит всех ордеров по типу ордера                               |
//+------------------------------------------------------------------+
double AllProfit(int ot=-1)
  {
   double pr=0;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==0 && (ot==0 || ot==-1))
              {
               pr+=OrderProfit()+OrderCommission()+OrderSwap();
              }

            if(OrderType()==1 && (ot==1 || ot==-1))
              {
               pr+=OrderProfit()+OrderCommission()+OrderSwap();
              }
           }
        }
     }
   return(pr);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseAll(int ot=-1)
  {
   bool cl;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==0 && (ot==0 || ot==-1))
              {
               RefreshRates();
               cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,_Digits),Slip,White);
              }
            if(OrderType()==1 && (ot==1 || ot==-1))
              {
               RefreshRates();
               cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,_Digits),Slip,White);
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   zz0=ZZPrice(0);
   zz1=ZZPrice(1);
   zz2=ZZPrice(2);

   if(AllProfit(0)>Profit && Profit>0)
      CloseAll(0);

   if(AllProfit(1)>Profit && Profit>0)
      CloseAll(1);

   if(z!=zz0)
     {
      if(zz0<zz1)
        {
         PutOrder(0,Ask);
        }
      if(zz0>zz1)
        {
         PutOrder(1,Bid);
        }
      z=zz0;
     }

   Comment("\n ZZ: ",z,
           "\n ZZ0: ",zz0,
           "\n ZZ1: ",zz1,
           "\n ZZ2: ",zz2,
           "\n Buy Profit: ",AllProfit(0),
           "\n Sell Profit: ",AllProfit(1));
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 7 сентября 2021, 15:37
0
скиньте тз в топик. опишите входы выходы и покажите все на скринах
avatar

AM2

  • 7 сентября 2021, 14:31
0
тз рассмотрю
avatar

AM2

  • 6 сентября 2021, 20:00
+1
1. Сделал сигнал 3 МА в ряд
2. Вывел в настройки метод МА
3. Добавил настройку бар индикатора



www.opentraders.ru/downloads/3106/
avatar

AM2

  • 6 сентября 2021, 19:57
0
подправил добавил :)  www.opentraders.ru/downloads/2765/



avatar

AM2

  • 6 сентября 2021, 08:42
0
то что скинули не устроит?
avatar

AM2

  • 5 сентября 2021, 21:38
0
такие пробойки на предыдущего дня очень хорошо работают.
avatar

AM2

  • 5 сентября 2021, 18:23
0
вынес в настройки: www.opentraders.ru/downloads/3104/
avatar

AM2

  • 5 сентября 2021, 08:12