귀하의 코드 형식은 읽기 어렵게 만들지만 한 가지는 후행 정지에서 이것을 어떻게 사용할 수 있습니까? 주문은 여전히 열려 있어야 하므로 OrderClosePrice()가 없습니다.
( OrderClosePrice() - OrderOpenPrice() ) / Figure ) >= ( StartTrailingStop + CummulativeValue )
그림이 무엇인지 알지 못한 채 ..... 주문이 아직 열려 있으면 OrderClosePrice - OrderOpenPrice가 음수 값을 가지므로 미결 주문에 대해 OrderClosePrice == 0을 알고 코드를 작성했습니까?
아니요, 그냥 OrderClosePrice-OrderOpenPrice를 사용하는 다른 모든 스크립트는 잘 작동합니다.
누군가 나에게 도움을 줄 수 있습니까? 나는 실제로 매우 가깝습니다. 나는 개인적으로 내 코딩에 문제가 있다고 생각하지 않지만 왜 항상 제대로 작동하지 않는지 모르겠습니다.
모든 것을 1로 결합한 이후로 긴 EA입니다. 이제 제 눈이 상당히 흐릿해진 점을 조금 실례합니다.
Figure는 각 특정 쌍에 대한 포인트 값을 반환합니다.
이것은 후행 부분입니다.
//+------------------------------------------------------------------+ //| Program's global variables | //+------------------------------------------------------------------+ extern double StartTrailingStop = 15.0 ; extern double TrailingStop = 5.0 ; extern double CummulativeValue = 5.0 ; extern int NumberOfTrail = 10 ; double Figure ; //+------------------------------------------------------------------+
//+------------------------------------------------------------------+ //| Program's sub-function | //+------------------------------------------------------------------+double PointsDetection() { Figure = 0.0 ; if ( MarketInfo ( OrderSymbol() , MODE_POINT ) == 0.01 || MarketInfo ( OrderSymbol() , MODE_POINT ) == 0.001 ) { Figure = 0.01 ; } else { if ( MarketInfo ( OrderSymbol() , MODE_POINT ) == 0.0001 || MarketInfo ( OrderSymbol() , MODE_POINT ) == 0.00001 ) { Figure = 0.0001 ; } } return ( Figure ) ; }
//+------------------------------------------------------------------+ //| Program's sub-function | //+------------------------------------------------------------------+ 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 ) && ( ( 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 ) ) && ( 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 ) ) ) && ( 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 ) && ( ( 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 ) ) && ( 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 ) ) ) && ( OrderStopLoss() == ( OrderOpenPrice() - ( ( TrailingStop + ( CummulativeValue * ( xaii - 1 ) ) ) * Figure ) ) ) ) { Result = OrderModify ( OrderTicket() , OrderOpenPrice() , ( OrderOpenPrice() - ( ( TrailingStop + ( CummulativeValue * xaii ) ) * Figure ) ) , OrderTakeProfit() , 0 , Color ) ; } } } } } } }
어쩌면 거기 :
( OrderStopLoss() == ( OrderOpenPrice() - ( TrailingStop * Figure ) )
https://forum.mql4.com/45053
아마도 서버 오류를 피하기 위해 다음과 같이 코딩해야 합니다.
figure = PointsDetection(); if ( ( ( ( OrderOpenPrice() - OrderClosePrice() ) / Figure ) >= StartTrailingStop ) && ( ( OrderStopLoss() == 0 ) || ( OrderStopLoss() >= OrderOpenPrice() ) || ( OrderStopLoss() > ( OrderOpenPrice() - ( TrailingStop * Figure ) ) ) ) ) { Result = OrderModify ( OrderTicket() , OrderOpenPrice() , ( OrderOpenPrice() - ( TrailingStop * Figure ) ) , OrderTakeProfit() , 0 , Color ) ; if( result == true ) break; }
구매 주문 :
( OrderStopLoss() < ( OrderOpenPrice() + ( TrailingStop * Figure ) )
나는 추적 EA 를 하고 있었는데 데모 에서 테스트 했을 때 구매 주문 만 올바르게 ( 내 생각 ) 는 것을 알았습니다 . 반면 판매 주문 은 정지 손실 을 한 번만 움직였습니다 . 그래도 문제가 어디에 있는지 여전히 알 수 없습니다.
** 코드 수정 **