약간의 오류를 발견하는 데 도움이 필요합니다. - 페이지 4

 
그렇다면 나는 첫 번째 코드에서도 옳습니다. 첫 번째 for 루프 직후에 OrderSelect()를 호출 합니다..... 문제는 이제 후행 정지 손실이 제대로 작동하지 않고 여전히 문제가 어디에 있는지 단서.
 
juniorlcq : 카운트 다운 루프를 사용하지만 x-- . 왜 --x 를 제안하는지 이해가 되지 않습니다.
  1. x++는 값을 읽고, 사본을 저장하고 , 값을 증가시키고, x에 새 값을 저장하고, 후속 사용을 위해 사본 을 검색합니다.
  2. ++x는 값을 읽고, 값을 증가시키고, x에 새 값을 저장합니다.
  3. 정수의 경우 거의 차이가 없습니다. 일부 플랫폼에서 후자는 몇 배 더 빠르게 만드는 단일 명령입니다.
  4. 반복자와 같은 클래스의 경우 추가 생성자 및 소멸자 호출이 있으므로 몇 배 더 빨라집니다.
    접두사 연산자++
    후위 연산자++
    RaRev* RaRev:: operator ++( void ){         // prefix
       ++mPos;
       return GetPointer( this ); // Allow (++It).Get()
    }
    
    RaRev RaRev:: operator ++( int ){               // postfix
       RaRev  orig( this ); // Make a copy to return.
       ++ this ;            // Increment myself.
       return orig;       // Return the original position.
    }
    
    대부분의 STL 구현에서 "iterator last=end; --end;"를 자주 보게 될 것입니다. "반복자 마지막 = 끝--"보다는

 

가격이 OrderOpenprice()에서 600포인트 올라간다고 가정해 봅시다. = StartTraillingStop (200) + 8(xai)*50

코드는 다음과 같습니다.

   if ( xai >= 8 ) 
    {
    if ( ( ( OrderClosePrice() - OrderOpenPrice() ) / Figure ) >= ( StartTrailingStop + ( CummulativeValue * xai ) ) )
        {
        if ( OrderStopLoss() == ( OrderOpenPrice() + ( ( TrailingStop + ( CummulativeValue * ( xai - 1 ) ) ) * Figure ) ) )
           {
            Result = OrderModify ( OrderTicket() , OrderOpenPrice() , ( OrderOpenPrice() + ( ( TrailingStop + ( CummulativeValue * xai ) ) * Figure ) ) , OrderTakeProfit() , 0 , Color ) ;
       }
    }

그러나 코드는 0에서 8까지 모든 xai를 수행합니다. 코드가 xai = 4에 있다고 가정합니다. 이 조건이 사실입니까?

 if ( ( ( OrderClosePrice() - OrderOpenPrice() ) / Figure ) >= ( StartTrailingStop + ( CummulativeValue * xai ) ) )

예, SL은 StartTraillinStop(200) + 4(xai)*50(이전에서 내려감)에 설정됩니다.

xai 5, SL은 StartTraillinStop (200) + 5(xai)*50에서 설정됩니다.

등등, 그래서 SL이 설정되면 중단을 둘 수 없습니다.

 

Juniorlcq 코드를 다시 포맷했으므로 훨씬 더 읽기 쉽습니다. 게시하기 위해 작게 만들기 위해 조금 더 형식을 변경했으며 가능한 문제를 강조 표시했습니다. 코드에서 일부 트레일을 실행하지 못하게 하는 "더블 == 계산된 더블" 문제가 있을 수 있다고 생각합니다. can price != price 에 대한 스레드를 읽은 적이 있습니까?

2번과 4번은 계산이 더 복잡하기 때문에 가장 의심스럽습니다.

계산 후에 Print() 문을 넣어 실제로 ==인지 여부를 확인합니다.

부동 소수점 오류로 알려진 오류는 ==이어야 하는 것처럼 보이더라도 !=로 만들 수 있습니다.

==는 실제로 정수와 함께 사용하는 것이 100% 안전하므로 테스트로 ==를 <= 또는 >=로 변경할 수 있습니다.

   void ProcessTrailingStop()
 {
   bool Result;
   for ( int x=( OrdersTotal ()- 1 ); x>= 0 ; x--)
  { if ( OrderSelect (x,SELECT_BY_POS,MODE_TRADES)==True)
   {PointsDetection();
     if (OrderType()==OP_BUY)
    { for ( int xai= 0 ; xai<NumberOfTrail; xai++)
     { if (xai== 0 )
      { if (((OrderClosePrice()-OrderOpenPrice())/Figure)>=StartTrailingStop)
       { if (( OrderStopLoss()== 0 ) || (OrderStopLoss()<(OrderOpenPrice()+(TrailingStop*Figure))))
        {Result=OrderModify(OrderTicket(),OrderOpenPrice(),(OrderOpenPrice()+(TrailingStop*Figure)),OrderTakeProfit(), 0 ,Color);
      }}}
       if (xai== 1 )
      { if (((OrderClosePrice()-OrderOpenPrice())/Figure)>=(StartTrailingStop+CummulativeValue))
       { if (OrderStopLoss()==(OrderOpenPrice()+(TrailingStop*Figure)))
        {Result=OrderModify(OrderTicket(),OrderOpenPrice(),(OrderOpenPrice()+((TrailingStop+CummulativeValue)*Figure)),OrderTakeProfit(), 0 ,Color);
      }}}
       if (xai>= 2 )
      { if (((OrderClosePrice()-OrderOpenPrice())/Figure)>=(StartTrailingStop+(CummulativeValue*xai)))
       { if (OrderStopLoss()==(OrderOpenPrice()+(( TrailingStop+(CummulativeValue *(xai- 1 )))*Figure)))
        {Result=OrderModify(OrderTicket(),OrderOpenPrice(),(OrderOpenPrice()+(( TrailingStop+(CummulativeValue*xai))*Figure)),OrderTakeProfit(), 0 ,Color);
    }}}}} else
    { if (OrderType()==OP_SELL)
     { for ( int xaii= 0 ; xaii<NumberOfTrail; xaii++)
      { if (xaii== 0 )
       { if (((OrderOpenPrice()-OrderClosePrice())/Figure)>=StartTrailingStop)
        { if (( OrderStopLoss()== 0 ) || (OrderStopLoss()>(OrderOpenPrice() -(TrailingStop*Figure))))
         {Result=OrderModify(OrderTicket(),OrderOpenPrice(),(OrderOpenPrice() -(TrailingStop*Figure)),OrderTakeProfit(), 0 ,Color);
       }}}
       if (xaii== 1 )
       { if (((OrderOpenPrice()-OrderClosePrice())/Figure)>=(StartTrailingStop+CummulativeValue))
        { if (OrderStopLoss()==(OrderOpenPrice() -(TrailingStop*Figure)))
         {Result=OrderModify(OrderTicket(),OrderOpenPrice(),(OrderOpenPrice() -(( TrailingStop+CummulativeValue)*Figure)),OrderTakeProfit(), 0 ,Color);
       }}}
       if (xaii>= 2 )
       { if (((OrderOpenPrice()-OrderClosePrice())/Figure)>=(StartTrailingStop+(CummulativeValue*xaii)))
        { if (OrderStopLoss()==(OrderOpenPrice() -(( TrailingStop+(CummulativeValue *(xaii- 1 )))*Figure)))
         {Result=OrderModify(OrderTicket(),OrderOpenPrice(),(OrderOpenPrice() -(( TrailingStop+(CummulativeValue*xaii))*Figure)),OrderTakeProfit(), 0 ,Color);
 }}}}}}}}}


또한 참고 사항으로: OrderSelect() 루프의 시작 부분에서 OrderOpenPrice(), OrderStopLoss(), OrderClosePrice()를 한 번 호출하고 해당 값을 나머지 전체에서 사용할 로컬 변수에 할당하면 코드가 훨씬 더 효율적입니다. 코드의. 로컬 변수는 함수 호출보다 훨씬 빠르게 액세스할 수 있으므로 동일한 결과에 대해 반복적인 함수 호출을 피해야 합니다... 일반적으로 코드에 분홍색 글씨가 많을수록 EA의 성능이 느려집니다.

 

나는 그것을 작동시킬 수 없다는 것을 이해합니다. 이것은 주문 구매와 함께 작동할 수 있습니다. SL은 설명된 대로 아래로 내려가고 있습니다.

   extern double CummulativeValue = 50.0 ;
   extern int      NumberOfTrail = 100 ;



   void ProcessTrailingStop()
   {
       double Figure = Point ;
     color Color = Yellow;
  
     bool Result ;
         for ( int x =  OrdersTotal (); x >= 0 ; x-- )
         {
         if ( OrderSelect ( x , SELECT_BY_POS , MODE_TRADES ) == false) continue;
        if ( OrderType() == OP_BUY )
           {
                 for ( int xai = 0 ; xai < NumberOfTrail ; xai++ )
                     {
                         if ( xai == 0 )
                        {
                           if ( ( ( OrderClosePrice() - OrderOpenPrice() ) / Figure ) >= StartTrailingStop )
                           {
                               if ( OrderStopLoss() == 0 ) 
                              {
                               Result = OrderModify ( OrderTicket() , OrderOpenPrice() , ( OrderOpenPrice() + ( TrailingStop * Figure ) ) , OrderTakeProfit() , 0 , Color ) ;
                          } } }                        
                  
                         if ( xai == 1 )
                           {
                           if ( ( ( OrderClosePrice() - OrderOpenPrice() ) / Figure ) >= ( StartTrailingStop + CummulativeValue ) )
                           {
                           Result = OrderModify ( OrderTicket() , OrderOpenPrice() , ( OrderOpenPrice() + ( ( TrailingStop + CummulativeValue ) * Figure ) ) , OrderTakeProfit() , 0 , Color ) ;
                          } }                         
                        
                         if ( xai >= 2 )
                           {
                          if ( ( ( OrderClosePrice() - OrderOpenPrice() ) / Figure ) >= ( StartTrailingStop + ( CummulativeValue * xai ) ) )
                           {
                           Result = OrderModify ( OrderTicket() , OrderOpenPrice() , ( OrderOpenPrice() + ( ( TrailingStop + ( CummulativeValue * xai ) ) * Figure ) ) , OrderTakeProfit() , 0 , Color ) ;
                        } }                         
                     }
                  }
                  
       }}           
 
WHRoeder :
  1. x++는 값을 읽고, 사본을 저장하고 , 값을 증가시키고, x에 새 값을 저장하고, 후속 사용을 위해 사본 을 검색합니다.
  2. ++x는 값을 읽고, 값을 증가시키고, x에 새 값을 저장합니다.
  3. 정수의 경우 거의 차이가 없습니다. 일부 플랫폼에서 후자는 몇 배 더 빠르게 만드는 단일 명령입니다.
  4. 반복자와 같은 클래스의 경우 추가 생성자 및 소멸자 호출이 있으므로 몇 배 더 빨라집니다.
    접두사 연산자++
    후위 연산자++
    대부분의 STL 구현에서 "iterator last=end; --end;"를 자주 보게 될 것입니다. "반복자 마지막 = 끝--"보다는


으으으으으으으으으으으으으으으으으으으으으으으 WHRoeder님 감사합니다 :) .

그래서 그것은 ,

OrdersTotal() == 3 , for 루프 for ( int x = ( OrdersTotal() - 1 ) ; x >= 0 ; x-- ) , x 는 첫 번째 값을 2 로 저장합니다. OrdersTotal()을 다시 거치지 않고 for 루프를 2부터 계속 진행합니까?

 
SDC :

Juniorlcq 당신의 코드는 당신이 그것을 다시 포맷했기 때문에 훨씬 더 읽기 쉽습니다. 게시하기 위해 더 작게 만들기 위해 조금 더 형식을 변경했으며 가능한 문제를 강조 표시했습니다. 코드에서 일부 트레일을 실행하지 못하게 하는 "더블 == 계산된 더블" 문제가 있을 수 있다고 생각합니다. can price != price 에 대한 스레드를 읽은 적이 있습니까?

저는 2번과 4번이 계산이 더 복잡하기 때문에 가장 의심스럽습니다.

계산 후에 Print() 문을 넣어 실제로 ==인지 여부를 확인합니다.

부동 소수점 오류로 알려진 오류는 ==이어야 하는 것처럼 보일 때에도 !=로 만들 수 있습니다.

==는 실제로 정수와 함께 사용하는 것이 100% 안전하므로 테스트로 ==를 <= 또는 >=로 변경할 수 있습니다.



아니요, 나는 전에 그 스레드를 읽어본 적이 없습니다. 그냥 했다.

당신이 제안한 것은 논리적으로 들립니다. 다시 생각해보면, 가격 속성에 대해 MT4에 선을 그리면 실제로는 5자리 가격이 표시되지 않고 때로는 그 이상을 표시하기도 합니다.

그러나 여기에 이전 계정 중 하나에 대한 내 부동 거래 중 하나가 있습니다. 간단한 인쇄 코딩으로 이중이 무엇인지 확인하기 위해 인쇄했습니다. 이상한 MQL4 추측 @.@?

나는 여전히 double == double 부분을 수정하는 방법을 생각하고 있습니다 .....

SDC :


또한 참고 사항으로: OrderSelect() 루프의 시작 부분에서 OrderOpenPrice(), OrderStopLoss(), OrderClosePrice()를 한 번 호출하고 해당 값을 나머지 전체에서 사용할 로컬 변수에 할당하면 코드가 훨씬 더 효율적입니다. 코드의. 로컬 변수는 함수 호출보다 훨씬 빠르게 액세스할 수 있으므로 동일한 결과에 대해 반복적인 함수 호출을 피해야 합니다... 일반적으로 코드에 분홍색 글씨가 많을수록 EA의 성능이 느려집니다.

Ohhh 속도 실행에 큰 차이가 있을 줄은 몰랐습니다. 가이드 SDC에 감사드립니다. 트레일 정류장이 작동하기 시작한 후 가이드에 따라 수정됩니다.

 

마지막 코드 블록을 이 디버그 버전으로 교체해 보십시오. 내가 컴파일하지 않은 내 코드를 확인하십시오 .

       if (xaii>= 2 )
       { if (((OrderOpenPrice()-OrderClosePrice())/Figure)>=(StartTrailingStop+(CummulativeValue*xaii)))
        { Print ( "debug2.1: first condition true" );
         if (OrderStopLoss()==(OrderOpenPrice() -(( TrailingStop+(CummulativeValue *(xaii- 1 )))*Figure)))
         { Print ( "debug2.2: second condition true" );
          Result=OrderModify(OrderTicket(),OrderOpenPrice(),(OrderOpenPrice() -(( TrailingStop+(CummulativeValue*xaii))*Figure)),OrderTakeProfit(), 0 ,Color);
         } else
         { Print ( "debug2.2: second condition false" );
           Print ( "debug2.2: val1=" ,OrderStopLoss(), " val2=" ,OrderOpenPrice() -(( TrailingStop+(CummulativeValue *(xaii- 1 )))*Figure));
 }}}}}}}}}

그것은 무언가를 드러낼 수 있습니다. 다른 == 조건에서도 비슷한 것을 할 수 있습니다.

 
SDC :

마지막 코드 블록을 이 디버그 버전으로 교체해 보십시오. xa와 비슷한 작업을 수행할 수 있습니다.

그것은 무언가를 드러낼 수 있습니다. 다른 == 조건에서도 비슷한 것을 할 수 있습니다.


네, 문제가 나타납니다. "이중 == 계산된 이중 문제"입니다. SDC 문제를 지적해 주셔서 감사합니다.

이전에도 같은 문제를 지적해 주신 foorr님 감사합니다. 하지만 올바른 방법으로 수정하지 않았고 문제가 아니라고 생각했습니다.

질문이 있지만 두 번째 for 루프에서 두 번째 및 세 번째 경우 "사이에" 문을 넣는 것이 더 낫습니다. OrderStopLoss() >= x + 1 && x - 1 ?? 아니면 >= 또는 <= ??

 

WHR이 이것을 읽지 않기를 바랍니다. 그는 적합할 것입니다. 그러나 NormalizeDouble() ....을 시도하라고 말할 것입니다. .... 동일해야 할 때 조건을 동일하게 만들어야 합니다. 그것의 OrderStopLoss() 쪽에도 그것을 할 필요는 없지만, 그것이 해야 할 때 여전히 동등하지 않다면 조건의 양쪽 모두에 그것을 시도할 수 있습니다....

       if (xaii>= 2 )
       { if (((OrderOpenPrice()-OrderClosePrice())/Figure)>=(StartTrailingStop+(CummulativeValue*xaii)))
        { Print ( "debug2.0: condition true" );
         if (OrderStopLoss()== NormalizeDouble ((OrderOpenPrice() -(( TrailingStop+(CummulativeValue *(xaii- 1 )))*Figure)),Digits));
         { Print ( "debug2.1: condition true" );
          Result=OrderModify(OrderTicket(),OrderOpenPrice(),(OrderOpenPrice() -(( TrailingStop+(CummulativeValue*xaii))*Figure)),OrderTakeProfit(), 0 ,Color);
         } else
         { Print ( "debug2.1: condition false" );
           Print ( "debug2.1: val1=" ,OrderStopLoss(), " val2=" ,OrderOpenPrice() -(( TrailingStop+(CummulativeValue *(xaii- 1 )))*Figure));
 }}}}}}}}}