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

 
Nerd Trader :
isCrossing()2 를 반환하지 않는 이유는 ??? IsCrossing() 자체에는 두 번째 if 에 대한 항목이 있지만 OnTick() 에는 isCrossing() == 2 일 때 if 항목이 없습니다. 도대체 무슨...

두 조건 모두 적합하므로 첫 번째 결과를 얻습니다.

 
MakarFX :

두 조건 모두 적합하므로 첫 번째 결과를 얻습니다.

입찰가 == ma일 때만 적합합니다. <= 를 <로 변경했지만(>=의 경우도 마찬가지) 변경된 사항은 없습니다.
 
Nerd Trader :
isCrossing()2 를 반환하지 않는 이유는 ??? IsCrossing() 자체에는 두 번째 if 에 대한 항목이 있지만 OnTick() 에는 isCrossing() == 2 일 때 if 항목이 없습니다. 도대체 무슨...

왠지 1도 돌아오지 않는 것 같아요.

이 조건

 if (g_barTime < iTime ( NULL ,g_timeFrame, 0 )// и дальше

새로운 바를 여는 것에 대해 이야기합니다. 막대의 첫 번째 눈금에서 열기 == 높음 == 낮음 == 닫기 및 == 입찰가— 따라서 조건

 && high > ma && Bid <= ma)

또는

 && low < ma && Bid >= ma)
할 수 없다...

오늘은 if(i != i) 조건에 대한 질문이 있었는데 이 조건은 거의 같습니다.

 
OnTick() 함수는 현재 편집기에 있는 것입니다.
 void OnTick ()
  {
/*     if(isCrossing() == 1){          
      Print("enter to '1. if (isCrossing)'");
        if(shouldBars(1))         
          Print("angulation is ", shouldAngulation(1));            
    } */

     if (isCrossing() == 2 ){
       Print ( "enter to '2. if (isCrossing)'" );
       if (shouldBars( 2 ))
         Print ( "angulation is " , shouldAngulation( 2 ));
         //if(shouldAngulation(2))
           //OpenSell();
    }

   
  }
첫 번째 블록을 주석 처리하면 두 번째 블록이 실행됩니다. 오류가 어디에 있는지 이해하지 못합니다.

추신
f- ii에서 isCrossing() 이 모든 것을 그대로 두었음에도 불구하고.
 
Alexey Viktorov :

왠지 1도 돌아오지 않는 것 같아요.

이 조건

새로운 바를 여는 것에 대해 이야기합니다. 막대의 첫 번째 눈금에서 열기 == 높음 == 낮음 == 닫기 및 == 입찰가— 따라서 조건

또는

할 수 없다...

오늘은 if(i != i) 조건에 대한 질문이 있었는데 이 조건은 거의 같습니다.

"1"이 반환되고 MetaEditor에서 코드를 디버깅했습니다.

또한 모든 것이 모든 것과 같더라도 첫 번째 틱에서만.

 
Nerd Trader :

"1"이 반환되고 MetaEditor에서 코드를 디버깅했습니다.

또한 모든 것이 모든 것과 같더라도 첫 번째 틱에서만.

네, 제가 잘못했습니다. 모든 조건이 충족된 후에만 새 막대 가 나타납니다.

높은 곳과 낮은 곳을 개방으로 교체해 보십시오. 전략에 큰 영향을 미치지 않을 수 있습니다 ...

 
Nerd Trader :

"1"이 반환되고 MetaEditor에서 코드를 디버깅했습니다.

또한 모든 것이 모든 것과 같더라도 첫 번째 틱에서만.

이것이 작동하는 방식입니다

 //--- input parameters
input int                   g_maPeriod  = 14 ;
input int                   g_maShift   = 1 ;
input ENUM_APPLIED_PRICE    g_maPrice   = PRICE_CLOSE ;   //Applied price
input ENUM_MA_METHOD        g_maMethod  = MODE_SMA ;     //Method Ma
input ENUM_TIMEFRAMES       g_timeFrame = PERIOD_CURRENT ;   //Timeframe for calculate
datetime g_barTime= 0 ;
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick ()
  {
//---
   if (g_barTime != iTime ( NULL ,g_timeFrame, 0 ))
     {
       if (isCrossing()== 1 )
        {
         Print ( "enter to '1. if (isCrossing)'" ); g_barTime = iTime ( NULL ,g_timeFrame, 0 );
        }
       if (isCrossing()== 2 )
        {
         Print ( "enter to '2. if (isCrossing)'" ); g_barTime = iTime ( NULL ,g_timeFrame, 0 );
        }
     }
  }
//+------------------------------------------------------------------+
int isCrossing()
  {  
   int res= 0 ;
   double low = iLow ( Symbol (), g_timeFrame, 1 );
   double high = iHigh ( Symbol (), g_timeFrame, 1 );
   double ma = iMA ( _Symbol , g_timeFrame, g_maPeriod, g_maShift, g_maMethod, g_maPrice, 0 );

   if (high > ma && Bid <= ma) res= 1 ;
  
   if (low < ma && Bid >= ma) res= 2 ;
   return (res);
  }
//+------------------------------------------------------------------+
2021.08 . 25 09 : 24 : 56.629 2021.08 . 20 23 : 50 : 00   Nerd Trader EURUSD,M5: enter to ' 1 . if (isCrossing)'
2021.08 . 25 09 : 24 : 56.624 2021.08 . 20 23 : 45 : 00   Nerd Trader EURUSD,M5: enter to ' 2 . if (isCrossing)'
2021.08 . 25 09 : 24 : 56.592 2021.08 . 20 21 : 35 : 00   Nerd Trader EURUSD,M5: enter to ' 2 . if (isCrossing)'
2021.08 . 25 09 : 24 : 56.582 2021.08 . 20 21 : 05 : 00   Nerd Trader EURUSD,M5: enter to ' 1 . if (isCrossing)'
2021.08 . 25 09 : 24 : 56.566 2021.08 . 20 20 : 20 : 00   Nerd Trader EURUSD,M5: enter to ' 1 . if (isCrossing)'
2021.08 . 25 09 : 24 : 56.554 2021.08 . 20 18 : 50 : 00   Nerd Trader EURUSD,M5: enter to ' 2 . if (isCrossing)'
2021.08 . 25 09 : 24 : 56.553 2021.08 . 20 18 : 45 : 00   Nerd Trader EURUSD,M5: enter to ' 2 . if (isCrossing)'
2021.08 . 25 09 : 24 : 56.553 2021.08 . 20 18 : 40 : 00   Nerd Trader EURUSD,M5: enter to ' 1 . if (isCrossing)'
 
MakarFX :

이것이 작동하는 방식입니다


이 작업을 수행하고 모든 것이 작동했으며 한 틱에 대해 함수가 두 번 호출되기 때문에 isCrossing()의 메시지만 복제됩니다.

 void OnTick ()
  {
   if (BarTime != iTime ( NULL , 0 , 0 )){

     if (isCrossing == 1 ){
       ...
     }

     if (isCrossing == 2 ){
       ...
     }
     BarTime = iTime ( NULL , 0 , 0 ); 
  }

int isCrossing()
  {  
    ...

     if (high > ma && Bid <= ma){
       Print ( "Crossing down" );
       return 1 ;
    } 
  
     if (low < ma && Bid >= ma){
       Print ( "Crossing up" );
       return 2 ;
    }
   return 0 ;
  }


일반적으로 원래 그대로 두었지만 이제 모든 것이 isCrossing()에서 변수로 반환됩니다. 아무 것도 복제되지 않으며 모든 것이 작동합니다. 모두에게 감사합니다 :)

 void OnTick ()
  {
     int iCrossing = isCrossing();

     if (iCrossing == 1 ){
       ...
    }

     if (iCrossing == 2 ){
       ...
    }   
  }
 
MakarFX :
 2021.08 . 25 09 : 24 : 56.629 2021.08 . 20 23 : 50 : 00   Nerd Trader EURUSD,M5: enter to ' 1 . if (isCrossing)'
2021.08 . 25 09 : 24 : 56.624 2021.08 . 20 23 : 45 : 00   Nerd Trader EURUSD,M5: enter to ' 2 . if (isCrossing)'
2021.08 . 25 09 : 24 : 56.592 2021.08 . 20 21 : 35 : 00   Nerd Trader EURUSD,M5: enter to ' 2 . if (isCrossing)'
2021.08 . 25 09 : 24 : 56.582 2021.08 . 20 21 : 05 : 00   Nerd Trader EURUSD,M5: enter to ' 1 . if (isCrossing)'
2021.08 . 25 09 : 24 : 56.566 2021.08 . 20 20 : 20 : 00   Nerd Trader EURUSD,M5: enter to ' 1 . if (isCrossing)'
2021.08 . 25 09 : 24 : 56.554 2021.08 . 20 18 : 50 : 00   Nerd Trader EURUSD,M5: enter to ' 2 . if (isCrossing)'
2021.08 . 25 09 : 24 : 56.553 2021.08 . 20 18 : 45 : 00   Nerd Trader EURUSD,M5: enter to ' 2 . if (isCrossing)'
2021.08 . 25 09 : 24 : 56.553 2021.08 . 20 18 : 40 : 00   Nerd Trader EURUSD,M5: enter to ' 1 . if (isCrossing)'
이제 로그를 추가했습니다. 중복 게시물도 있습니다 :)
 

기능의 차이점이 무엇인지 설명해 주시겠습니까?

(int j = OrdersHistoryTotal()-1; j >= 0; j--)

{

if ( OrderSelect (j, SELECT_BY_POS,MODE_HISTORY))

그리고

int i=OrdersHistoryTotal();

for(int pos=0; pos<i; pos++)

{

if(주문 선택(pos, SELECT_BY_POS, MODE_HISTORY))