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

 
Artyom Trishkin :
더 깊이 들여다봐야...

더 깊은 곳은 어디 입니까?

새로운 표시기가 있는 모든 시도는 중단으로 이어집니다.

그리고 변경되지 않은 표시기로 단기 제동.

해결책은 무엇입니까?

 
mila.com :

더 깊은 곳은 어디 입니까?

새로운 표시기가 있는 모든 시도는 중단으로 이어집니다.

그리고 변경되지 않은 표시기로 단기 제동.

해결책은 무엇입니까?

지표에서 다른 사용자 지정 지표의 데이터를 사용하는 대신, 특히 모든 차원의 프랙탈을 검색하는 대신 이러한 프랙탈을 검색하기 위한 함수를 만들고 작업하십시오.
 
Artyom Trishkin :
그런 프랙탈에 대한 검색 기능을 만들고 작업하십시오.

이것은 당신을 위한 것입니다, 그냥 하세요)

하지만 저에게는 벅찬 작업입니다.

여기에 그런 기능이 있습니까?


bool isDnFractal( int bar, int max, const double &low[])
  {
//---
   for ( int i= 1 ; i<=max; i++) {
       if (i<=leftSide && low[bar]>low[bar-i])     return ( false );
       if (i<=rightSide && low[bar]>=low[bar+i])   return ( false );
      }
//---
   return ( true );
  }

이것은 다운 프랙탈 입니다.

사용 방법?

 
mila.com :

이것은 당신을 위한 것입니다, 더 쉽게 할 수 있습니다)

하지만 저에게는 벅찬 작업입니다.

해당 표시기의 기능을 광산에 이식하는 방법은 무엇입니까?


bool isDnFractal( int bar, int max, const double &low[])
  {
//---
   for ( int i= 1 ; i<=max; i++) {
       if (i<=leftSide && low[bar]>low[bar-i])     return ( false );
       if (i<=rightSide && low[bar]>=low[bar+i])   return ( false );
      }
//---
   return ( true );
  }

글쎄, 당신은 필요한 막대에 프랙탈의 가격을 반환하는 데 필요합니다. 여기에 간단한 지표를 던졌습니다. 그것은 당신이 그것을 꺼낼 수 있는 두 가지 기능을 가지고 있으며, 유효하지 않은 값을 검사하면서 특별히 그것들을 기능으로 배열하여 자체적으로 사용할 수 있습니다.

//+------------------------------------------------------------------+
//|                                             iFreeNumFractals.mq4 |
//|              Copyright 2016, Artem A. Trishkin, Skype artmedia70 |
//|                       https://login.mql5.com/ru/users/artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, Artem A. Trishkin, Skype artmedia70"
#property link        "https://login.mql5.com/ru/users/artmedia70"
#property version    "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots    2
//--- plot UpperFractal
#property indicator_label1   "UpperFractal"
#property indicator_type1   DRAW_ARROW
#property indicator_color1   clrRed
#property indicator_style1   STYLE_SOLID
#property indicator_width1   1
//--- plot LowerFractal
#property indicator_label2   "LowerFractal"
#property indicator_type2   DRAW_ARROW
#property indicator_color2   clrSteelBlue
#property indicator_style2   STYLE_SOLID
#property indicator_width2   1
//--- input parameters
input           int       LeftNum= 2 ;     // Количество баров слева
int leftNum;     // Количество баров слева
input           int       RightNum= 2 ;     // Количество баров справа
int rightNum;     // Количество баров справа
//--- indicator buffers
double          BufferUpperFractal[];
double          BufferLowerFractal[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
//--- indicator buffers mapping
   SetIndexBuffer ( 0 ,BufferUpperFractal);
   SetIndexBuffer ( 1 ,BufferLowerFractal);
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
   PlotIndexSetInteger ( 0 , PLOT_ARROW , 159 );
   PlotIndexSetInteger ( 1 , PLOT_ARROW , 159 );
   SetIndexArrow ( 0 , 217 );
   SetIndexArrow ( 1 , 218 );
//---
   leftNum=(LeftNum< 1 ? 1 :LeftNum);
   rightNum=(RightNum< 1 ? 1 :RightNum);
//---
   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[])
  {
//---
   if (rates_total<leftNum+rightNum) return ( 0 );
   int limit=rates_total-prev_calculated;
   if (limit> 0 ) {
       ArrayInitialize (BufferUpperFractal, 0.0 );
       ArrayInitialize (BufferUpperFractal, 0.0 );
      limit=rates_total-leftNum- 1 ;
      }
   //---
   for ( int i=limit; i>rightNum; i--) {
       if (GetFreeUpperFractal(i,limit,high,leftNum,rightNum)> 0 ) BufferUpperFractal[i]=high[i];
       if (GetFreeLowerFractal(i,limit,low ,leftNum,rightNum)> 0 ) BufferLowerFractal[i]=low[i];
      }
//--- return value of prev_calculated for next call
   return (rates_total);
  }
//+----------------------------------------------------------------------------+
double GetFreeLowerFractal( int shift, const int limit, const double &low[], int left_dimension= 2 , int right_dimension= 2 ) {
   if (left_dimension< 1 )  left_dimension= 1 ;
   if (right_dimension< 1 ) right_dimension= 1 ;
   if (shift-right_dimension< 1 || shift+left_dimension>limit-1) return (- 1 );
   for ( int i=shift; i>shift-right_dimension; i--) if (low[i]>low[i- 1 ]) return (- 1 );
   for ( int i=shift; i<shift+left_dimension; i++)   if (low[i]>low[i+ 1 ]) return (- 1 );
   return (low[shift]);
}
//+----------------------------------------------------------------------------+
double GetFreeUpperFractal( int shift, const int limit, const double &high[], int left_dimension= 2 , int right_dimension= 2 ) {
   if (left_dimension< 1 )  left_dimension= 1 ;
   if (right_dimension< 1 ) right_dimension= 1 ;
   if (shift-right_dimension< 1 || shift+left_dimension>limit-1) return (- 1 );
   for ( int i=shift; i>=shift-right_dimension; i--) if (high[i]<high[i- 1 ]) return (- 1 );
   for ( int i=shift; i<=shift+left_dimension; i++)   if (high[i]<high[i+ 1 ]) return (- 1 );
   return (high[shift]);
}
//+----------------------------------------------------------------------------+
 

표시기에서 임의의 프랙탈을 얻는 기능을 완전히 분리하려면 high[] 및 low[] 배열과 한계값을 참조로 전달해서는 안 되며 함수로도 필요한 값을 얻어야 합니다.

코드를 최대한 MQL5에 가깝게 만들기 때문에 High[], Low[], iHigh() , iLow() 함수를 포기하고 자체 함수를 사용하여 필요한 가격을 얻어야 합니다. 동일한 표시기에서 다음과 같이 표시됩니다.

//+------------------------------------------------------------------+
//|                                             iFreeNumFractals.mq4 |
//|              Copyright 2016, Artem A. Trishkin, Skype artmedia70 |
//|                       https://login.mql5.com/ru/users/artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, Artem A. Trishkin, Skype artmedia70"
#property link        "https://login.mql5.com/ru/users/artmedia70"
#property version    "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots    2
//--- plot UpperFractal
#property indicator_label1   "UpperFractal"
#property indicator_type1   DRAW_ARROW
#property indicator_color1   clrRed
#property indicator_style1   STYLE_SOLID
#property indicator_width1   1
//--- plot LowerFractal
#property indicator_label2   "LowerFractal"
#property indicator_type2   DRAW_ARROW
#property indicator_color2   clrSteelBlue
#property indicator_style2   STYLE_SOLID
#property indicator_width2   1
//--- input parameters
input            int       LeftNum= 2 ;     // Количество баров слева
int leftNum;     // Количество баров слева
input            int       RightNum= 2 ;     // Количество баров справа
int rightNum;     // Количество баров справа
//--- indicator buffers
double          BufferUpperFractal[];
double          BufferLowerFractal[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
//--- indicator buffers mapping
   SetIndexBuffer ( 0 ,BufferUpperFractal);
   SetIndexBuffer ( 1 ,BufferLowerFractal);
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
   // PlotIndexSetInteger ( 0 , PLOT_ARROW , 217 );
   // PlotIndexSetInteger ( 1 , PLOT_ARROW , 218 );
   SetIndexArrow ( 0 , 217 );
   SetIndexArrow ( 1 , 218 );
//---
   leftNum=(LeftNum< 1 ? 1 :LeftNum);
   rightNum=(RightNum< 1 ? 1 :RightNum);
//---
   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[])
  {
//---
   if (rates_total<leftNum+rightNum) return ( 0 );
   int limit=rates_total-prev_calculated;
   if (limit> 0 ) {
       ArrayInitialize (BufferUpperFractal, 0.0 );
       ArrayInitialize (BufferUpperFractal, 0.0 );
      limit=rates_total-leftNum- 1 ;
      }
   //---
   for ( int i=limit; i>rightNum; i--) {
       if (GetFreeUpperFractal( Symbol (), PERIOD_CURRENT ,i,leftNum,rightNum)> 0 ) BufferUpperFractal[i]=high[i];
       if (GetFreeLowerFractal( Symbol (), PERIOD_CURRENT ,i,leftNum,rightNum)> 0 ) BufferLowerFractal[i]=low[i];
      }
//--- return value of prev_calculated for next call
   return (rates_total);
  }
//+----------------------------------------------------------------------------+
double GetFreeLowerFractal( const string symbol_name, ENUM_TIMEFRAMES timeframe, int shift, int left_dimension= 2 , int right_dimension= 2 ) {
   int bars= Bars (symbol_name,timeframe);
   if (left_dimension< 1 )  left_dimension= 1 ;
   if (right_dimension< 1 ) right_dimension= 1 ;
   if (shift-right_dimension< 1 || shift+left_dimension>bars- 1 ) return (- 1 );
   for ( int i=shift; i>shift-right_dimension; i--) if (GetPriceLow(symbol_name,timeframe,i)>GetPriceLow(symbol_name,timeframe,i- 1 )) return (- 1 );
   for ( int i=shift; i<shift+left_dimension; i++)   if (GetPriceLow(symbol_name,timeframe,i)>GetPriceLow(symbol_name,timeframe,i+ 1 )) return (- 1 );
   return (GetPriceLow(symbol_name,timeframe,shift));
}
//+----------------------------------------------------------------------------+
double GetFreeUpperFractal( const string symbol_name, ENUM_TIMEFRAMES timeframe, int shift, int left_dimension= 2 , int right_dimension= 2 ) {
   int bars= Bars (symbol_name,timeframe);
   if (left_dimension< 1 )  left_dimension= 1 ;
   if (right_dimension< 1 ) right_dimension= 1 ;
   if (shift-right_dimension< 1 || shift+left_dimension>bars- 1 ) return (- 1 );
   for ( int i=shift; i>=shift-right_dimension; i--) if (GetPriceHigh(symbol_name,timeframe,i)<GetPriceHigh(symbol_name,timeframe,i- 1 )) return (- 1 );
   for ( int i=shift; i<=shift+left_dimension; i++)   if (GetPriceHigh(symbol_name,timeframe,i)<GetPriceHigh(symbol_name,timeframe,i+ 1 )) return (- 1 );
   return (GetPriceHigh(symbol_name,timeframe,shift));
}
//+----------------------------------------------------------------------------+
double GetPriceHigh( const string symbol_name, ENUM_TIMEFRAMES timeframe, int shift){
   double array[ 1 ];
   if ( CopyHigh (symbol_name,timeframe,shift, 1 ,array)== 1 ) return (array[ 0 ]);
   return (- 1 );
}
//+----------------------------------------------------------------------------+
double GetPriceLow( const string symbol_name, ENUM_TIMEFRAMES timeframe, int shift){
   double array[ 1 ];
   if ( CopyLow (symbol_name,timeframe,shift, 1 ,array)== 1 ) return (array[ 0 ]);
   return (- 1 );
}
//+----------------------------------------------------------------------------+
사실, GetPriceHigh() 및 GetPriceLow() 함수에서 -1을 가져오는지 확인해야 합니다.
 
좋은 오후, 어드바이저가 20분마다 값을 확인하는 15분 시간 프레임을 사용하여 9-20, 9-40에 RSI 교차를 모니터링하고 수준이 교차, 20분 후에 가격 변동을 확인하십시오. 수정해야 할 사항은 다음과 같습니다.
if ( Hour ()== 9 && ( Minute () == 20 ) && (RSI> 70 ))
Price2== Bid ;
     {
       if ( Hour ()== 9 && ( Minute () == 40 ) && ( Bid <Price2))
  
         {
          ticket= OrderSend ( Symbol (), OP_SELL , Lts, Bid , SP, 0 , 0 , NULL , Magic, 0 , Blue);
           return ( 0 );
         }
     }

즉, RSI가 9-20에서 교차했다고 가정해 보겠습니다. 고문은 9-20시에 가격을 기억하고 9-40시에 9-20시에 가격과 관련하여 마지막 20분이 어떻게 마감되었는지 확인해야 합니다. 내리면 짧게 열립니다. 미리 감사합니다
 
strongflex :
좋은 오후, 어드바이저가 20분마다 값을 확인하는 15분 시간 프레임을 사용하여 9-20, 9-40에 RSI 교차를 모니터링하고 수준이 교차, 20분 후에 가격 변동을 확인하십시오. 수정해야 할 사항은 다음과 같습니다.
if ( Hour ()== 9 && ( Minute () == 20 ) && (RSI> 70 ))
Price2== Bid ;
     {
       if ( Hour ()== 9 && ( Minute () == 40 ) && ( Bid <Price2))
  
         {
          ticket= OrderSend ( Symbol (), OP_SELL , Lts, Bid , SP, 0 , 0 , NULL , Magic, 0 , Blue);
           return ( 0 );
         }
     }

즉, 9-20에서 RSI가 교차했다고 가정해 보겠습니다. 고문은 9-20시에 가격을 기억하고 9-40시에 9-20시에 가격과 관련하여 마지막 20분이 어떻게 마감되었는지 확인해야 합니다. 내리면 짧게 열립니다. 미리 감사합니다

:)

그리고 9시 22분에 어드바이저를 시작한다면?

시스템 또는 터미널 오류가 발생하면 어떻게 합니까? 가격이 기억나지 않을 것입니다.

즉, 이 점검 시간이 오면 20분 전의 내용을 찾아야 합니다. 분이 20의 배수보다 크거나 같은 시간이 되었습니다. 20분 전의 막대에서 RSI의 상태를 확인하십시오. 필요한 교차로가 있으면 계획에 따라 진행합니다 ...

사실, 정확한 교차 시간과 tf M15의 정확한 가격 을 결정할 수는 없지만 M1의 가격은 최소 15배 더 정확하게 볼 수 있습니다.

 
Artyom Trishkin :

:)

그리고 9시 22분에 어드바이저를 시작한다면?

시스템 또는 터미널 오류가 발생하면 어떻게 합니까? 가격이 기억나지 않을 것입니다.

즉, 이 점검 시간이 오면 20분 전의 내용을 찾아야 합니다. 분이 20의 배수보다 크거나 같은 시간이 되었습니다. 20분 전의 막대에서 RSI의 상태를 확인하십시오. 필요한 교차로가 있으면 계획에 따라 진행합니다 ...

사실, 정확한 교차 시간과 tf M15의 정확한 가격 을 결정할 수는 없지만 M1의 가격은 최소 15배 더 정확하게 볼 수 있습니다.

글쎄, 내가 이해하는 한 나는 그것을 마스터 할 수 없다))) 여러분, 누가 코드의이 부분을 작성할 수 있습니까? 나는 1000 루블을 지불 할 것입니다
 
strongflex :
글쎄, 내가 이해하는 한 나는 그것을 마스터 할 수 없다))) 여러분, 누가 코드의이 부분을 작성할 수 있습니까? 나는 1000 루블을 지불 할 것입니다
double rci20 = iRSI ( NULL , PERIOD_M1 , 14 , PRICE_CLOSE , 20 ); //RCI 20 минут назад.
   Comment ( "RSI = " ,rci20);

그리고 천은 어디에 있습니까?

(농담)

 
Alekseu Fedotov :
double rci20 = iRSI ( NULL , PERIOD_M1 , 14 , PRICE_CLOSE , 20 ); //RCI 20 минут назад.
   Comment ( "RSI = " ,rci20);

그리고 천은 어디에 있습니까?

(농담)

RSI는 15분이 필요합니다. 어드바이저는 시장 개장(9-00, 9-20, 9-40 등)부터 20분마다 확인해야 합니다. 10-20에 레벨 70의 상향 교차가 있었다고 가정해 보겠습니다. 가격과 10-40에서 그들은 가격이 10-20에서 그가 공매도보다 낮은지 확인할 것입니다.
사유: