포럼을 어지럽히 지 않도록 모든 초보자 질문. 프로, 놓치지 마세요. 너 없이는 아무데도 - 6. - 페이지 987

 
mario_SC-- :

이 코드로 무엇을 증명하고 싶은지 이해가 되지 않습니다. 그러나 나는 내가 수험자 범주에 맞지 않을 것이라는 것을 확실히 알고 있습니다 ... 따라서 도움이 필요하면 질문에 대답하는 범주에 들어가십시오. 이러한 사이클은 특정 조건에서 루프를 쉽게 구할 수 있으며 경우에만 이를 방지할 수 있습니다.
 

표시기를 디버깅 할 때 디버거가 "충돌"하지만 동시에 모든 것이 차트에 정상적으로 그려지는 이유는 무엇입니까?

MT4 빌드 950, 알파리 데모.

부착된 표시기.

 //+------------------------------------------------------------------+
//|                                     FX5_MACD_Divergence_V1.1.mq4 |
//|                                                              FX5 |
//|                                                    hazem@uk2.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, FX5"
#property link        "hazem@uk2.net"
//----
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Magenta
#property indicator_color4 Blue
//----
#define arrowsDisplacement 0.0001
//---- input parameters
extern string separator1 = "*** MACD Settings ***" ;
extern int     fastEMA = 12 ;
extern int     slowEMA = 26 ;
extern int     signalSMA = 9 ;
extern string separator2 = "*** Indicator Settings ***" ;
extern bool    drawIndicatorTrendLines = true ;
extern bool    drawPriceTrendLines = true ;
extern bool    displayAlert = true ;
//---- buffers
double bullishDivergence[];
double bearishDivergence[];
double macd[];
double signal[];
//----
static datetime lastAlertTime;
static string    indicatorName;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle( 0 , DRAW_ARROW );
   SetIndexStyle( 1 , DRAW_ARROW );
   SetIndexStyle( 2 , DRAW_LINE );
   SetIndexStyle( 3 , DRAW_LINE );
//----   
   SetIndexBuffer ( 0 , bullishDivergence);
   SetIndexBuffer ( 1 , bearishDivergence);
   SetIndexBuffer ( 2 , macd);
   SetIndexBuffer ( 3 , signal);   
//----   
   SetIndexArrow( 0 , 233 );
   SetIndexArrow( 1 , 234 );
//----
   indicatorName = "FX5_MACD_Divergence_v1.1(" + fastEMA + ", " + 
                                 slowEMA + ", " + signalSMA + ")" ;
   SetIndexDrawBegin( 3 , signalSMA);
   IndicatorDigits( Digits + 2 );
   IndicatorShortName(indicatorName);

   return ( 0 );
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   for ( int i = ObjectsTotal () - 1 ; i >= 0 ; i--)
     {
       string label = ObjectName (i);
       if ( StringSubstr (label, 0 , 19 ) != "MACD_DivergenceLine" )
           continue ;
       ObjectDelete (label);   
     }
   return ( 0 );
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int countedBars = IndicatorCounted();
   if (countedBars < 0 )
       countedBars = 0 ;
   CalculateIndicator(countedBars);
//---- 
   return ( 0 );
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CalculateIndicator( int countedBars)
  {
   for ( int i = Bars - countedBars; i >= 0 ; i--)
     {
       CalculateMACD(i);
       CatchBullishDivergence(i + 2 );
       CatchBearishDivergence(i + 2 );
     }              
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CalculateMACD( int i)
  {
   macd[i] = iMACD ( NULL , 0 , fastEMA, slowEMA, signalSMA, 
                   PRICE_CLOSE , MODE_MAIN, i);
   
   signal[i] = iMACD ( NULL , 0 , fastEMA, slowEMA, signalSMA, 
                     PRICE_CLOSE , MODE_SIGNAL, i);         
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CatchBullishDivergence( int shift)
  {
   if (IsIndicatorTrough(shift) == false )
       return ;  
   int currentTrough = shift;
   int lastTrough = GetIndicatorLastTrough(shift);
//----   
   if (macd[currentTrough] > macd[lastTrough] && 
      Low[currentTrough] < Low[lastTrough])
     {
       bullishDivergence[currentTrough] = macd[currentTrough] - 
                                          arrowsDisplacement;
       //----
       if (drawPriceTrendLines == true )
           DrawPriceTrendLine(Time[currentTrough], Time[lastTrough], 
                              Low[currentTrough], 
                             Low[lastTrough], Green, STYLE_SOLID );
       //----
       if (drawIndicatorTrendLines == true )
          DrawIndicatorTrendLine(Time[currentTrough], 
                                 Time[lastTrough], 
                                 macd[currentTrough],
                                 macd[lastTrough], 
                                 Green, STYLE_SOLID );
       //----
       if (displayAlert == true )
          DisplayAlert( "Classical bullish divergence on: " , 
                        currentTrough);  
     }
//----   
   if (macd[currentTrough] < macd[lastTrough] && 
      Low[currentTrough] > Low[lastTrough])
     {
       bullishDivergence[currentTrough] = macd[currentTrough] - 
                                          arrowsDisplacement;
       //----
       if (drawPriceTrendLines == true )
           DrawPriceTrendLine(Time[currentTrough], Time[lastTrough], 
                              Low[currentTrough], 
                              Low[lastTrough], Green, STYLE_DOT );
       //----
       if (drawIndicatorTrendLines == true )                            
           DrawIndicatorTrendLine(Time[currentTrough], 
                                  Time[lastTrough], 
                                  macd[currentTrough],
                                  macd[lastTrough], 
                                  Green, STYLE_DOT );
       //----
       if (displayAlert == true )
           DisplayAlert( "Reverse bullish divergence on: " , 
                        currentTrough);   
     }      
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CatchBearishDivergence( int shift)
  {
   if (IsIndicatorPeak(shift) == false )
       return ;
   int currentPeak = shift;
   int lastPeak = GetIndicatorLastPeak(shift);
//----   
   if (macd[currentPeak] < macd[lastPeak] && 
      High[currentPeak] > High[lastPeak])
     {
       bearishDivergence[currentPeak] = macd[currentPeak] + 
                                        arrowsDisplacement;
      
       if (drawPriceTrendLines == true )
           DrawPriceTrendLine(Time[currentPeak], Time[lastPeak], 
                              High[currentPeak], 
                              High[lastPeak], Red, STYLE_SOLID );
                            
       if (drawIndicatorTrendLines == true )
           DrawIndicatorTrendLine(Time[currentPeak], Time[lastPeak], 
                                  macd[currentPeak],
                                  macd[lastPeak], Red, STYLE_SOLID );

       if (displayAlert == true )
           DisplayAlert( "Classical bearish divergence on: " , 
                        currentPeak);  
     }
   if (macd[currentPeak] > macd[lastPeak] && 
      High[currentPeak] < High[lastPeak])
     {
       bearishDivergence[currentPeak] = macd[currentPeak] + 
                                        arrowsDisplacement;
       //----
       if (drawPriceTrendLines == true )
           DrawPriceTrendLine(Time[currentPeak], Time[lastPeak], 
                              High[currentPeak], 
                              High[lastPeak], Red, STYLE_DOT );
       //----
       if (drawIndicatorTrendLines == true )
           DrawIndicatorTrendLine(Time[currentPeak], Time[lastPeak], 
                                  macd[currentPeak],
                                  macd[lastPeak], Red, STYLE_DOT );
       //----
       if (displayAlert == true )
           DisplayAlert( "Reverse bearish divergence on: " , 
                        currentPeak);   
     }   
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsIndicatorPeak( int shift)
  {
   if (macd[shift] >= macd[shift+ 1 ] && macd[shift] > macd[shift+ 2 ] && 
      macd[shift] > macd[shift- 1 ])
       return ( true );
   else 
       return ( false );
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsIndicatorTrough( int shift)
  {
   if (macd[shift] <= macd[shift+ 1 ] && macd[shift] < macd[shift+ 2 ] && 
      macd[shift] < macd[shift- 1 ])
       return ( true );
   else 
       return ( false );
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int GetIndicatorLastPeak( int shift)
  {
   for ( int i = shift + 5 ; i < Bars ; i++)
     {
       if (signal[i] >= signal[i+ 1 ] && signal[i] >= signal[i+ 2 ] &&
          signal[i] >= signal[i- 1 ] && signal[i] >= signal[i- 2 ])
         {
           for ( int j = i; j < Bars ; j++)
             {
               if (macd[j] >= macd[j+ 1 ] && macd[j] > macd[j+ 2 ] &&
                  macd[j] >= macd[j- 1 ] && macd[j] > macd[j- 2 ])
                   return (j);
             }
         }
     }
   return (- 1 );
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int GetIndicatorLastTrough( int shift)
  {
     for ( int i = shift + 5 ; i < Bars ; i++)
      {
         if (signal[i] <= signal[i+ 1 ] && signal[i] <= signal[i+ 2 ] &&
           signal[i] <= signal[i- 1 ] && signal[i] <= signal[i- 2 ])
          {
             for ( int j = i; j < Bars ; j++)
              {
                 if (macd[j] <= macd[j+ 1 ] && macd[j] < macd[j+ 2 ] &&
                   macd[j] <= macd[j- 1 ] && macd[j] < macd[j- 2 ])
                     return (j);
              }
          }
      }
     return (- 1 );
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DisplayAlert( string message, int shift)
  {
   if (shift <= 2 && Time[shift] != lastAlertTime)
     {
       lastAlertTime = Time[shift];
       Alert (message, Symbol (), " , " , Period (), " minutes chart" );
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DrawPriceTrendLine( datetime x1, datetime x2, double y1, 
                         double y2, color lineColor, double style)
  {
   string label = "MACD_DivergenceLine_v1.0# " + DoubleToStr(x1, 0 );
   ObjectDelete (label);
   ObjectCreate (label, OBJ_TREND , 0 , x1, y1, x2, y2, 0 , 0 );
   ObjectSet(label, OBJPROP_RAY , 0 );
   ObjectSet(label, OBJPROP_COLOR , lineColor);
   ObjectSet(label, OBJPROP_STYLE , style);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DrawIndicatorTrendLine( datetime x1, datetime x2, double y1, 
                             double y2, color lineColor, double style)
  {
   int indicatorWindow = WindowFind(indicatorName);
   if (indicatorWindow < 0 )
       return ;
   string label = "MACD_DivergenceLine_v1.0$# " + DoubleToStr(x1, 0 );
   ObjectDelete (label);
   ObjectCreate (label, OBJ_TREND , indicatorWindow, x1, y1, x2, y2, 
                 0 , 0 );
   ObjectSet(label, OBJPROP_RAY , 0 );
   ObjectSet(label, OBJPROP_COLOR , lineColor);
   ObjectSet(label, OBJPROP_STYLE , style);
  }
//+------------------------------------------------------------------+
 
r772ra :
강세 캔들 이후 하루 중 가장 높은 비율을 찾는 것에 대한 질문에서 어떤 이유로 서버 시간대 와 관련된 부분은 들리지 않았습니다. 작업은 그날의 경계에 엄격하게 연결되어 있으며 회사마다 이러한 경계가 다릅니다. 양초의 요일은 다릅니다. 서버의 시간대에 따라 발견된 가장 높은 값은 주기적이 아닌 다른 요일에 나타납니다. 이것이 귀하의 경우 정상입니까?
 
안녕하세요!

초보자는 아니지만 "바보같은" 질문이 있습니다. tk. 거의 그런 상황을 만난 적이 없습니다.

이미 설정된 보류 주문 이 있다고 가정해 보겠습니다.
우리는 지표에 따라 가격을 움직입니다.
좋은 순간에는 순서를 수정할 수 없습니다. 새로운 결제 가격은 Ask/Bid +/- MarketInfo(Symbol(), MODE_STOPLEVEL / MODE_FREEZELEVEL) 과 같은 스톱 레벨로 인해 금지된 범위에 떨어졌습니다.

그러나 주문은 이미 "시장에" 열려 있어야 합니다.

이 경우 무엇을 할 수 있습니까?

보류 중인 항목을 삭제하고 시장에서 새 항목을 여시겠습니까?

아니면 어떻게 든 지연된 것을 열린 것으로 바꿀 수 있습니까?
 
mt4trade :
안녕하세요!

초보자는 아니지만 "바보같은" 질문이 있습니다. tk. 거의 그런 상황에 직면한 적이 없습니다.

이미 보류 중인 주문이 있다고 가정해 보겠습니다.
우리는 지표에 따라 가격을 움직입니다.
좋은 순간에는 순서를 수정할 수 없습니다. 새로운 결제 가격은 Ask/Bid +/- MarketInfo(Symbol(), MODE_STOPLEVEL / MODE_FREEZELEVEL) 과 같은 스톱 레벨로 인해 금지된 범위에 떨어졌습니다.

그러나 주문은 이미 "시장에" 열려 있어야 합니다.

이 경우 무엇을 할 수 있습니까?

보류 중인 항목을 삭제하고 시장에서 새 항목을 여시겠습니까?

아니면 어떻게 든 지연된 것을 열린 것으로 바꿀 수 있습니까?
가격에 너무 가까우면 가격이 저절로 찾을 수 있지만 그렇지 않은 경우 중지하면 더 좋을 것입니다! 그리고 한계, 그리고 인내. 테스터에서 실험을 시도하면 최적화가 최상의 옵션을 결정합니다! 행운을 빕니다!
 

도와주세요.

EA 가 독립형 차트에 설치된 경우 EA에서 start() 함수가 실행되지 않기 때문에 EA가 작동하지 않습니다.

차트를 작성하는 Expert Advisor 또는 이 차트에 첨부된 Expert Advisor에서 차트를 어떻게 업데이트할 수 있습니까?

 
borilunad :
가격에 너무 가까우면 가격이 저절로 찾을 수 있지만 그렇지 않은 경우 중지하면 더 좋을 것입니다! 그리고 한계, 그리고 인내. 테스터에서 실험을 시도하면 최적화가 최상의 옵션을 결정합니다! 행운을 빕니다!
고맙습니다! 다 이해가 됩니다. 그러나 질문에 대한 대답이 필요합니다. 주문이 작동하는 데 필요한 경우 가격이 현재 어디로 갈 것인지에 관계없이 어떻게 해야 합니까? 지연기를 삭제하고 일반 지연기를 열거나 다른 옵션이 있습니까?
 
mt4trade :
고맙습니다! 이것은 모두 이해할 수 있습니다.그러나 나는 질문에 대한 답변이 필요합니다 - 주문이 작동하는 데 필요한 경우 가격이 현재 어디로 갈 것인지에 관계없이 어떻게해야합니까? 지연기를 삭제하고 일반 지연기를 열거나 다른 옵션이 있습니까?
나를 위해, 당신이 당신의 전략을 따른다면, 그것을 따르십시오! 중간에 변경하지 않는 것이 좋습니다. 그렇지 않으면 특정 결과(긍정적이든 부정적이든)가 없으면 전략의 합리성을 확신할 수 없습니다. 이와 같이!
 
borilunad :
나를 위해, 당신이 당신의 전략을 따른다면, 그것을 따르십시오! 중간에 변경하지 않는 것이 좋습니다. 그렇지 않으면 특정 결과(긍정적이든 부정적이든)가 없으면 전략의 합리성을 확신할 수 없습니다. 이와 같이!
그리고 다시 한 번 감사합니다! 당신은 옳은 말을 했지만 질문과 관련이 없습니다. :) 다시 한 번 반복하겠습니다: 지연기의 정산 가격이 금지된 범위에 있고 수정할 수 없지만 (전략에 따라) 정산 가격에서 작동해야 하는 경우 - 그것을 "전환"하는 방법 일했어? 삭제하고 정상적으로 열리시겠습니까? 아니면 다른 옵션이 있습니까? 이 질문에 정확히 답해 주십시오.
 
mt4trade :
그리고 다시 한 번 감사합니다! 당신은 옳은 말을 했지만 질문과 관련이 없습니다. :) 다시 한 번 반복하겠습니다: 지연기의 정산 가격이 금지된 범위에 있고 수정할 수 없지만 (전략에 따라) 정산 가격에서 작동해야 하는 경우 - 그것을 "전환"하는 방법 하나 일했어? 삭제하고 정상적으로 열리시겠습니까? 아니면 다른 옵션이 있습니까? 이 질문에 정확히 답해 주십시오.
이 접근 방식에는 일관성이 없습니다. 보류 중인 주문 에서 이미 동결 영역(수정 불가)에서 포지션이 열릴 것으로 예상되는 경우 이 동결의 경계에서 다른 가격으로 주문이 처음에 연기되어야 합니다. 이러한 이유로 귀하의 접근 방식은 여전히 많은 사람들에게 받아들여지지 않습니다.

특히 귀하의 질문에 대한 경우. 먼저 보류 중인 주문을 제거한 다음 현재 가격으로 즉시 포지션을 엽니다. 문제는 이러한 조치를 취하는 동안 가격이 동결 영역을 벗어날 수 있고(심각한 경우) 위치가 잘못된 가격으로 열릴 수 있다는 것입니다. 또 다른 옵션은 보류 주문을 생성하는 것이 아니라 프로그램에서 변수에 값을 작성하여 포지션을 여는 것입니다. 현재 가격과 비교하고 조건이 충족되면(동결 영역 고려) 포지션을 엽니다.