MQL4 ve MQL5 ile ilgili herhangi bir acemi sorusu, algoritmalar ve kodlar hakkında yardım ve tartışma - sayfa 1293

 
Aleksei Stepanenko :

Düz bir çizgi üzerinde iki nokta ile, gelecekte de dahil olmak üzere (ve tersi) bu düz çizgide isteğe bağlı bir üçüncü noktanın fiyatını bulabilirsiniz.

Teşekkür ederim! Yapmaya çalışacağım.

PS Tek şey. İlk bakışta anlamıyorum. MT4'te bir danışmanda çalışacak mı?

 
Merhaba uzman arkadaşlar. Göstergeyi ayarlamak için yardımınıza ihtiyacım var. Göstergenin özü aşağıdaki gibidir. Önceki çubuğa göre fiyat artışı miktarını hesaplayın. Yıldız çubuğu sıfır olarak alınır. Yani açılış fiyatı kapanış fiyatına eşittir. Derleme yaparken hata yok ama test ederken karakterin 80 20 satırında hata veriyor. Ayrıca sinyal hattını eğri çiziyor. Ancak ana arabelleğin yanlış hesaplanmasının nedeninin bu olduğunu düşünüyorum. Düzeltmeye yardım edin.
//+------------------------------------------------------------------+
//|                                                         MSBB.mq4 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#include <MovingAverages.mqh>

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1  clrGreen
#property indicator_color2  clrRed
#property  indicator_width1  1
input int            InpMSBBPeriod=3;        // Period
input ENUM_MA_METHOD InpMSBBMethod=MODE_SMA;  // Method
//--- indicator buffers
double         ExtMSBBBuffer[];
double         ExtTempBuffer[];
double         ExtPriceBuffer[];
double         ExtSignalBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
//--- indicator buffers mapping
   IndicatorDigits(Digits-2);
//--- drawing settings
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMSBBBuffer);
   SetIndexBuffer(1,ExtSignalBuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(2,ExtTempBuffer);
   SetIndexBuffer(2,ExtPriceBuffer);
   SetIndexDrawBegin(1,InpMSBBPeriod);
//--- name for DataWindow and indicator subwindow label
   IndicatorShortName("MSBB("+IntegerToString(InpMSBBPeriod)+")");
   SetIndexLabel(0,"MSBB");
   SetIndexLabel(1,"Signal");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   int    i;//limit;
//------
   if(rates_total<=InpMSBBPeriod || InpMSBBPeriod<=2)
      return(0);
   /*//--- counting from 0 to rates_total
      ArraySetAsSeries(ExtMSBBBuffer,false);
      ArraySetAsSeries(ExtSignalBuffer,false);
      ArraySetAsSeries(open,false);
      ArraySetAsSeries(high,false);
      ArraySetAsSeries(low,false);
      ArraySetAsSeries(close,false);*/
//---
  // limit=rates_total-prev_calculated;
   //if(prev_calculated>0)
     // limit++;
//--- typical price and its moving average
   for(i=0; i<rates_total; i++)
     {
      ExtTempBuffer[i] = NormalizeDouble((close[i]-open[i])/Point(),2);
      ExtPriceBuffer[i] = NormalizeDouble((close[i+1]-open[i+1])/Point(),2);
      //ExtMSBBBuffer[i]=price_open+ExtTempBuffer[i];
      //Print("ExtPriceBuffer[i] = ", ExtPriceBuffer[i]);
      if(ExtTempBuffer[i]==0)
         ExtMSBBBuffer[i]=0.0;
      if(ExtPriceBuffer[i]>0 && ExtTempBuffer[i]>0)
        {
         double price_open = NormalizeDouble((open[i]-open[i+1])/Point(),2);
         double price_close = NormalizeDouble((close[i]-close[i+1])/Point(),2);
         if((price_open<0 && price_close>0)||(price_open>0 && price_close<0))
            ExtMSBBBuffer[i] = 0.0;
         if((price_open<0 && price_close<0)||(price_open>0 && price_close>0))
            ExtMSBBBuffer[i]=ExtTempBuffer[i]+price_open;
        }
      if(ExtPriceBuffer[i]>0 && ExtTempBuffer[i]<0)
        {
         double price_open = NormalizeDouble((open[i]-close[i+1])/Point(),2);
         double price_close = NormalizeDouble((close[i]-open[i+1])/Point(),2);
         if((price_open<0 && price_close>0)||(price_open>0 && price_close<0))
            ExtMSBBBuffer[i] = 0.0;
         if((price_open>0 && price_close>0)||(price_open<0 && price_close<0))
            ExtMSBBBuffer[i]=ExtTempBuffer[i]+price_open;
        }
      if(ExtPriceBuffer[i]<0 && ExtTempBuffer[i]<0)
        {
         double price_open = NormalizeDouble((open[i]-open[i+1])/Point(),2);
         double price_close = NormalizeDouble((close[i]-close[i+1])/Point(),2);
         if((price_open<0 && price_close>0)||(price_open>0 && price_close<0))
            ExtMSBBBuffer[i]=0.0;
         if((price_open<0 && price_close<0)||(price_open>0 && price_close>0))
            ExtMSBBBuffer[i]=ExtTempBuffer[i]+price_open;
        }
      if(ExtPriceBuffer[i]<0 && ExtTempBuffer[i]>0)
        {
         double price_open = NormalizeDouble((open[i]-close[i+1])/Point(),2);
         double price_close = NormalizeDouble((close[i]-open[i+1])/Point(),2);
         if((price_open>0 && price_close<0)||(price_open<0 && price_close>0))
            ExtMSBBBuffer[i]=0.0;
         if((price_open>0 && price_close>0)||(price_open<0 && price_close<0))
            ExtMSBBBuffer[i]=ExtTempBuffer[i]+price_open;
        }
      //--- signal line counted in the 2-nd buffer
      //ExtSignalBuffer[i]=iMAOnArray(ExtMSBBBuffer,0,InpMSBBPeriod,0,InpMSBBMethod,0);
      SimpleMAOnBuffer(rates_total,prev_calculated,1,InpMSBBPeriod+2,ExtMSBBBuffer,ExtSignalBuffer);
      Print ("ExtSignalBuffer = ", ExtSignalBuffer[i]);
      //--- done
     }
   /* if(ExtPriceBuffer[i]>0||ExtPriceBuffer[i]<0)
     {
      ExtMSBBBuffer[i] = ExtPriceBuffer[i]+ExtTempBuffer[i];
      Print("ExtMSBBBuffer[i] = ", ExtMSBBBuffer[i]);
     }
   if(ExtPriceBuffer[i]==0)
     {
      ExtMSBBBuffer[i] = 0.0;
      Print("ExtMSBBBuffer[i] = ", ExtMSBBBuffer[i]);
     }
   }*/
//---
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
 
Tek bir testin yapıldığı yerel ajanın numarası nasıl bulunur?
 

Tünaydın!

Lütfen bir danışmanla yardım edin.

30 ve 70 seviyelerindeki RSI sinyalleriyle uygun yönde anlaşmalar yapar, bir ızgara oluşturur.

% kayıptan bir stop loss gibi içine dikilmiş gibi görünüyor, ancak siparişler periyodik olarak donuyor ve siz manuel olarak kapatana veya depozitoyu boşaltana kadar kapanmaz.

Yani, emirler açıldı, fiyat şimdiden 5.000 pip ve üstüne çıktı ve hala kırmızıdalar.

Hatayı bulmamız gerekiyor. Ve bu mümkün değilse, puanlardaki kayıp için danışmana ayrı bir Zarar Durdurma dikin.

2 danışmanı bir araya getirmeye çalıştım ama becerilerime hiçbir şey olmadı.

Dosyalar:
 

Merhaba. Lütfen bana söyle. Son kene için geçen puan sayısını almanız gerekir. Ama bir şey çalışmıyor.

 #property indicator_chart_window
#property indicator_buffers 1
double ExtMapBuffer[];
double dOldPriceEURUSD, dNewPriceEURUSD;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
   IndicatorDigits( 5 );
   SetIndexBuffer ( 0 , ExtMapBuffer);
   SetIndexEmptyValue( 0 , 0.0 );        
   dOldPriceEURUSD= iClose ( "EURUSD" , 0 , 0 );
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[])
  {
   dNewPriceEURUSD= iClose ( "EURUSD" , 0 , 0 );
   double delta= NormalizeDouble (dOldPriceEURUSD-dNewPriceEURUSD, 5 );
   ExtMapBuffer[ 0 ] = delta;
   Alert (delta);     
   dOldPriceEURUSD=dNewPriceEURUSD;
   return (rates_total);
  }
//+------------------------------------------------------------------+
 
Forallf :

Merhaba. Lütfen bana söyle. Son kene için geçen puan sayısını almanız gerekir. Ama bir şey çalışmıyor.

Böyle deneyin.

 //+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2018, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 1
double ExtMapBuffer[];
double dOldPriceEURUSD, dNewPriceEURUSD;
double delta;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
   IndicatorDigits( 5 );
   SetIndexBuffer ( 0 , ExtMapBuffer);
   SetIndexEmptyValue( 0 , 0.0 );
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[])
  {
   dNewPriceEURUSD = NormalizeDouble (Close[ 0 ], Digits );
   delta = dOldPriceEURUSD - dNewPriceEURUSD;
   Comment ( " delta = " , DoubleToStr(delta , 5 ));
   dOldPriceEURUSD = dNewPriceEURUSD;
   ExtMapBuffer[ 0 ] = delta;
 Alert ( " delta = " , DoubleToStr(delta , 5 ));
   return (rates_total);
  }
//+------------------------------------------------------------------+
Domain Registration Services
  • www.registryrocket.com
Get a unique domain name plus our FREE value-added services to help you get the most from it. Call it a "dot-com name," a URL, or a domain. Whatever you call it, it's the cornerstone of your online presence, and we make getting one easy. Simply enter the name you want in the search field above, and we'll tell you instantly whether the name is...
 
Александр :

Böyle deneyin.

Teşekkür ederim!
 

Tekrar merhaba.
Lütfen yeni başlayanlar sorusuna dikkat edin.
Koddaki hataları belirtmek gerekir, çünkü test cihazında, EA siparişleri açmıyor...
Aynı zamanda, derleyici hata ve uyarı vermez, günlük benzer - hata yoktur ...

 extern double Lot= 0.1 ;            
extern int Slippage = 3 ;
extern int TakeProfit = 30 ;
extern int StopLoss   = 30 ;
extern int MA_Smoth_S = 60 ;
extern int MA_Smoth_B = 12 ;
extern int MA_Simpl_S = 3 ;
extern int MA_Simpl_B = 1 ;
int start()
         {
           //___________________

           double SL, TP;
           int MA_Simpl_S_Cl,       //
              MA_Simpl_S_Op,       //
              MA_Simpl_B_Cl,       //
              MA_Simpl_B_Op;       //
         
           //________________

           //------------

          SL= NormalizeDouble (Bid-StopLoss* Point , Digits );       // 
          TP= NormalizeDouble (Bid+TakeProfit* Point , Digits );     //
          SL = StopLoss;                        
          TP = TakeProfit;
           if ( _Digits == 5 || _Digits == 3 )
            {
             SL = SL* 10 ;
             TP = TP* 10 ;
             return ( 0 );
            }
            
           //_______________

          MA_Smoth_S = iMA ( NULL , 0 , 60 , 0 , MODE_SMMA , PRICE_CLOSE , 1 );
          MA_Smoth_B = iMA ( NULL , 0 , 12 , 0 , MODE_SMMA , PRICE_CLOSE , 1 );
          MA_Simpl_S = iMA ( NULL , 0 , 3 , 0 , MODE_SMA , PRICE_CLOSE , 1 );
          MA_Simpl_B = iMA ( NULL , 0 , 1 , 0 , MODE_SMA , PRICE_CLOSE , 1 );
          MA_Simpl_S_Cl = iMA ( NULL , 0 , 3 , 0 , MODE_SMA , PRICE_CLOSE , 1 );
          MA_Simpl_S_Op = iMA ( NULL , 0 , 3 , 0 , MODE_SMA , PRICE_CLOSE , 2 );
          MA_Simpl_B_Cl = iMA ( NULL , 0 , 1 , 0 , MODE_SMA , PRICE_CLOSE , 1 );
          MA_Simpl_B_Op = iMA ( NULL , 0 , 1 , 0 , MODE_SMA , PRICE_CLOSE , 2 );
          
           //______________________

           while (MA_Smoth_B > MA_Smoth_S)
               {
                 if (MA_Simpl_B_Op < MA_Simpl_S_Op && MA_Simpl_B_Cl > MA_Simpl_S_Cl)
                  {
                   bool check = OrderSend ( Symbol (),OP_BUY,Lot, NormalizeDouble (Ask, Digits ),Slippage,SL,TP, "Buy" , 0 , 0 , clrGreen );
                   return ( 0 );
                  }
               }
               
           //_____________________

           while (MA_Smoth_S > MA_Smoth_B)
               {
                 if (MA_Simpl_B_Op > MA_Simpl_S_Op && MA_Simpl_B_Cl < MA_Simpl_S_Cl)
                  {
                   check = OrderSend ( Symbol (),OP_SELL,Lot, NormalizeDouble (Ask, Digits ),Slippage,SL,TP, "Sell" , 0 , 0 , clrRed );
                   return ( 0 );
                  }   
               }     
           return ( 0 );
         } 
 

Hepinize iyi günler!

mql4'ten mql5'e geçmeye çalışıyorum.

SORU. Neden geçerli fiyat ile <1( mql4'te olduğu gibi) olması gereken Hay değişkeninin değeri arasındaki fark yerine, mql5 anlamadığım ifadeleri hesaplar ve görüntüler, örneğin, 2.99999999 -( eksi)05 .

mql5'in verilen değerler arasındaki farkı doğru bir şekilde hesaplaması nasıl sağlanır? NormalizeDouble() ile tüm değerleri normalleştirdim ama yukarıdaki değerler

değişmeden görüntülenir. Bu benim için garip çünkü her iki değer de doble tipinde

Yardımlarınız için hepinize teşekkür ederim.

 #include <Trade\Trade.mqh>                                        
int tm, s1 ;                                    
double P= SymbolInfoDouble ( Symbol (), SYMBOL_BID ),S=P+ 0.0030 ,T=P- 0.0010 ,Lou,Hay,DL= 0.0030 ; 
CTrade            m_Trade;                 //структура для выполнения торговых операций
//=============================================================================================================
void OnTick ()
  {
Print ( "===============" , SymbolInfoDouble ( Symbol (), SYMBOL_BID ) - Hay, "===Hay====" ,Hay, "===SymbolInfoDouble()====" , SymbolInfoDouble ( Symbol (), SYMBOL_BID )); 

m_Trade.Sell( 0.1 , Symbol (),P,S,T);
Hay= SymbolInfoDouble ( Symbol (), SYMBOL_BID );

   }


 
MrBrooklin :

Merhaba Ivan! Burada kimse yeni gelenleri azarlamıyor, aksine yardım etmeye çalışıyorlar. Ben kendim bir acemiyim. Şimdi, sorunuzla ilgili olarak. Bir pozisyon açma kontrolü yapıldığı için birkaç pozisyon açıldı, ancak kontrolü durdurmayı unuttular. Return ifadesi , kontrolü çağıran programa döndürür (MQL5 Referansından alınmıştır).

EA koduna geri dönüş eklemeniz gerekir (sarı renkle vurgulanmıştır):

Ayrıca derleyicinin uyarı vermemesi için Al ve Sat pozisyonları açma koşullarında OrderSend(mrequest,mresult) kontrol etmek için bir koşul daha eklenmelidir. Bu koşul, if ifadesi tarafından belirlenir ve şöyle görünür:

Ve bir şey daha dikkate alınmalıdır. 23:59:59'da bir işlem gününden diğerine geçerken, daha önce açılan pozisyon kapatılır ve 00:00:00'da hemen yeni bir pozisyon açılır. Bu, belirli forex satıcısına ve ticaret koşullarına bağlı olan, rollover kapanışı ve rollover açılışıdır. Forumda biraz araştırın bir yerlerde bununla ilgili bilgiler var.

Saygılarımla, Vladimir.


Merhaba.

Cevabınız için çok teşekkür ederim! Ama return ifadesinin ne için olduğunu anlamıyorum? Gerçekten de, bu kodda iki koşul vardır ve bunlardan biri karşılandığında kontrol durmalıdır.

 //--- есть ли открытые позиции?
   bool Buy_opened= false ;   // переменные, в которых будет храниться информация 
   bool Sell_opened= false ; // о наличии соответствующих открытых позиций

   if ( PositionSelect ( _Symbol )== true ) // есть открытая позиция
     {
       if ( PositionGetInteger ( POSITION_TYPE )== POSITION_TYPE_BUY )   // если истина, выполняем условие 1
        {
         Buy_opened= true ;   //это длинная позиция
        }
       else if ( PositionGetInteger ( POSITION_TYPE )== POSITION_TYPE_SELL )   // иначе выполняем условие 2
        {
         Sell_opened= true ; // это короткая позиция
        }
     }
Yoksa değil mi?
Neden: