Kodlama yardımı - sayfa 678

 
mladen :

Simon

Koşullar daha rafine hale getirilmelidir. Örneğin : her ikisi de sinyal verdiğinde genellikle aynı şey olur. Peki, bunu tam olarak ne zaman yapmalılar. Bunun ilk oluşumunda mı? Bunun her oluşumunda mı? Ayrıca, ikisinden birini değiştirerek çıkıyorsanız, çıkışlar çok sık olacaktır.

Cevap için teşekkürler! Evet, bu iyi bir strateji olmayabilir. Sadece bunu bir şablon olarak alırsam, muhtemelen daha sonra kendi başıma bazı değişiklikler yapabilirim. İstediğim şey, iki göstergeyi (ve arabelleklerinin kullanımını) birleştirme olasılığı.

Bunun yerine stratejinin şöyle olması gerektiğini söyleyelim: Her iki gösterge de belirttiğinde satın alın. Ve her iki gösterge de gösterdiğinde sat. Gösterge değişikliği ve kapalı çubuktan sonra gerçekleşmelidir. Bunun her oluşumunda olması gerekir.

Herşey gönlünce olsun!

 

sevgili mladen,


Ekteki göstergeyle ilgili bir sorunum var:

EA yürütmesi sırasında indi uygulandığında (MT4'teki standart hareketli ortalama), değerler, EA yürütmesinin sonunda aynı göstergeyi uygulayarak görüntülenen değerlerden çok farklıdır.

Lütfen nedenini ve mümkünse indi'yi düzelttiğini açıklayabilir misiniz?


Dosyalar:
 

Bay mladen,

Ma kanalına doldurulmuş ma şeridi için biraz değişiklik yapıyorum ama arabellekle ilgili bir sorunum var.

Bu, kanalı histogramın arkasına gizlemenin veya kanal arasındaki boşluğu doldurmanın herhangi bir yolu mu?

Onu boşaltmaya çalışıyorum ama bunu yalnızca bir tarafta yapabiliyorum, bunun için bir arabellek daha eklemeye gerek var mı?

Ve 44. satırda bir sorun daha var, onu dışlayamıyorum veya silemiyorum.

hep hata çıkıyor.

Lütfen bana biraz tavsiye verin, teşekkür ederim.

Steven.


Dosyalar:
 
stevenpun :

Bay mladen,

Ma kanalına doldurulmuş ma şeridi için bazı değişiklikler yapıyorum ama arabellekle ilgili bir sorunum var.

Bu, kanalı histogramın arkasına gizlemenin veya kanal arasındaki boşluğu doldurmanın herhangi bir yolu mu?

Onu boşaltmaya çalışıyorum ama bunu sadece bir tarafta yapabiliyorum, bunun için bir arabellek daha eklemeye gerek var mı?

Ve 44. satırda bir sorun daha var, onu dışlayamıyorum veya silemiyorum.

hep hata çıkıyor.

Lütfen bana biraz tavsiye verin, teşekkür ederim.

Steven.


Yapmaya çalıştığın şeyin bu olup olmadığından emin değilim, ama dene


Dosyalar:
 
mladen :

Yapmaya çalıştığın şeyin bu olup olmadığından emin değilim, ama dene


evet tam istediğim gibi :D

Ama 44 'AlertOnClosedCandle' satırındaki kodu kontrol etmeme yardım edebilir misiniz, neden bool silemez veya extern olamaz?

Bu tür bir sorunu ilk kez yaşıyorum.

Herhangi bir şekilde arabellekte bazı şeyler öğrendim.

Teşekkür ederim .

 

Mladen, değiştirdiğiniz önceki göstergedeki özelleştirmemi yeni bitirdi. Bu kodda yanlış olan ne? Hiçbir şey göstermiyor... Derlendiğinde hata yok.

 #property version    "1.00"
#property strict


#property indicator_chart_window
#property indicator_buffers      4
#property indicator_color1     Gold
#property indicator_color2     DodgerBlue
#property indicator_color3     LimeGreen
#property indicator_color4     Crimson

#property indicator_width1     2
#property indicator_width2     2
#property indicator_width3     2
#property indicator_width4     2

extern string                 NOTE1           = "SELECT PARAMETERS OF THE INDICATOR" ; //SPAN MA CROSS PARAMS
extern int                    SpanPeriod      = 1 ;             // Period of Span
extern int                    SpanShift       = - 26 ;           // Shift of Span
extern ENUM_MA_METHOD         SpanMode        = 1 ;             // Mode of Span
extern ENUM_APPLIED_PRICE     SpanPrice       = 0 ;             // Applied price of Span
extern int                    MaPeriod        = 55 ;           // Period of Moving average
extern int                    MaShift         = 0 ;             // Shift of Moving average
extern ENUM_MA_METHOD         MaMode          = 1 ;             // Mode of Moving average
extern ENUM_APPLIED_PRICE     MaPrice         = 0 ;             // Applied price of Moving average

extern string                 NOTE2           = "SELECT COLORS/STYLES OF THE INDICATOR" ; //SPAN MA CROSS COLORS/STYLES
extern color                  SpanClr         = Gold;         // Span color
extern int                    SpanWdt         = 2 ;             // Span width
extern ENUM_LINE_STYLE        SpanStl         = 0 ;             // Span line style
extern color                  MaClr           = DodgerBlue;   // Moving average color
extern int                    MaWdt           = 2 ;             // Moving average width
extern ENUM_LINE_STYLE        MaStl           = 0 ;             // Moving average line style

extern string                 NOTE3           = "SELECT PARAMETERS OF THE SIGNAL ARROWS" ; //SPAN MA CROSS PARAMETERS OF THE SIGNAL ARROWS
extern bool                   DrawArrows      = true ;         // Draw signal arrows?
extern bool                   DrawMaLines     = true ;         // Draw lines?
extern color                  UpArrowClr      = LimeGreen;     // Up arrow color
extern int                    UpArrowWdt      = 2 ;             // Up arrow width
extern color                  DnArrowClr      = Crimson;       // Down arrow color
extern int                    DnArrowWdt      = 2 ;             // Down arrow width
extern int                    ArrowsDistance  = 10 ;           // Arrows distance from candle

extern string                 NOTE4           = "SELECT PARAMETERS OF THE ALERT" ; //SPAN MA CROSS PARAMETERS OF THE ALERT
extern bool                   AlertsOn        = true ;         // Active alert?
extern bool                   AlertsOnCurrent = true ;         // Alert on current unclosed bar
extern bool                   AlertsMessage   = true ;         // Alert message
extern bool                   AlertsSound     = true ;         // Alert sound
extern bool                   AlertsEmail     = false ;         // Alert e-mail
extern string                 SoundFile       = "alert2.wav" ; // Filename of sound alert

string                        IndicatorFileName;
int                           WhichBar;
double                        Gap;


double    SpanBuffer[];     // Buffer of the Span
double    MaBuffer[];       // Buffer of the Moving average
double    CrossUpBuffer[];   // Up arrow buffer
double    CrossDnBuffer[];   // Down arrow buffer
double    TrendBuffer[];     // Span/Ma cross buffer


int init()
  {
   IndicatorFileName = WindowExpertName ();
   IndicatorBuffers ( 5 );
   
   
   SetIndexBuffer ( 0 , SpanBuffer);
   SetIndexBuffer ( 1 , MaBuffer);
   SetIndexBuffer ( 2 , CrossUpBuffer);
   SetIndexBuffer ( 3 , CrossDnBuffer);
   SetIndexBuffer ( 4 , TrendBuffer);
   
   if (DrawMaLines) {   
   SetIndexStyle ( 0 , DRAW_LINE , SpanStl, SpanWdt, SpanClr);  
   SetIndexStyle ( 1 , DRAW_LINE , MaStl, MaWdt, MaClr);}
        
   else { 
   SetIndexStyle ( 0 , DRAW_NONE ); 
   SetIndexStyle ( 1 , DRAW_NONE );} 
     
   if (DrawArrows) {
   SetIndexStyle ( 2 , DRAW_ARROW , 0 , UpArrowWdt, UpArrowClr); SetIndexArrow ( 0 , 233 );
   SetIndexStyle ( 3 , DRAW_ARROW , 0 , DnArrowWdt, DnArrowClr); SetIndexArrow ( 0 , 234 );}
   
   else { 
   SetIndexStyle ( 2 , DRAW_NONE ); 
   SetIndexStyle ( 3 , DRAW_NONE );} 
   
   
   
return ( 0 );}
  
int deinit() {   return ( 0 ); }

int start() {
   int counted_bars = IndicatorCounted ();
   int i, limit;

   if (counted_bars< 0 ) return (- 1 );
   if (counted_bars> 0 ) counted_bars--;
         limit = MathMin ( Bars -counted_bars, Bars - 1 );
         
         
   for (i=limit; i>= 0 ; i--){   
      SpanBuffer[i]  = iMA ( NULL , 0 , SpanPeriod, SpanShift, SpanMode, SpanPrice, i);
      MaBuffer[i]    = iMA ( NULL , 0 , MaPeriod, MaShift, MaMode, MaPrice, i);
      Gap = iATR ( NULL , 0 , 20 ,i);
      
      TrendBuffer[i] = TrendBuffer[i+ 1 ];
         if (SpanBuffer[i] > MaBuffer[i]) TrendBuffer[i] = 1 ;
         if (SpanBuffer[i] < MaBuffer[i]) TrendBuffer[i] =- 1 ;
         
      
         CrossUpBuffer[i] = EMPTY_VALUE ;
         CrossDnBuffer[i] = EMPTY_VALUE ;
         if (TrendBuffer[i]!= TrendBuffer[i+ 1 ])
         if (TrendBuffer[i] == 1 )
               CrossUpBuffer[i] = Low [i]  - ArrowsDistance * Gap;
         else   CrossDnBuffer[i] = High [i] + ArrowsDistance * Gap; 
         }
         
         if (AlertsOn)
         {
         if (AlertsOnCurrent)
                  WhichBar = 0 ;
         else      WhichBar = 1 ;      
      
         if (TrendBuffer[WhichBar] != TrendBuffer[WhichBar+ 1 ])
         if (TrendBuffer[WhichBar] == 1 )
               doAlert( "uptrend" );
         else   doAlert( "downtrend" );       
   }
   
   return ( 0 );
}


// CUSTOM FUNCTIONS -------------------------

 void doAlert( string doWhat)
{
   static string    previousAlert= "nothing" ;
   static datetime previousTime;
   string message;
   
       if (previousAlert != doWhat || previousTime != Time [ 0 ]) {
          previousAlert  = doWhat;
          previousTime   = Time [ 0 ];

          message =   StringConcatenate ( Symbol (), " at " , TimeToStr ( TimeLocal (), TIME_SECONDS ), " Span ma cross " , doWhat);
             if (AlertsMessage) Alert (message);
             if (AlertsEmail)   SendMail ( StringConcatenate ( Symbol (), " Span ma cross " ), message);
             if (AlertsSound)   PlaySound (SoundFile);
      }
}
 
thefxpros :

Mladen, değiştirdiğiniz önceki göstergedeki özelleştirmemi yeni bitirdi. Bu kodda yanlış olan ne? Hiçbir şey göstermiyor... Derlendiğinde hata yok.

thefxpros

şöyle dene

 #property version    "1.00"
#property strict


#property indicator_chart_window
#property indicator_buffers      4
#property indicator_color1     Gold
#property indicator_color2     DodgerBlue
#property indicator_color3     LimeGreen
#property indicator_color4     Crimson

#property indicator_width1     2
#property indicator_width2     2
#property indicator_width3     2
#property indicator_width4     2

extern string                 NOTE1           = "SELECT PARAMETERS OF THE INDICATOR" ; //SPAN MA CROSS PARAMS
extern int                    SpanPeriod      = 1 ;             // Period of Span
extern int                    SpanShift       = - 26 ;           // Shift of Span
extern ENUM_MA_METHOD         SpanMode        = 1 ;             // Mode of Span
extern ENUM_APPLIED_PRICE     SpanPrice       = 0 ;             // Applied price of Span
extern int                    MaPeriod        = 55 ;           // Period of Moving average
extern int                    MaShift         = 0 ;             // Shift of Moving average
extern ENUM_MA_METHOD         MaMode          = 1 ;             // Mode of Moving average
extern ENUM_APPLIED_PRICE     MaPrice         = 0 ;             // Applied price of Moving average

extern string                 NOTE2           = "SELECT COLORS/STYLES OF THE INDICATOR" ; //SPAN MA CROSS COLORS/STYLES
extern color                  SpanClr         = Gold;         // Span color
extern int                    SpanWdt         = 2 ;             // Span width
extern ENUM_LINE_STYLE        SpanStl         = 0 ;             // Span line style
extern color                  MaClr           = DodgerBlue;   // Moving average color
extern int                    MaWdt           = 2 ;             // Moving average width
extern ENUM_LINE_STYLE        MaStl           = 0 ;             // Moving average line style

extern string                 NOTE3           = "SELECT PARAMETERS OF THE SIGNAL ARROWS" ; //SPAN MA CROSS PARAMETERS OF THE SIGNAL ARROWS
extern bool                   DrawArrows      = true ;         // Draw signal arrows?
extern bool                   DrawMaLines     = true ;         // Draw lines?
extern color                  UpArrowClr      = LimeGreen;     // Up arrow color
extern int                    UpArrowWdt      = 2 ;             // Up arrow width
extern color                  DnArrowClr      = Crimson;       // Down arrow color
extern int                    DnArrowWdt      = 2 ;             // Down arrow width
extern int                    ArrowsDistance  = 10 ;           // Arrows distance from candle

extern string                 NOTE4           = "SELECT PARAMETERS OF THE ALERT" ; //SPAN MA CROSS PARAMETERS OF THE ALERT
extern bool                   AlertsOn        = true ;         // Active alert?
extern bool                   AlertsOnCurrent = true ;         // Alert on current unclosed bar
extern bool                   AlertsMessage   = true ;         // Alert message
extern bool                   AlertsSound     = true ;         // Alert sound
extern bool                   AlertsEmail     = false ;         // Alert e-mail
extern string                 SoundFile       = "alert2.wav" ; // Filename of sound alert

string                        IndicatorFileName;
int                           WhichBar;
double                        Gap;


double    SpanBuffer[];     // Buffer of the Span
double    MaBuffer[];       // Buffer of the Moving average
double    CrossUpBuffer[];   // Up arrow buffer
double    CrossDnBuffer[];   // Down arrow buffer
double    TrendBuffer[];     // Span/Ma cross buffer


int init()
  {
   IndicatorFileName = WindowExpertName ();
   IndicatorBuffers ( 5 );
   
   
   SetIndexBuffer ( 0 , SpanBuffer);
   SetIndexBuffer ( 1 , MaBuffer);
   SetIndexBuffer ( 2 , CrossUpBuffer);
   SetIndexBuffer ( 3 , CrossDnBuffer);
   SetIndexBuffer ( 4 , TrendBuffer);
   
   if (DrawMaLines) {   
   SetIndexStyle ( 0 , DRAW_LINE , SpanStl, SpanWdt, SpanClr);  
   SetIndexStyle ( 1 , DRAW_LINE , MaStl, MaWdt, MaClr);}
        
   else { 
   SetIndexStyle ( 0 , DRAW_NONE ); 
   SetIndexStyle ( 1 , DRAW_NONE );} 
     
   if (DrawArrows) {
   SetIndexStyle ( 2 , DRAW_ARROW , 0 , UpArrowWdt, UpArrowClr); SetIndexArrow ( 0 , 233 );
   SetIndexStyle ( 3 , DRAW_ARROW , 0 , DnArrowWdt, DnArrowClr); SetIndexArrow ( 0 , 234 );}
   
   else { 
   SetIndexStyle ( 2 , DRAW_NONE ); 
   SetIndexStyle ( 3 , DRAW_NONE );} 
   
   
   
return ( 0 );}
  
int deinit() {   return ( 0 ); }

int start() {
   int counted_bars = IndicatorCounted ();
   int i, limit;

   if (counted_bars< 0 ) return (- 1 );
   if (counted_bars> 0 ) counted_bars--;
         limit = MathMin ( Bars -counted_bars, Bars - 1 );
         
         
   for (i=limit; i>= 0 ; i--){   
      SpanBuffer[i]  = iMA ( NULL , 0 , SpanPeriod, SpanShift, SpanMode, SpanPrice, i);
      MaBuffer[i]    = iMA ( NULL , 0 , MaPeriod, MaShift, MaMode, MaPrice, i);
      Gap = iATR ( NULL , 0 , 20 ,i);
      
       if (i< Bars - 1 ) TrendBuffer[i] = TrendBuffer[i+ 1 ];
         if (SpanBuffer[i] > MaBuffer[i]) TrendBuffer[i] = 1 ;
         if (SpanBuffer[i] < MaBuffer[i]) TrendBuffer[i] =- 1 ;
         
      
         CrossUpBuffer[i] = EMPTY_VALUE ;
         CrossDnBuffer[i] = EMPTY_VALUE ;
         if (i< Bars - 1 && TrendBuffer[i]!= TrendBuffer[i+ 1 ])
         if (TrendBuffer[i] == 1 )
               CrossUpBuffer[i] = Low [i]  - ArrowsDistance * Gap;
         else   CrossDnBuffer[i] = High [i] + ArrowsDistance * Gap; 
         }
         
         if (AlertsOn)
         {
         if (AlertsOnCurrent)
                  WhichBar = 0 ;
         else      WhichBar = 1 ;      
      
         if (TrendBuffer[WhichBar] != TrendBuffer[WhichBar+ 1 ])
         if (TrendBuffer[WhichBar] == 1 )
               doAlert( "uptrend" );
         else   doAlert( "downtrend" );       
   }
   
   return ( 0 );
}


// CUSTOM FUNCTIONS -------------------------

 void doAlert( string doWhat)
{
   static string    previousAlert= "nothing" ;
   static datetime previousTime;
   string message;
   
       if (previousAlert != doWhat || previousTime != Time [ 0 ]) {
          previousAlert  = doWhat;
          previousTime   = Time [ 0 ];

          message =   StringConcatenate ( Symbol (), " at " , TimeToStr ( TimeLocal (), TIME_SECONDS ), " Span ma cross " , doWhat);
             if (AlertsMessage) Alert (message);
             if (AlertsEmail)   SendMail ( StringConcatenate ( Symbol (), " Span ma cross " ), message);
             if (AlertsSound)   PlaySound (SoundFile);
      }
}
 
mladen :

düzeltme:

Bundan sigmanın 74 ve 75 satırlarını değiştirin:

buna :

Ve çalışması gerekir

Veya katı ifadeyi tamamen kaldırın (çünkü "katı" ile kullanılacaksa bu göstergenin tamamen yeniden yazılması gerekir)

sevgili mladen,

Her iki öneriyi de başarılı olmadan denedim ancak aşağıdaki resimde olduğu gibi bir EA'da çalışırken indi'nin güncellenmediğini fark ettim.

Düzeltmek mümkün olmalı mı? :

Dosyalar:
Sigma.mq4  5 kb
 
mladen :

thefxpros

şöyle dene

Mladen'i denedim ve çalışıyor gibi görünüyor ama strateji test cihazında kendini yenilemiyor ve uyarı vermiyor, piyasa açıldığında gerçek piyasada deneyeceğim. Teşekkürler
 

Merhaba Bay Mladen,

Fiyat trendin tersine döndüğünde ve "almayı bekle" ve "satmayı bekle" olduğunda bir yorum eklemeyi düşünüyordum.

Yeni satırı satın almak için eklemek sorun değil, ancak satmak için eklediğinizde işe yaramıyor.

Neyi değiştirmem gerekiyor?

   string OPstr;
   color OPclr;
   if (buffer1[i+SignalCandle]>buffer5[i+SignalCandle]) {
      OPstr = "BUY" ;
      OPclr = Green;
      }
   if (buffer1[i+SignalCandle]>buffer5[i+SignalCandle] && Bid < buffer1[i+SignalCandle] ) {
      OPstr = "WAIT FOR BUY" ;
      OPclr = LimeGreen;
      }       
   else
   
   if (buffer1[i+SignalCandle]<buffer6[i+SignalCandle] ) {
      OPstr = "SELL" ;
      OPclr = Red;
      }
   if (buffer1[i+SignalCandle]<buffer6[i+SignalCandle] && Bid > buffer1[i+SignalCandle] ) {
      OPstr = "WAIT FOR SELL" ;
      OPclr = OrangeRed;
      }        
   else 
      {
      OPstr = "NO TRADE" ;
      OPclr = Yellow;
      }