흥미로운 거래 아이디어가 있습니다. 코드(mql4)에서 오류를 찾는 데 도움을 주세요. - 페이지 15

 
Alexander Zakharov :

미확인 변수 충돌 오류, 해결 방법을 알려주세요. 저는 MQL4에 익숙하지 않습니다.


// 로트 계산

if(MarketInfo(Symbol(),MODE_LOTSTEP)==0.01) int 숫자=2;

if(MarketInfo(Symbol(),MODE_LOTSTEP)==0.10) int digit=1;

if(MarketInfo(Symbol(),MODE_LOTSTEP)==1.00) int digit=0;

더블 _lot =NormalizeDouble(lot* MathPow(koef,totalO(-1,key)), 숫자 ) ; 여기서 그는 이전에 이 변수의 입력을 보지 못했습니다(

이중 최소 = MarketInfo(Symbol(),MODE_MINLOT);

if(_lot<min)_lot=min;

다음은 로트 정규화 기능입니다.

 double volume_n( string symbol, double lot)
  {
   double MinLot= SymbolInfoDouble (symbol, SYMBOL_VOLUME_MIN );
   double MaxLot= SymbolInfoDouble (symbol, SYMBOL_VOLUME_MAX );
   double LotStep= SymbolInfoDouble (symbol, SYMBOL_VOLUME_STEP );

   if (lot<MinLot)lot=MinLot;
   if (lot>MaxLot)lot=MaxLot;

   if (LotStep== 0.001 ) return ( NormalizeDouble (lot, 3 ));
   if (LotStep== 0.01 )   return ( NormalizeDouble (lot, 2 ));
   if (LotStep== 0.1 )   return ( NormalizeDouble (lot, 1 ));

   return ( NormalizeDouble (lot, 0 ));
  }

애플리케이션

 double _lot=volume_n( _Symbol ,lot* MathPow (koef,totalO(- 1 ,key))
 
Sergey Gritsay :

다음은 로트 정규화 기능입니다.

신청 감사합니다

 
Sergey Gritsay :
바 모드를 수정했습니다. MT5 버전에 THV4 추세 표시기 추가
나는이 테스터를 모든면에서 뒤틀었습니다. 병합됩니다 ... 구매에 대해 하나의 신호를 남겨두면 ... 다소 걸리고 트롤이 너무 오래 작동합니다 ... 뒤에 0이 남습니다 ...
 
Сергей Криушин :
나는이 테스터를 모든면에서 뒤틀었습니다. 병합됩니다 ... 구매에 대해 하나의 신호를 남겨두면 ... 다소 걸리고 트롤이 너무 오래 작동합니다 ... 뒤에 0이 남습니다 ...
d 오랫동안 작동한다는 의미에서 어떤 0을 남기나요?
 
Sergey Gritsay :

다음은 로트 정규화 기능입니다.

애플리케이션

더 우아한 솔루션이 있습니다.

 double volume_step= SymbolInfoDouble ( _Symbol , SYMBOL_VOLUME_STEP );
int volume_digits=( int )( MathLog ( 1.0 /volume_step)/ MathLog ( 10.0 ));
 
Sergey Gritsay :
d 오랫동안 작동한다는 의미에서 어떤 0을 남기나요?

이익 = 0.0

 2016.03 . 14 12 : 35 : 31      64321035         USDCHF  sell     in        0.05      0.98764 78568040          0.00      0.00      0.00      63 366.94        
2016.03 . 14 13 : 00 : 34      64323324         GBPUSD  buy     in        0.01      1.43567 78570253          0.00      0.00      0.00      63 366.94        exp_cci
2016.03 . 14 13 : 00 : 55      64323378         USDJPY  buy     in        0.01      113.688 78570307          0.00      0.00      0.00      63 366.94        exp_cci
2016.03 . 14 13 : 00 : 56      64323380         NZDUSD  sell     in        0.01      0.67134 78570308          0.00      0.00      0.00      63 366.94        exp_cci
2016.03 . 14 13 : 01 : 14      64323403         CHFJPY  buy     in        0.01      115.162 78570331          0.00      0.00      0.00      63 366.94        exp_cci
2016.03 . 14 13 : 01 : 15      64323406         EURGBP  buy     in        0.01      0.77432 78570334          0.00      0.00      0.00      63 366.94        exp_cci
2016.03 . 14 13 : 01 : 16      64323408         EURJPY  buy     in        0.01      126.363 78570336          0.00      0.00      0.00      63 366.94        exp_cci
2016.03 . 14 13 : 01 : 17      64323409         EURUSD  buy     in        0.01      1.11148 78570337          0.00      0.00      0.00      63 366.94        exp_cci
2016.03 . 14 13 : 01 : 18      64323410         GBPJPY  buy     in        0.01      163.208 78570338          0.00      0.00      0.00      63 366.94        exp_cci
2016.03 . 14 13 : 01 : 18      64323412         EURJPY  sell     out      0.01      126.356 78570340          0.00      0.00     - 0.06    63 366.88        
2016.03 . 14 13 : 01 : 21      64323417         USDSEK  sell     in        0.01      8.35246 78570345          0.00      0.00      0.00      63 366.88        exp_cci
2016.03 . 14 13 : 01 : 21      64323418         USDZAR  sell     in        0.01      15.35749          78570346          0.00      0.00      0.00      63 366.88        exp_cci
2016.03 . 14 13 : 07 : 25      64323874         GBPUSD  sell     out      0.01      1.43567 78570786          0.00      0.00      0.00      63 366.88        [sl 1.43567 ]
2016.03 . 14 13 : 09 : 06      64323946         USDCHF  buy     out      0.05      0.98764 78570855          0.00      0.00      0.00      63 366.88        [sl 0.98764 ]
2016.03 . 14 13 : 23 : 54      64324855         USDCHF  sell     in        0.01      0.98745 78571736          0.00      0.00      0.00      63 366.88        exp_cci
2016.03 . 14 14 : 00 : 00      64328785         AUDUSD  buy     in        0.01      0.75339 78575571          0.00      0.00      0.00      63 366.88        exp_cci
2016.03 . 14 14 : 00 : 05      64328795         GBPUSD  buy     in        0.01      1.43463 78575585          0.00      0.00      0.00      63 366.88        exp_cci
2016.03 . 14 14 : 00 : 05      64328797         AUDCAD  buy     in        0.01      0.99889 78575587          0.00      0.00      0.00      63 366.88        exp_cci
2016.03 . 14 14 : 00 : 07      64328802         EURJPY  buy     in        0.01      126.311 78575592          0.00      0.00      0.00      63 366.88        exp_cci
2016.03 . 14 14 : 00 : 07      64328805         USDMXN  sell     in        0.01      17.76137          78575595          0.00      0.00      0.00      63 366.88        exp_cci
2016.03 . 14 14 : 00 : 08      64328807         USDZAR  buy     out      0.01      15.42380          78575597          0.00      0.00     - 4.30    63 362.58        
2016.03 . 14 14 : 00 : 08      64328808         EURJPY  sell     out      0.01      126.301 78575598          0.00      0.00     - 0.09    63 362.49        
2016.03 . 14 14 : 00 : 11      64328812         USDHKD  sell     in        0.09      7.75715 78575601          0.00      0.00      0.00      63 362.49        exp_cci
2016.03 . 14 14 : 00 : 12      64328813         USDZAR  buy     in        0.01      15.42351          78575602          0.00      0.00      0.00      63 362.49        exp_cci
2016.03 . 14 14 : 04 : 12      64329157         GBPUSD  sell     out      0.01      1.43463 78575943          0.00      0.00      0.00      63 362.49        [sl 1.43463 ]
2016.03 . 14 14 : 04 : 50      64329180         GBPUSD  buy     in        0.01      1.43462 78575964          0.00      0.00      0.00      63 362.49        exp_cci
2016.03 . 14 14 : 05 : 43      64329266         EURJPY  buy     in        0.01      126.360 78576048          0.00      0.00      0.00      63 362.49        exp_cci
2016.03 . 14 14 : 15 : 01      64330159         USDCAD  buy     in        0.01      1.32450 78576911          0.00      0.00      0.00      63 362.49        exp_cci
2016.03 . 14 14 : 15 : 02      64330160         EURJPY  sell     out      0.01      126.429 78576913          0.00      0.00      0.61      63 363.10        
2016.03 . 14 14 : 15 : 04      64330169         USDSEK  buy     out      0.01      8.35081 78576922          0.00      0.00      0.20      63 363.30        
2016.03 . 14 14 : 15 : 26      64330196         USDMXN  buy     out      0.01      17.76283          78576946          0.00      0.00     - 0.08    63 363.22        
2016.03 . 14 14 : 30 : 00      64331460         AUDCAD  sell     out      0.01      0.99792 78578213          0.00      0.00     - 0.73    63 362.49        
2016.03 . 14 14 : 30 : 02      64331464         GBPCAD  sell     in        0.01      1.89854 78578217          0.00      0.00      0.00      63 362.49        exp_cci
2016.03 . 14 14 : 30 : 04      64331472         AUDUSD  sell     out      0.01      0.75491 78578225          0.00      0.00      1.52      63 364.01        
        
 
Сергей Криушин :

이익 = 0.0

입력 매개변수를 잘못 설정한 것일 수도 있습니다. 모든 것이 정상입니다.

 
Sergey Gritsay :

입력 매개변수를 잘못 설정한 것일 수도 있습니다. 모든 것이 정상입니다.

변경 사항은 다음과 같습니다.

  
input ENUM_TYPE_BALANS Type_Balanse=Balance;
input double Risk= 0.5 ;
input double _Lot= 0.04 ;
input double Loading_deposit= 20.0 ;
input double Ksl= 8.0 ;
input double Ktp= 2.0 ;
input int TotalLossSeries= 16 ;
input bool TrailingStop= true ;
input bool CloseSignal= true ;
input ENUM_TYPE_INDICATOR IndicatorTrend=CCI;
input int period_CCI_S= 90 ;
input int period_CCI_F= 13 ;
input int Period_ATR= 35 ;
input ENUM_TIMEFRAMES TF_ATR= PERIOD_CURRENT ;
input bool signal_01= true ;
input bool signal_02= true ;
input bool signal_03= true ;
input bool signal_04= true ;
input bool signal_05= true ;
input string CommentOrder= "exp_cci" ;
input color ColorText= clrBlack ;
input string symbol_tester= "EURUSD,AUDUSD,USDJPY,USDCAD" ;

//Уменьшил уровень до 90 - чтоб надежней срабатывал 
if (trend[index]== ORDER_TYPE_BUY )
     {
       if (signal_01 && cci_f[ 1 ]<- 90.0 ) return ( ORDER_TYPE_BUY );
       if (signal_02 && cci_f[ 1 ]<- 90.0 && cci_f[ 0 ]>- 90.0 ) return ( ORDER_TYPE_BUY );
       if (signal_03 && cci_f[ 1 ]>- 90.0 && cci_f[ 0 ]<- 90.0 ) return ( ORDER_TYPE_BUY );
       if (signal_04 && cci_f[ 1 ]> 90.0 && cci_f[ 0 ]< 90.0 ) return ( ORDER_TYPE_BUY );
       if (signal_05 && cci_f[ 1 ]> 90.0 ) return ( ORDER_TYPE_BUY );
     }
   if (trend[index]== ORDER_TYPE_SELL )
     {
       if (signal_01 && cci_f[ 1 ]> 90 ) return ( ORDER_TYPE_SELL );
       if (signal_02 && cci_f[ 1 ]> 90 && cci_f[ 0 ]< 90 ) return ( ORDER_TYPE_SELL );
       if (signal_03 && cci_f[ 1 ]< 90 && cci_f[ 0 ]> 90 ) return ( ORDER_TYPE_SELL );
       if (signal_04 && cci_f[ 1 ]<- 90 && cci_f[ 0 ]>- 90 ) return ( ORDER_TYPE_SELL );
       if (signal_05 && cci_f[ 1 ]<- 90 ) return ( ORDER_TYPE_SELL );
     }
 
Сергей Криушин :

변경 사항은 다음과 같습니다.

이러한 설정으로

 input double Ksl= 8.0 ;
input double Ktp= 2.0 ;

후행은 특별한 의미가 없으므로 완전히 비활성화할 수 있습니다.

 
MT5 버전의 버그 수정
파일: