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

 
나는 새로운 지표를 발견했고 고문에 넣고 싶었습니다. 그러나 사실은 그가 각 양초에 대해 거래를 시작한다는 것입니다. 화살표의 신호에서만 열리게 하는 방법을 알려주세요.
 //------------------------------------------------------------------
#property copyright "Hill"
#property link        "Romio.com"
//------------------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Orange
#property indicator_color2 DarkGray
#property indicator_color3 Orange
#property indicator_color4 LimeGreen
#property indicator_style2 STYLE_DOT
#property indicator_style3 STYLE_DOT
#property indicator_style4 STYLE_DOT
//

//
//
//
//
//

extern int     RsiLength  = 4 ;
extern int     RsiPrice   = PRICE_CLOSE ;
extern int     HalfLength = 5 ;
extern int     DevPeriod  = 100 ;
extern int     Sise       = 10 ;
extern double Deviations = 1.0 ;
extern bool    UseAlert   = true ;
extern bool    DrawArrows = true ;

color ColorDn = Crimson;
color ColorUp = DodgerBlue;
int      CodDn = 222 ;
int      CodUp = 221 ;

string    Font = "Verdana" ;

// ti init() if(ObjectFind("100s")<0)GetText(3,"100s","BuySell Pro",LawnGreen,5,5,7);


string PrefixArrow = "ArrowsHill" ;

double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];

double up[];
double dn[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   HalfLength= MathMax (HalfLength, 1 );
   SetIndexBuffer ( 0 ,buffer1);
   SetIndexBuffer ( 1 ,buffer2);
   SetIndexBuffer ( 2 ,buffer3);
   SetIndexBuffer ( 3 ,buffer4);

   SetIndexStyle( 4 , DRAW_ARROW , 0 , 2 ,Blue);
   SetIndexArrow( 4 , 233 );
   SetIndexBuffer ( 4 ,up);

   SetIndexStyle( 5 , DRAW_ARROW , 0 , 2 ,Red);
   SetIndexArrow( 5 , 234 );
   SetIndexBuffer ( 5 ,dn);


   return ( 0 );
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   DellObj(PrefixArrow);

   return ( 0 );
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i,j,k,counted_bars=IndicatorCounted();
   if (counted_bars< 0 )
       return (- 1 );
   if (counted_bars> 0 )
      counted_bars--;
   int limit= MathMin ( Bars - 1 , Bars -counted_bars+HalfLength);

   static datetime timeLastAlert = NULL ;

   for (i=limit; i>= 0 ; i--)
      buffer1[i] = iRSI ( NULL , 0 ,RsiLength,RsiPrice,i);
   for (i=limit; i>= 0 ; i--)
     {
       double dev  = iStdDevOnArray(buffer1, 0 ,DevPeriod, 0 , MODE_SMA ,i);
       double sum  = (HalfLength+ 1 )*buffer1[i];
       double sumw = (HalfLength+ 1 );
       for (j= 1 , k=HalfLength; j<=HalfLength; j++, k--)
        {
         sum  += k*buffer1[i+j];
         sumw += k;
         if (j<=i)
           {
            sum  += k*buffer1[i-j];
            sumw += k;
           }
        }
      buffer2[i] = sum/sumw;
      buffer3[i] = buffer2[i]+dev*Deviations;
      buffer4[i] = buffer2[i]-dev*Deviations;

       if (buffer1[i] >= buffer3[i] /*&& buffer1[i+1] < buffer3[i+1]*/ )
        {
         dn[i] = buffer3[i];
         if (DrawArrows)
            ArrowDn(Time[i], High[i]);

         if (UseAlert && i == 0 && Time[ 0 ] != timeLastAlert)
           {
             Alert ( "Signal DOWN!" );
            timeLastAlert = Time[ 0 ];
           }
        }

       if (buffer1[i] <= buffer4[i] /*&& buffer1[i+1] > buffer4[i+1] */ )
        {
         up[i] = buffer4[i];
         if (DrawArrows)
            ArrowUp(Time[i], Low[i]);

         if (UseAlert && i == 0 && Time[ 0 ] != timeLastAlert)
           {
             Alert ( "Signal UP!" );
            timeLastAlert = Time[ 0 ];
           }
        }
     }
   return ( 0 );
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ArrowUp( datetime tim, double pr)
  {
   if ( ObjectFind (PrefixArrow+ "TextUp" +tim)==- 1 )
     {
       if ( ObjectCreate (PrefixArrow+ "TextUp" +tim, OBJ_TEXT , 0 ,tim,pr-GetDistSdvig()))
         ObjectSetText(PrefixArrow+ "TextUp" +tim,CharToStr(CodUp),Sise, "WingDings" ,ColorUp);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ArrowDn( datetime tim, double pr)
  {
   if ( ObjectFind (PrefixArrow+ "TextDn" +tim)==- 1 )
     {
       if ( ObjectCreate (PrefixArrow+ "TextDn" +tim, OBJ_TEXT , 0 ,tim,pr+GetDistSdvig()))
         ObjectSetText(PrefixArrow+ "TextDn" +tim,CharToStr(CodDn),Sise, "WingDings" ,ColorDn);
     }
  }
extern double TextSdvigMnoj = 2 ;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetDistSdvig()
  {
   return ( iATR ( NULL , 0 , 100 , 1 ) * TextSdvigMnoj);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DellObj( string dell)
  {
   string name;
   for ( int i = ObjectsTotal ()- 1 ; i >= 0 ; i--)
     {
      name = ObjectName (i);
       if ( StringFind (name, dell) != EMPTY)
         ObjectDelete (name);
     }
  }
//+------------------------------------------------------------------+
 
jarikn :
나는 새로운 지표를 발견했고 고문에 넣고 싶었습니다. 그러나 사실은 그가 각 양초에 대해 거래를 시작한다는 것입니다. 화살표의 신호에서만 열리게 하는 방법을 알려주세요.

첫째, 지표는 전혀 새로운 것이 아니라 매우 오래된 것입니다. 너무 오래되어 인터페이스가 4-ki에서도 구식입니다.

둘째, 다시 그려집니다. 정확히 HalfLength에서(기본적으로 5개 막대, 매개변수에서 설정)

그리고 마지막으로 - 고문을 위한 거래를 여는 방법은 고문에게 90% 의존합니다. 즉, 고문 코드가 없으면 모든 것이 쓸모가 없습니다.

 
Maxim Kuznetsov :

첫째, 지표는 전혀 새로운 것이 아니라 매우 오래된 것입니다. 너무 오래되어 인터페이스가 4-ki에서도 구식입니다.

둘째, 다시 그려집니다. 정확히 HalfLength에서(기본적으로 5개 막대, 매개변수에서 설정)

그리고 마지막으로 - 고문을 위한 거래를 여는 방법은 고문에게 90% 의존합니다. 즉, 고문 코드가 없으면 모든 것이 쓸모가 없습니다.

확인. 이해했다. 예를 들어, 기간이 다른 2개의 이러한 표시기를 사용하고 다음 조건을 작성하는 경우 * 표시기 1이 위쪽 화살표를 표시하고 표시기 2가 한 양초에 위쪽 화살표를 표시하면 예를 들어 경고 및 화살표를 발행합니다. 도표 *. 이 작업을 수행할 수 있는 방법을 제안할 수 있습니까? 버퍼를 추가해야 합니까 아니면 두 신호를 모두 따르도록 표시기를 만들 수 있습니까? 글쎄, 어렵지 않다면 그것을하는 방법의 예를 들어보십시오.

 
jarikn :

확인. 이해했다. 예를 들어, 기간이 다른 2개의 이러한 표시기를 사용하고 다음 조건을 작성하는 경우 * 표시기 1이 위쪽 화살표를 표시하고 표시기 2가 한 양초에 위쪽 화살표를 표시하면 예를 들어 경고 및 화살표를 발행합니다. 도표 *. 이 작업을 수행할 수 있는 방법을 제안할 수 있습니까? 버퍼를 추가해야 합니까 아니면 두 신호를 모두 따르도록 표시기를 만들 수 있습니까? 글쎄, 어렵지 않다면 그것을하는 방법의 예를 들어보십시오.

기간이 다른 두 개의 iCustoms를 고문에게 추가하면 (아마도) 만족할 것입니다.
 
MakarFX :
기간이 다른 두 개의 iCustoms를 고문에게 추가하면 (아마도) 만족할 것입니다.

응 시도해 볼게. 고맙습니다

 

그리고 다시 안녕하세요))) 어떤 종류의 지표를 말할 수 있습니까?

<*.ex* 파일 제거됨>

 

친애하는, 나는 통과 점수를 기반으로 지그재그 표시기를 작성하려고합니다.

불행히도, 나는 그것을 스스로 쓸 지식이 충분하지 않아, 나는 다른 사람의 지표를 다시 만들기로 결정했습니다.

그 일이 일어난거야

 #property link        " https://www.mql5.com "
#property version    "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots    1
//--- plot Label1
#property indicator_label1    "Label1"
#property indicator_type1    DRAW_SECTION
#property indicator_color1    clrCrimson
#property indicator_style1    STYLE_SOLID
#property indicator_width1    1
//--- input parameters
input int       Points= 50 ;
//--- indicator buffers
int Trend= 1 ,InTrend;
datetime ttime;
double Last_High,Last_Low;
double Buffer01[],Buffer02[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
   IndicatorBuffers( 2 );
   IndicatorDigits( Digits );
//--- indicator buffers mapping
   SetIndexBuffer ( 0 ,Buffer01);
   SetIndexBuffer ( 1 ,Buffer02);
   SetIndexEmptyValue( 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[])
  {
//---
   int limit=rates_total-prev_calculated- 2 ;
   if (limit< 2 ) return ( 0 );
   for ( int i=limit; i>= 0 ;i--)
     {
       if (time[i]!=ttime) {InTrend=InTrend+ 1 ; ttime=time[i];}
      Buffer01[i]= 0 ;
      Buffer02[i]= open[i]; 
       if (Buffer02[i+ 1 ]>Last_High && Trend== 1 )   InTrend= 1 ;
       if (Buffer02[i+ 1 ]<Last_Low  && Trend== 0 )   InTrend= 1 ;
       if (Buffer02[i+ 1 ]>Last_High) Last_High=Buffer02[i+ 1 ];
       if (Buffer02[i+ 1 ]<Last_Low ) Last_Low =Buffer02[i+ 1 ];
       //----
       if (Trend== 1 && Buffer02[i+ 1 ]<Last_High-Points* Point && InTrend> 1 )
        {
         Trend= 0 ;
         if (i+InTrend< ArraySize (Buffer01))
         Buffer01[i+InTrend]=Buffer02[i+InTrend];
         Last_High=Buffer02[i+ 1 ];
         Last_Low=Buffer02[i+ 1 ];
         InTrend= 1 ;
        }
       if (Trend== 0 && Buffer02[i+ 1 ]>Last_Low+Points* Point && InTrend> 1 )
        {
         Trend= 1 ;
         if (i+InTrend< ArraySize (Buffer01))
         Buffer01[i+InTrend]=Buffer02[i+InTrend];
         Last_Low=Buffer02[i+ 1 ];
         Last_High=Buffer02[i+ 1 ];
         InTrend= 1 ;
        }
     }
//--- return value of prev_calculated for next call
   return (rates_total);
  }
//+------------------------------------------------------------------+

그리고 제대로 그리는 것 같지만 늦었다.

화면에서 가격은 이미 50포인트를 넘어섰지만 지표는 그리지 않습니다.

문제 해결을 도와주세요.

 
MakarFX :

문제 해결을 도와주세요.

여기에서 MT5 ZZ를 포인트로 배치했습니다.

https://www.mql5.com/en/forum/318267#comment_12508440


기본 계산 주기에서 번호 매기기를 변경하면 MT4에서 작동해야 합니다.

 
Igor Makanu :

여기에서 MT5 ZZ를 포인트로 배치했습니다.

https://www.mql5.com/en/forum/318267#comment_12508440


기본 계산 주기에서 번호 매기기를 변경하면 MT4에서 작동해야 합니다.

Igor는 감사하지만 MT4가 제대로 작동하지 않습니다.


고쳐야 할 점을 알려주세요

 
그런 문제에 직면했습니다. MT4에 MT2 인디케이터를 붙였습니다. 이론적으로 표시기 버퍼를 읽고 화살표가 나타나면 바이너리 옵션에 대한 트랜잭션을 자동으로 열어야 합니다. 그러나 문제는 그가 나를 위해 모든 새 양초만 거래를 시작한다는 것입니다. 뭐가 문제인지 누가 알겠어?
파일:
Screenshot_8.png  121 kb
123.mq4  5 kb