Yeni başlayanlardan sorular MQL5 MT5 MetaTrader 5 - sayfa 1324

 
Alexey Viktorov :

Dün görmek için bu mucizeyi indirdim ... Ve aniden beni tirnetten mahrum ettiler. Fırtınanın ardından gün sonuna kadar teknik çalışma. Bu yüzden, tembellikten, bu mucizeyi burada yayınlanan MQL5'te yeniden yazmaya karar verdim.

İyi olmadan kötü olmadığı ortaya çıktı………

Uzman Danışmanınıza bir Gösterge ekledim - Sanırım sorun olmaz!? Sprut 185 istediğim gibi çıktı

(sarı ile burada mevcut uzmana ne eklendi . )

 //+------------------------------------------------------------------+
//|                                                 2 DVA_Martin.mq5 |
//|                                          © 2021, Alexey Viktorov |
//|                     https://www.mql5.com/ru/users/alexeyvik/news |
//+------------------------------------------------------------------+
#property copyright "© 2021, Alexey Viktorov"
#property link        " https://www.mql5.com/ru/users/alexeyvik/news "
#property version    "2.00"
//---
#include <Trade\Trade.mqh>
CTrade trade;
//---
input int      TakeProfit1         = 300 ;   // профит первой позиции
input int      TakeProfit2         = 250 ;   // профит второй позиции
input int      TakeProfit3         = 200 ;   // профит третьей позиции
input int      TakeProfit4         = 100 ;   // профит четвертой и следующих позиций
input int      Step                = 200 ;   // шаг первой позиции
input int      Delta               = 100 ;   // добавка к шагу
// со второй позиции увеличивает расстояние последующих позиций на величину "дельта" от предыдущего
input double   Lot                 = 0.03 ; // первый лот открытия
input double   MaximalLot          = 0.5 ;   // максимальный лот, который мы разрешаем
input int      MaxTrades           = 9 ;     // максимальное количество позиций одного направления
input double   MultiplicatorLot    = 1.6 ;   // умножаем последующие позиции
input int      Magic               = 123 ;   // идентификатор советника
//--- Пременные для хранения собранной информации
double MaxLot  = 0 ;
double LotBuy  = 0 ;
double LotSell = 0 ;
//---
int m_bar_current= 0 ;
int StepMA_NRTR_Handle;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit ()
  {
//---
   trade.SetExpertMagicNumber(Magic);
   MaxLot = contractSize(MaximalLot);
//--- create StepMA_NRTR indicator
   StepMA_NRTR_Handle= iCustom ( NULL , 0 , "StepMA_NRTR" );
   if (StepMA_NRTR_Handle== INVALID_HANDLE )
     {
       printf ( "Error creating StepMA_NRTR indicator" );
       return ( false );
     }
//---
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
  {
//---
   Comment ( "" );
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick ()
  {
//---
   double StepMA_NRTR[],StepMA_NRTRS[];
   ArraySetAsSeries (StepMA_NRTR, true );
   ArraySetAsSeries (StepMA_NRTRS, true );
   int start_pos= 1 ,count= 3 ;
   if (!iGetArray(StepMA_NRTR_Handle, 0 ,start_pos,count,StepMA_NRTR)||
      !iGetArray(StepMA_NRTR_Handle, 1 ,start_pos,count,StepMA_NRTRS))
     {
       return ;
     }
//---
   int posTotal = PositionsTotal ();
   double BuyMinPrice = DBL_MAX , //  Минимальная цена Buy позиции
          SelMaxPrice = DBL_MIN , //  Максимальная цена Sell позиции
          BuyMinLot = 0 ,         //  Лот самой нижней Buy позиции
          SelMaxLot = 0 ,         //  Лое самой верхней Sell позиции
          posPrice = 0.0 ,
          posLot = 0.0 ,
          BuyAwerage = 0 ,
          SelAwerage = 0 ,
          BuyPrice = 0 ,
          SelPrice = 0 ,
          BuyLot = 0 ,
          SelLot = 0 ;
   MqlTick tick;
   if (! SymbolInfoTick ( _Symbol , tick))
       return ;
   int b = 0 ,
       s = 0 ;
   for ( int i = 0 ; i < posTotal; i++)
     {
       ulong posTicket = PositionGetTicket (i);
       if ( PositionGetString ( POSITION_SYMBOL ) == _Symbol && PositionGetInteger ( POSITION_MAGIC ) == Magic)
        {
         posPrice = PositionGetDouble ( POSITION_PRICE_OPEN );
         posLot = PositionGetDouble ( POSITION_VOLUME );
         if ( PositionGetInteger ( POSITION_TYPE ) == POSITION_TYPE_BUY )
           {
            b++; // Считаем открытые позиции на покупку
             if (posPrice < BuyMinPrice)
              {
               BuyMinPrice = posPrice;
               BuyMinLot = posLot;
               BuyPrice += posPrice*posLot;   // добавить к переменной BuyPrice Цена оредра 1 * лот ордера 1
               BuyLot += posLot;             // суммируем лоты
              }
           }
         if ( PositionGetInteger ( POSITION_TYPE ) == POSITION_TYPE_SELL )
           {
            s++; // Считаем открытые позиции на продажу
             if (posPrice > SelMaxPrice)
              {
               SelMaxPrice = posPrice;
               SelMaxLot = posLot;
               SelPrice += posPrice*posLot;   // добавить к переменной BuyPrice Цена оредра 1 * лот ордера 1
               SelLot += posLot;             // суммируем лоты
              }
           }
        }
     }
   LotBuy = b == 0 ? contractSize(Lot) : fmin (MaxLot, contractSize(BuyMinLot*MultiplicatorLot));
   LotSell = s == 0 ? contractSize(Lot) : fmin (MaxLot, contractSize(SelMaxLot*MultiplicatorLot));
//---
//--- BUY Signal
   if (StepMA_NRTR[m_bar_current]<StepMA_NRTRS[m_bar_current])
     {
       if (b == 0 || (b < MaxTrades && BuyMinPrice-tick.ask >= (Step+Delta*b)* _Point ))
         openPos( ORDER_TYPE_BUY , LotBuy, tick.ask);
     }
//--- SELL Signal
   if (StepMA_NRTR[m_bar_current]>StepMA_NRTRS[m_bar_current])
     {
       if (s == 0 || (s < MaxTrades && tick.bid-SelMaxPrice >= (Step+Delta*s)* _Point ))
         openPos( ORDER_TYPE_SELL , LotSell, tick.bid);
     }
//--- посчитаем математические формулы средних цен
   switch (b)
     {
       case 0 :
         return ;
       case 1 :
         BuyAwerage = BuyPrice/BuyLot+TakeProfit1* _Point ;
         break ;
       case 2 :
         BuyAwerage = BuyPrice/BuyLot+TakeProfit1* _Point ;
         break ;
       case 3 :
         BuyAwerage = BuyPrice/BuyLot+TakeProfit3* _Point ;
         break ;
       default :
         BuyAwerage = BuyPrice/BuyLot+TakeProfit4* _Point ;
         break ;
     }
   switch (s)
     {
       case 0 :
         return ;
       case 1 :
         SelAwerage = SelPrice/SelLot-TakeProfit1* _Point ;
         break ;
       case 2 :
         SelAwerage = SelPrice/SelLot-TakeProfit2* _Point ;
         break ;
       case 3 :
         SelAwerage = SelPrice/SelLot-TakeProfit3* _Point ;
         break ;
       default :
         SelAwerage = SelPrice/SelLot-TakeProfit4* _Point ;
         break ;
     }
   normalizePrice(BuyAwerage); // Произведем расчет цены TP Buy
   normalizePrice(SelAwerage); // Произведем расчет цены TP Sell
//---
   for ( int i = 0 ; i < posTotal; i++)
     {
       ulong posTicket = PositionGetTicket (i);
       if ( PositionGetString ( POSITION_SYMBOL ) == _Symbol && PositionGetInteger ( POSITION_MAGIC ) == Magic)
        {
         double posTP = PositionGetDouble ( POSITION_TP );
         if ( PositionGetInteger ( POSITION_TYPE ) == POSITION_TYPE_BUY )
           {
             if ( fabs (posTP-BuyAwerage) > _Point && tick.ask < BuyAwerage) // Если тейк не равен требуемой цене
               if (!trade.PositionModify(posTicket, 0.0 , BuyAwerage))
                   Print ( "Ошибка " , __LINE__ );
           }
         if ( PositionGetInteger ( POSITION_TYPE ) == POSITION_TYPE_SELL )
           {
             if ( fabs (posTP-SelAwerage) > _Point && tick.bid > SelAwerage) // Если тейк не равен требуемой цене
               if (!trade.PositionModify(posTicket, 0.0 , SelAwerage))
                   Print ( "Ошибка " , __LINE__ );
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void openPos( ENUM_ORDER_TYPE type, double lot, double price)
  {
   trade.CheckVolume( _Symbol , lot, price, type);
   if (trade.CheckResultMarginFree() <= 0.0 )
     {
       Print ( "Not enough money for " , EnumToString (type), " " , lot, " " , _Symbol , " Error code=" , trade.CheckResultRetcode());
       return ;
     }
   if (!trade.PositionOpen( _Symbol , type, LotBuy, price, 0.0 , 0.0 ))
       Print (trade.ResultRetcode());
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double contractSize( double volume, string symbol = NULL )
  {
   symbol = symbol == NULL ? _Symbol : symbol;
   double v = volume;
   double volumeStep = SymbolInfoDouble (symbol, SYMBOL_VOLUME_STEP );
   v = round (volume/volumeStep)*volumeStep;
   double minLot = SymbolInfoDouble (symbol, SYMBOL_VOLUME_MIN );
   return ((v < minLot ? minLot : v));
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double normalizePrice( double &price, string symbol = NULL )
  {
   symbol = symbol == NULL ? _Symbol : symbol;
   double tickSize = SymbolInfoDouble (symbol, SYMBOL_TRADE_TICK_SIZE );
   price = round (price/tickSize)*tickSize;
   return (tickSize);
  }
//+------------------------------------------------------------------+
//| Filling the indicator buffers from the indicator                 |
//+------------------------------------------------------------------+
bool iGetArray( const int handle, const int buffer, const int start_pos,
               const int count, double &arr_buffer[])
  {
   bool result= true ;
   if (! ArrayIsDynamic (arr_buffer))
     {
       return ( false );
     }
   ArrayFree (arr_buffer);
//--- reset error code
   ResetLastError ();
//--- fill a part of the iBands array with values from the indicator buffer
   int copied= CopyBuffer (handle,buffer,start_pos,count,arr_buffer);
   if (copied!=count)
     {
       return ( false );
     }
   return (result);
  }
//+------------------------------------------------------------------+

Советники: DVA_Martin
Советники: DVA_Martin
  • 2021.06.30
  • www.mql5.com
Статьи и техническая библиотека по автоматическому трейдингу: Советники: DVA_Martin
 
SanAlex :

Uzman Danışmanınıza bir Gösterge ekledim - Sanırım sorun olmaz!? Sprut 185 istediğim gibi çıktı

(sarı ile burada mevcut uzmana ne eklendi . )

Ve neden üç çubuktan göstergelerin değerleri? Ve neden diziyi bir zaman dizisine çevirelim?

Genel olarak, bana öyle geliyor ki, öyle değil ... Hiçbir martin çalışmayacak.

 
Alexey Viktorov :

Ve neden üç çubuktan göstergelerin değerleri? Ve neden diziyi bir zaman dizisine çevirelim?

Genel olarak, bana öyle geliyor ki, öyle değil ... Hiçbir martin çalışmayacak.

Buradaki gösterge tıpkı bir yön filtresi gibidir - ve tüm görevi Uzman Danışmanınız yapar

\\\\\\\\\\\\\

göstergenin kendisi pozisyon açmıyor.

 
SanAlex :

Buradaki gösterge tıpkı bir yön filtresi gibidir - ve tüm görevi Uzman Danışmanınız yapar

Görev, yazılı kod tarafından gerçekleştirilmelidir. Ama öyle bir koşul ayarladın ki, martin asla açılmayacak. Öyle düşünüyorum, ama kontrol etmek için ne arzum ne de zamanım var.

 
Alexey Viktorov :

Görev, yazılı kod tarafından gerçekleştirilmelidir. Ama öyle bir koşul ayarladın ki, martin asla açılmayacak. Öyle düşünüyorum, ama kontrol etmek için ne arzum ne de zamanım var.

Burada işini kontrol ediyorum - her şey planlandığı gibi çalışıyor.

2 DVA_Martin

 
Alexey Viktorov :

Martin, yalnızca gösterge sinyali ters olduğunda mı yoksa bundan bağımsız olarak mı açılmalı?

Örnek: Göstergeye göre bir Alış pozisyonu açılır. Fiyat belirli bir mesafe kadar düştü ve gösterge zaten Sat gösteriyor. Alış pozisyonları açılmalı mı?

Söz verdiğim gibi, bir şeyler photoshopladım.

1

Zaten net değilse, o zaman sadece kişisel iletişimle fikrimin anlamını açıklayabilirim.

 
SanAlex :

Burada bir şey yaptım - 100.000 ruble ile anlamadığım. iki milyona kadar

Göstergeyi değiştirdi ve 5dk. euro\dolar 15 günde bir milyona.

LeMan_BrainTrend1Sig 2

LeMan_BrainTrend1Sig

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

uzmana eklendi - toplam kârda (tüm çiftlerden) karı kapatın ve uzmanı kaldırın

 input group   "---- : Parameters:  ----"
input int     TargetProfit     = 1000000 ; // : Balance + Profit(add to balance)
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick ( void )
  {
//---
   if ( AccountInfoDouble ( ACCOUNT_EQUITY )>=TargetProfit)
     {
      AllClose();
       ExpertRemove ();
     }
//---

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

mevcut olması için bu 2 göstergeye ihtiyacınız var (değişmemesi için göstergelerin adları )

 
SanAlex :

Göstergeyi değiştirdi ve 5dk. euro\dolar 15 günde bir milyona.

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

uzmana eklendi - toplam kârda (tüm çiftlerden) karı kapatın ve uzmanı kaldırın

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

mevcut olması için bu 2 göstergeye ihtiyacınız var (değişmemesi için göstergelerin adları )

Kurulumda kayıp durdurma kaybı

 

\n" gibi bir yöntem kullanarak bir dizeyi satırlara ayırmanın yolları vardır.

Ancak, zaten satırlara bölünmüş bir dize değişkenini tek bir satıra yapıştırmanın/dönüştürmenin yolları var mı?

Yani, parametre değerinin tüm metinleri vb. Bu satırda mevcut (string) değişken tek satırda yazılmıştır.

Sorun, csv'ye yazarken ortaya çıktı (bir dize değişkeninin değeri bir grup satıra yazılır).

 
Vitaly Muzichenko :

Kurulumda kayıp durdurma kaybı

Stop Loss ile artık bu kar yok

kaybı durdurmak

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

EA'yı daha sık yeniden başlatmanız gerektiğini düşünüyorum - örneğin, bir hafta boyunca (tüm çiftlerden) toplam karı aldım ve EA tüm çiftleri bıraktı.

ve tüm çiftlerden yeni toplam kâr elde edilene kadar Expert Advisor'ı yeniden başlatın.

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\ \\\\\\\\\\\\\

stop'ta başka bir düşünce vardı - stop, pozisyonları kapatmak değil, çok sayıda zıt (kârsız) açık pozisyonla zıt pozisyonu açmaktır.

İşte lotlardaki açık pozisyonların hesabı

   int total= PositionsTotal ();
   for ( int i=total- 1 ; i>= 0 ; i--) // returns the number of open positions
     {
       string    position_GetSymbol= PositionGetSymbol (i); // GetSymbol позиции
       if (position_GetSymbol==m_symbol.Name())
        {
         if (m_position.PositionType()== POSITION_TYPE_BUY )
           {
            PROFIT_BUY=PROFIT_BUY+ PositionGetDouble ( POSITION_PROFIT );
            PROFIT_BUY_Lot=PROFIT_BUY_Lot+ PositionGetDouble ( POSITION_VOLUME );
           }
         else
           {
            PROFIT_SELL=PROFIT_SELL+ PositionGetDouble ( POSITION_PROFIT );
            PROFIT_SELL_Lot=PROFIT_SELL_Lot+ PositionGetDouble ( POSITION_VOLUME );
           }
           {
            PROFIT_CLOSE= AccountInfoDouble ( ACCOUNT_PROFIT );
           }
        }
     }
//---

Zararı Durdur 777

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\

tam bir saçmalık olduğu ortaya çıkıyor. kısacası, elinizle açmanız gerekir ve diğer her şey manuel ticarete yardımcı olmalıdır.

Neden: