MQL4 및 MQL5에 대한 초보자 질문, 알고리즘 및 코드에 대한 도움말 및 토론 - 페이지 1170

 
Carcass77 :

내 표시기가 작동 중이며 확장 중입니다. 문자열 ; 추가되었다.

알았어, 내가 갈게

이것이 당신의 지표라면, 그 질문은 가볍게 말해서 놀라운 것처럼 보입니다.

 
Сергей Таболин :

이것이 당신의 지표라면, 그 질문은 가볍게 말해서 놀라운 것처럼 보입니다.

벌었다. 질문은 문자열 변수 선언의 "형식"이었습니다. 저는 여전히 프로그래머 여러분, 무엇이든 배우고 있습니다.

 
Carcass77 :

벌었다. 질문은 문자열 변수 선언의 "형식"이었습니다. 저는 여전히 프로그래머 여러분, 무엇이든 배우고 있습니다.

모두가 배우고 있어, 괜찮아

내 질문이 제기되었습니다. 왜냐하면 귀하의 예제는 초보자 수준이 아니었지만 변수 유형 및 범위에 대한 질문은 코드를 처음 작성하려고 할 때 가장 먼저 이해해야 하는 것입니다.

 
Carcass77 :

벌었다. 질문은 문자열 변수 선언의 "형식"이었습니다. 저는 여전히 프로그래머 여러분, 무엇이든 배우고 있습니다.

저도 아직 배우는 중입니다 )))) 그리고 더 많은 것을 배울 수 있기를 바랍니다 ;)

 

모두를 환영합니다! 버튼, 이름 + 값을 전달하는 방법(예제 버튼 Lot = 0.1)?

모두 미리 감사드립니다!

 
안녕하세요! 낮은 프랙탈에 추세선 을 그리려고하는데 작동하지 않습니다. 첫 번째 지점에 대해 그는 시간의 시작을 잡고 한 줄을 그리면 끝입니다. 다음 프랙탈로 넘어가지 않는데 내가 뭘 잘못하고 있는 거지, 어떻게 고쳐?
 datetime firsttime1;
datetime firsttime2;
datetime secondtime1;
datetime secondtime2;
double   firstprice1;
double   firstprice2;
double   secondprice1;
double   secondprice2;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit ()
  {
//---
   
//---
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick ()
  {
   if (Hour()>= 9 && Hour()< 22 )
   {
    Fun_New_Bar();
     if (New_Bar)      
     {

double vallo= iFractals ( NULL , 0 ,MODE_LOWER, 2 ); Alert ( "vallo = " ,vallo);
      { if (vallo> 0 )
       {
       //забиваем координаты второй точки для линии Low
       secondtime1=( TimeCurrent ()- 7200 );
       secondprice1= iLow ( NULL , 0 , 2 );
       
       //рисуем трендовую линию Low
       ObjectCreate ( "LowLine" , OBJ_TREND , 0 ,firsttime1,firstprice1,secondtime1,secondprice1);

      firsttime1=secondtime1;
      firstprice1=secondprice1;
   
       }
      }
     }
   }
  } 
 

코드베이스에서 다운로드한 SuperTrend 표시기에 화살표를 추가했습니다. 시작 시 일반적으로 화살표를 그립니다.


그러나 차트를 뒤로/왼쪽으로 스크롤하면 쓰레기가 나타나고 모든 것이 무너집니다.


코드는 다음과 같습니다.

 //+------------------------------------------------------------------+
//|                                                   SuperTrend.mq4 |
//|                   Copyright © 2008, Jason Robinson (jnrtrading). |
//|                                   http://www.spreadtrade2win.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Jason Robinson."
#property link        "http://www.spreadtrade2win.com"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 clrLime
#property indicator_color2 clrRed
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 3
#property indicator_width4 3

enum en_trend {
   Modern,   // Modern
   Classic,   // Classic
};

//+------------------------------------------------------------------+
//| Universal Constants                                              |
//+------------------------------------------------------------------+
#define PHASE_NONE 0
#define PHASE_BUY   1
#define PHASE_SELL - 1

//+------------------------------------------------------------------+
//| User input variables                                             |
//+------------------------------------------------------------------+
input en_trend TrendMode      = Modern;   // Trend Line Mode
input int       ATR_Period     = 10 ;       // ATR Period
input double    ATR_Multiplier = 3.0 ;       // ATR Multiplier
input int       BarsToCount    = 0 ;         // Bars to count (0 - all bars)
input color     clr_Up         = clrLime ;   // Arrow Up Color
input color     clr_Dn         = clrRed ;   // Arrow Down Color

//+------------------------------------------------------------------+
//| Universal variables                                              |
//+------------------------------------------------------------------+
double buffer_line_up[];
double buffer_line_down[];
double ArrowUpBuffer[];
double ArrowDnBuffer[];

double atr,
       band_upper,
       band_lower,
       shift;
int     phase=PHASE_NONE;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
   IndicatorShortName( "Super Trend" );
   IndicatorDigits(( int )MarketInfo( Symbol (),MODE_DIGITS));
   SetIndexBuffer ( 0 ,buffer_line_up);
   SetIndexLabel( 0 , "Up Trend" );
   SetIndexBuffer ( 1 ,buffer_line_down);
   SetIndexLabel( 1 , "Down Trend" );

//--- 2 additional arrows buffers
//---- drawing settings
   SetIndexStyle( 2 , DRAW_ARROW , STYLE_SOLID ,EMPTY,clr_Up);
   SetIndexArrow( 2 , 233 );
   SetIndexStyle( 3 , DRAW_ARROW , STYLE_SOLID ,EMPTY,clr_Dn);
   SetIndexArrow( 3 , 234 );
//---- indicator buffers
   SetIndexBuffer ( 2 ,ArrowUpBuffer);
   SetIndexBuffer ( 3 ,ArrowDnBuffer);
   SetIndexEmptyValue( 2 , 0.0 );
   SetIndexEmptyValue( 3 , 0.0 );  
  
   return ( 0 );
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return ( 0 );
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();
   if (counted_bars< 0 ) return (- 1 );
   if (counted_bars> 0 ) counted_bars--;
   int limit= Bars -counted_bars;
   if (counted_bars== 0 ) limit-= 1 + 2 ;

   for ( int i=limit; i>= 0 ; i--) 
     {
      atr   = iATR ( Symbol (), 0 ,ATR_Period,i);
      shift = 0.5 * iATR ( Symbol (), 0 , 100 ,i);;
      band_upper = (High[i]+Low[i])/ 2 + ATR_Multiplier * atr;
      band_lower = (High[i]+Low[i])/ 2 - ATR_Multiplier * atr;

       if (phase==PHASE_NONE) 
        {
         buffer_line_up[i]=(High[i+ 1 ]+Low[i+ 1 ])/ 2 ;
         buffer_line_down[i]=(High[i+ 1 ]+Low[i+ 1 ])/ 2 ;
        }

       if (phase!=PHASE_BUY && Close[i]>buffer_line_down[i+ 1 ] && buffer_line_down[i+ 1 ]!= EMPTY_VALUE ) 
        {
         phase = PHASE_BUY;
         buffer_line_up[i]=band_lower;
         buffer_line_up[i+ 1 ]=buffer_line_down[i+ 1 ];
        }

       if (phase!=PHASE_SELL && Close[i]<buffer_line_up[i+ 1 ] && buffer_line_up[i+ 1 ]!= EMPTY_VALUE ) 
        {
         phase = PHASE_SELL;
         buffer_line_down[i]=band_upper;
         buffer_line_down[i+ 1 ]=buffer_line_up[i+ 1 ];
        }

       if (phase==PHASE_BUY
         && ((TrendMode== 0 && buffer_line_up[i+ 2 ]!= EMPTY_VALUE ) || TrendMode== 1 )) 
        {
         if (band_lower>buffer_line_up[i+ 1 ]) 
           {
            buffer_line_up[i]=band_lower;
           }
         else 
           {
            buffer_line_up[i]=buffer_line_up[i+ 1 ];
           }
        }
       if (phase==PHASE_SELL
         && ((TrendMode== 0 && buffer_line_down[i+ 2 ]!= EMPTY_VALUE ) || TrendMode== 1 )) 
        {
         if (band_upper<buffer_line_down[i+ 1 ]) 
           {
            buffer_line_down[i]=band_upper;
           }
         else 
           {
            buffer_line_down[i]=buffer_line_down[i+ 1 ];
           }
        }
        
         // Make Arrows
         if (buffer_line_up[i+ 1 ]  != EMPTY_VALUE && 
            buffer_line_up[i+ 2 ]  != EMPTY_VALUE && 
            buffer_line_down[i+ 2 ]!= EMPTY_VALUE ) {
           ArrowUpBuffer[i+ 1 ]=Low[i+ 1 ]-shift;
           ArrowDnBuffer[i+ 1 ]= 0.0 ;

        }
         if (buffer_line_down[i+ 1 ] != EMPTY_VALUE && 
            buffer_line_down[i+ 2 ] != EMPTY_VALUE && 
            buffer_line_up[i+ 2 ]   != EMPTY_VALUE ) {
           ArrowDnBuffer[i+ 1 ]=High[i+ 1 ]+shift;
           ArrowUpBuffer[i+ 1 ]= 0.0 ;

        }
     }

   return ( 0 );
  }
//+------------------------------------------------------------------+

뭘 망쳤는지 말해주세요.

Supertrend
Supertrend
  • www.mql5.com
AudioPrice Revision 1 Have audio output of latest price in stereo! Revised to cater for fractional pips as now offered by some brokers to MT4. Stochastic Net Stochastic net for the the classification problems with the instruction provided.
파일:
 
Grigori.SB :

뭘 망쳤는지 말해주세요.

이 애드온을 별도로 삽입한 것을 망쳤습니다. 화살표는 버퍼를 변경하는 순간에만 설정해야 합니다. 동시에 다른 모든 경우에는 버퍼에 빈 값을 넣는 것을 잊지 마십시오.

이 방법은 훨씬 더 좋습니다. 즉시 빈 값을 설정하고 추세가 변경되면 버퍼 중 하나를 화살표로 채웁니다.

 
Grigori.SB :

그러나 차트를 뒤로/왼쪽으로 스크롤하면 쓰레기가 나타나고 모든 것이 무너집니다.

이야기가 꼬이는가? 이 경우에 대한 재계산이 없으며 나타난 표시기 버퍼의 새 요소는 쓰레기로 채워집니다.

 
아무도 대답하고 싶어하지 않기 때문에 아마도 내가 다시 기초적인 것을 놓치고 있습니까?