코딩 도움말 - 페이지 678

 
mladen :

시몬

조건이 더 세련되어야 합니다. 예를 들어, 둘 다 같은 신호를 보내는 경우가 매우 많습니다. 그래서, 그들은 정확히 언제 그것을 해야 합니다. 처음 발생했을 때? 그럴 때마다? 또한 둘 중 하나가 변경되어 종료하는 경우 종료가 매우 자주 발생합니다.

답변 감사합니다! 예, 이것은 좋은 전략이 아닐 수도 있습니다. 이것을 템플릿으로 받으면 나중에 스스로 약간의 변경을 할 수 있다는 것입니다. 내가 원하는 것은 두 개의 지표를 결합할 수 있는 가능성입니다(및 해당 버퍼의 사용).

대신 전략이 다음과 같아야 한다고 가정해 보겠습니다. 두 지표가 모두 표시될 때 매수합니다. 그리고 두 지표가 모두 표시될 때 매도하십시오. 표시기 변경 및 닫힌 막대 후에 발생해야 합니다. 그럴 때마다 발생해야 합니다.

모두 제일 좋다!

 

친애하는 mladen,


첨부된 표시기에 문제가 있습니다.

EA 실행 중에 indi가 적용될 때(MT4의 표준 이동 평균) 값은 EA 실행이 끝날 때 동일한 표시기를 적용하여 표시되는 값과 매우 다릅니다.

왜 그리고 가능하다면 indi를 수정하는지 설명해 주시겠습니까?


파일:
 

믈라덴 씨,

ma 채널에 채워진 ma 리본에 대해 약간의 변경을 수행하고 있지만 버퍼에 문제가 있습니다.

히스토그램 뒤에 채널을 숨기거나 채널 사이에 공백을 만들 수 있는 방법이 있습니까?

나는 그것을 비우려고하지만 한쪽에서만 그것을 할 수 있습니다. 버퍼를 하나 더 추가해야합니까?

그리고 또 하나의 문제는 44행에 있습니다. extern하거나 삭제할 수 없습니다.

항상 오류가 나옵니다.

조언 좀 부탁드립니다. 감사합니다.

스티븐 .


 
stevenpun :

믈라덴 씨,

ma 채널에 채워진 ma 리본에 대해 약간의 변경을 수행하고 있지만 버퍼에 문제가 있습니다.

히스토그램 뒤에 채널을 숨기거나 채널 사이에 공백을 만들 수 있는 방법이 있습니까?

나는 그것을 비우려고하지만 한쪽에서만 그것을 할 수 있습니다. 버퍼를 하나 더 추가해야합니까?

그리고 또 하나의 문제는 44행에 있습니다. extern하거나 삭제할 수 없습니다.

항상 오류가 나옵니다.

조언 좀 부탁드립니다. 감사합니다.

스티븐 .


이것이 당신이하려는 일인지 확실하지 않지만 시도하십시오.


 
mladen :

이것이 당신이하려는 일인지 확실하지 않지만 시도하십시오.


네, 정확히 제가 원하는 것입니다 :D

하지만 44행 'AlertOnClosedCandle'에서 코드를 확인 하는 데 도움을 줄 수 있습니까? 왜 삭제 또는 extern bool이 되지 않습니까?

이런 유형의 문제는 처음입니다.

어쨌든 나는 버퍼에 대해 몇 가지를 배웠습니다.

고맙습니다 .

 

Mladen은 방금 수정한 이전 지표에서 내 사용자 지정을 완료했습니다. 이 코드에서 잘못된 것은 무엇입니까? 아무것도 표시하지 않습니다...컴파일할 때 오류가 없습니다.

 #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은 방금 수정한 이전 지표에서 내 사용자 지정을 완료했습니다. 이 코드에서 잘못된 것은 무엇입니까? 아무것도 표시하지 않습니다...컴파일할 때 오류가 없습니다.

더 엑스프로

이렇게 해봐

 #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 :

수정:

다음에서 시그마의 74행과 75행을 변경하십시오.

이에 :

그리고 그것은 작동해야합니다

또는 strict 문을 완전히 제거합니다("strict"와 함께 사용하려면 해당 표시기를 완전히 다시 작성해야 하므로).

친애하는 mladen,

나는 성공하지 않고 두 가지 제안을 시도했지만 다음 그림과 같이 EA에서 실행할 때 indi가 업데이트되지 않는다는 것을 깨달았습니다.

그것을 고칠 수 있어야 합니까? :

파일:
Sigma.mq4  5 kb
 
mladen :

더 엑스프로

이렇게 해봐

Mladen을 시도했는데 작동하는 것 같지만 전략 테스터 에서 자체 새로 고침이 되지 않고 경고가 팝업되지 않습니다. 시장이 열리면 실제 시장에서 시도할 것입니다. 감사해요
 

안녕하세요, Mladen 씨.

가격이 추세와 반대이고 "매수 대기" 및 "매도 대기"가있을 때 의견을 추가하려고 생각했습니다.

구매 에 새 라인 을 추가 하는 것은 문제 가 되지 않지만 , 판매 를 위해 추가할 때 작동 하도록 만들 수 없습니다 .

무엇을 변경해야 합니까?

   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;
      }