메타에디터 빌드 1490 - 페이지 2

 
Andrey Dik :

SL/TP가 OnTradeTransaction()에서 작동했는지 어떻게 알 수 있습니까?

OnTrade*에서 메시지의 논리를 이해하기 위해 관심 이벤트가 발생한 순간에 입력 매개변수를 인쇄합니다.

똑같이하면 모든 것이 즉시 명확해질 것입니다.

PS MT5의 TP는 항상 (MT4와 달리) 거래소/ECN이 아닌 MT5 서버에 있는 시장 주문임을 잊지 마십시오. 따라서 트리거되면 모든 신호의 대기 시간 + 시장 슬리피지가 있습니다. 일부 MT4 TP에서는 ECN에 직접 지정가 주문이 있습니다. 따라서 지연(MT-ECN)이 없고 음의 미끄러짐이 없지만 거부가 있습니다. 따라서 TP는 MT4에 비해 MT5의 강력한 단점 중 하나입니다.

 
fxsaber :

OnTrade*에서 메시지의 논리를 이해하기 위해 관심 이벤트가 발생한 순간에 입력 매개변수를 인쇄합니다.

똑같이하면 모든 것이 즉시 명확해질 것입니다.

시험을 마친. 이 경우 OnTrade()에서 각 거래 이벤트에 대한 이력을 처리해야 하기 때문에 아무 소용이 없으며 심지어 해를 입힐 수도 있습니다.

이벤트 유형별 로 필터링할 수 있으므로 OnTradeTransaction()에서 SL/TP 트리거링에 대해 아는 것이 좋습니다. 이 경우 이벤트 유형을 "기록에 추가"로 정의한 다음 거래 유형을 "종료"로 정의한 다음 막다른 골목으로 정의했습니다.

 
Andrey Dik :

시험을 마친. 이 경우 OnTrade()에서 각 거래 이벤트에 대한 이력을 처리해야 하기 때문에 아무 소용이 없으며 심지어 해를 입힐 수도 있습니다.

OnTrade * 에 관한 것이었습니다.
 
fxsaber :
OnTrade * 에 관한 것이었습니다.
네 이해했습니다. 시험을 마친. 나는 (내가 필요한 것에서) 아무것도 찾지 못했습니다.
 
#include <MT4Orders.mqh> // https://www.mql5.com/ru/code/16006

bool FirstRun = true ;

void OnTick ()
{  
   if (FirstRun)    
  {
     const double Price = SymbolInfoDouble ( _Symbol , SYMBOL_ASK );
    
    FirstRun = ( OrderSend ( _Symbol , OP_BUY , 1 , Price, 0 , 0 , Price + 10 * _Point ) <= 0 );
  }
}

void OnTradeTransaction ( const MqlTradeTransaction &Trans, const MqlTradeRequest &Request, const MqlTradeResult &Result )
{
   if (!FirstRun)
     Print (ToString(Trans) + ToString(Request) + ToString(Result));
}

#define TOSTRING(A)   #A + " = " + ( string )(A) + "\n"
#define TOSTRING2(A) #A + " = " + EnumToString (A) + "\n"

string ToString( const MqlTradeTransaction &Trans )
{
   return (TOSTRING(Trans.deal) + TOSTRING(Trans.order) + TOSTRING(Trans.symbol) +
         TOSTRING2(Trans.type) + TOSTRING2(Trans.order_type) + TOSTRING2(Trans.order_state) +
         TOSTRING2(Trans.deal_type) + TOSTRING2(Trans.time_type) +
         TOSTRING(Trans.time_expiration) + TOSTRING(Trans.price) + TOSTRING(Trans.price_trigger) +
         TOSTRING(Trans.price_sl) + TOSTRING(Trans.price_tp) + TOSTRING(Trans.volume) +
         TOSTRING(Trans.position) + TOSTRING(Trans.position_by));
}

string ToString( const MqlTradeRequest &Request )
{
   return (TOSTRING2(Request.action) + TOSTRING(Request.magic) + TOSTRING(Request.order) +
         TOSTRING(Request.symbol) + TOSTRING(Request.volume) + TOSTRING(Request.price) +
         TOSTRING(Request.stoplimit) + TOSTRING(Request.sl) +  TOSTRING(Request.tp) +
         TOSTRING(Request.deviation) + TOSTRING2(Request.type) + TOSTRING2(Request.type_filling) +
         TOSTRING2(Request.type_time) + TOSTRING(Request.expiration) + TOSTRING(Request.comment) +
         TOSTRING(Request.position) + TOSTRING(Request.position_by));
}

string ToString( const MqlTradeResult &Result )
{
   return (TOSTRING(Result.retcode) + TOSTRING(Result.deal) + TOSTRING(Result.order) +
         TOSTRING(Result.volume) + TOSTRING(Result.price) + TOSTRING(Result.bid) +  
         TOSTRING(Result.ask) + TOSTRING(Result.comment) + TOSTRING(Result.request_id) +  
         TOSTRING(Result.retcode_external));
}
테스터 결과
2016.11 . 23 23 : 59 : 57    take profit triggered # 2 buy 1.00 EURUSD 1.06235 tp: 1.06245 [ # 3 sell 1.00 EURUSD at 1.06245 ]
2016.11 . 23 23 : 59 : 57    deal # 3 sell 1.00 EURUSD at 1.06245 done (based on order # 3 )
2016.11 . 23 23 : 59 : 57    deal performed [ # 3 sell 1.00 EURUSD at 1.06245 ]
2016.11 . 23 23 : 59 : 57    order performed sell 1.00 at 1.06245 [ # 3 sell 1.00 EURUSD at 1.06245 ]
2016.11 . 23 23 : 59 : 57    Trans.deal = 3
2016.11 . 23 23 : 59 : 57    Trans.order = 3
2016.11 . 23 23 : 59 : 57    Trans.type = TRADE_TRANSACTION_DEAL_ADD
2016.11 . 23 23 : 59 : 57    Trans.order_type = ORDER_TYPE_BUY
2016.11 . 23 23 : 59 : 57    Trans.order_state = ORDER_STATE_STARTED
2016.11 . 23 23 : 59 : 57    Trans.deal_type = DEAL_TYPE_SELL
2016.11 . 23 23 : 59 : 57    Trans.time_type = ORDER_TIME_GTC
2016.11 . 23 23 : 59 : 57    Trans.time_expiration = 1970.01 . 01 00 : 00 : 00
2016.11 . 23 23 : 59 : 57    Trans.price = 1.06245
2016.11 . 23 23 : 59 : 57    Trans.price_trigger = 0.0
2016.11 . 23 23 : 59 : 57    Trans.price_sl = 0.0
2016.11 . 23 23 : 59 : 57    Trans.volume = 1.0
2016.11 . 23 23 : 59 : 57    Trans.position = 2
2016.11 . 23 23 : 59 : 57    Trans.position_by = 0
2016.11 . 23 23 : 59 : 57    Request.action = ENUM_TRADE_REQUEST_ACTIONS :: 0
2016.11 . 23 23 : 59 : 57    Request.magic = 0
2016.11 . 23 23 : 59 : 57    Request.order = 0
2016.11 . 23 23 : 59 : 57    Request.symbol =
2016.11 . 23 23 : 59 : 57    Request.volume = 0.0
2016.11 . 23 23 : 59 : 57    Request.price = 0.0
2016.11 . 23 23 : 59 : 57    Request.sl = 0.0
2016.11 . 23 23 : 59 : 57    Request.tp = 0.0
2016.11 . 23 23 : 59 : 57    Request.deviation = 0
2016.11 . 23 23 : 59 : 57    Request.type = ORDER_TYPE_BUY
2016.11 . 23 23 : 59 : 57    Request.type_filling = ORDER_FILLING_FOK
2016.11 . 23 23 : 59 : 57    Request.type_time = ORDER_TIME_GTC
2016.11 . 23 23 : 59 : 57    Request.expiration = 1970.01 . 01 00 : 00 : 00
2016.11 . 23 23 : 59 : 57    Request.comment =
2016.11 . 23 23 : 59 : 57    Request.position = 0
2016.11 . 23 23 : 59 : 57    Result.retcode = 0
2016.11 . 23 23 : 59 : 57    Result.deal = 0
2016.11 . 23 23 : 59 : 57    Result.order = 0
2016.11 . 23 23 : 59 : 57    Result.volume = 0.0
2016.11 . 23 23 : 59 : 57    Result.price = 0.0
2016.11 . 23 23 : 59 : 57    Result.bid = 0.0
2016.11 . 23 23 : 59 : 57    Result.ask = 0.0
2016.11 . 23 23 : 59 : 57    Result.comment =
2016.11 . 23 23 : 59 : 57    Result.request_id = 0
2016.11 . 23 23 : 59 : 57   
2016.11 . 23 23 : 59 : 57    Trans.deal = 0
2016.11 . 23 23 : 59 : 57    Trans.order = 3
2016.11 . 23 23 : 59 : 57    Trans.symbol = EURUSD
2016.11 . 23 23 : 59 : 57    Trans.type = TRADE_TRANSACTION_ORDER_DELETE
2016.11 . 23 23 : 59 : 57    Trans.order_type = ORDER_TYPE_SELL
2016.11 . 23 23 : 59 : 57    Trans.order_state = ORDER_STATE_FILLED
2016.11 . 23 23 : 59 : 57    Trans.deal_type = DEAL_TYPE_BUY
2016.11 . 23 23 : 59 : 57    Trans.time_type = ORDER_TIME_GTC
2016.11 . 23 23 : 59 : 57    Trans.price = 1.06245
2016.11 . 23 23 : 59 : 57    Trans.price_trigger = 0.0
2016.11 . 23 23 : 59 : 57    Trans.price_sl = 0.0
2016.11 . 23 23 : 59 : 57    Trans.price_tp = 0.0
2016.11 . 23 23 : 59 : 57    Trans.volume = 1.0
2016.11 . 23 23 : 59 : 57    Trans.position = 2
2016.11 . 23 23 : 59 : 57    Trans.position_by = 0
2016.11 . 23 23 : 59 : 57    Request.action = ENUM_TRADE_REQUEST_ACTIONS :: 0
2016.11 . 23 23 : 59 : 57    Request.magic = 0
2016.11 . 23 23 : 59 : 57    Request.symbol =
2016.11 . 23 23 : 59 : 57    Request.volume = 0.0
2016.11 . 23 23 : 59 : 57    Request.price = 0.0
2016.11 . 23 23 : 59 : 57    Request.stoplimit = 0.0
2016.11 . 23 23 : 59 : 57    Request.sl = 0.0
2016.11 . 23 23 : 59 : 57    Request.tp = 0.0
2016.11 . 23 23 : 59 : 57    Request.deviation = 0
2016.11 . 23 23 : 59 : 57    Request.type = ORDER_TYPE_BUY
2016.11 . 23 23 : 59 : 57    Request.type_filling = ORDER_FILLING_FOK
2016.11 . 23 23 : 59 : 57    Request.expiration = 1970.01 . 01 00 : 00 : 00
2016.11 . 23 23 : 59 : 57    Request.comment =
2016.11 . 23 23 : 59 : 57    Request.position = 0
2016.11 . 23 23 : 59 : 57    Request.position_by = 0
2016.11 . 23 23 : 59 : 57    Result.retcode = 0
2016.11 . 23 23 : 59 : 57    Result.deal = 0
2016.11 . 23 23 : 59 : 57    Result.order = 0
2016.11 . 23 23 : 59 : 57    Result.volume = 0.0
2016.11 . 23 23 : 59 : 57    Result.price = 0.0
2016.11 . 23 23 : 59 : 57    Result.ask = 0.0
2016.11 . 23 23 : 59 : 57    Result.comment =
2016.11 . 23 23 : 59 : 57    Result.request_id = 0
2016.11 . 23 23 : 59 : 57    Result.retcode_external = 0
2016.11 . 23 23 : 59 : 57   
2016.11 . 23 23 : 59 : 57    Trans.deal = 0
2016.11 . 23 23 : 59 : 57    Trans.order = 3
2016.11 . 23 23 : 59 : 57    Trans.symbol = EURUSD
2016.11 . 23 23 : 59 : 57    Trans.type = TRADE_TRANSACTION_HISTORY_ADD
2016.11 . 23 23 : 59 : 57    Trans.order_state = ORDER_STATE_FILLED
2016.11 . 23 23 : 59 : 57    Trans.deal_type = DEAL_TYPE_BUY
2016.11 . 23 23 : 59 : 57    Trans.time_type = ORDER_TIME_GTC
2016.11 . 23 23 : 59 : 57    Trans.time_expiration = 1970.01 . 01 00 : 00 : 00
2016.11 . 23 23 : 59 : 57    Trans.price = 1.06245
2016.11 . 23 23 : 59 : 57    Trans.price_trigger = 0.0
2016.11 . 23 23 : 59 : 57    Trans.price_sl = 0.0
2016.11 . 23 23 : 59 : 57    Trans.price_tp = 0.0
2016.11 . 23 23 : 59 : 57    Trans.volume = 0.0
2016.11 . 23 23 : 59 : 57    Trans.position_by = 0
2016.11 . 23 23 : 59 : 57    Request.action = ENUM_TRADE_REQUEST_ACTIONS :: 0
2016.11 . 23 23 : 59 : 57    Request.magic = 0
2016.11 . 23 23 : 59 : 57    Request.order = 0
2016.11 . 23 23 : 59 : 57    Request.symbol =
2016.11 . 23 23 : 59 : 57    Request.volume = 0.0
2016.11 . 23 23 : 59 : 57    Request.price = 0.0
2016.11 . 23 23 : 59 : 57    Request.stoplimit = 0.0
2016.11 . 23 23 : 59 : 57    Request.sl = 0.0
2016.11 . 23 23 : 59 : 57    Request.deviation = 0
2016.11 . 23 23 : 59 : 57    Request.type = ORDER_TYPE_BUY
2016.11 . 23 23 : 59 : 57    Request.type_filling = ORDER_FILLING_FOK
2016.11 . 23 23 : 59 : 57    Request.type_time = ORDER_TIME_GTC
2016.11 . 23 23 : 59 : 57    Request.expiration = 1970.01 . 01 00 : 00 : 00
2016.11 . 23 23 : 59 : 57    Request.comment =
2016.11 . 23 23 : 59 : 57    Request.position = 0
2016.11 . 23 23 : 59 : 57    Request.position_by = 0
2016.11 . 23 23 : 59 : 57    Result.retcode = 0
2016.11 . 23 23 : 59 : 57    Result.order = 0
2016.11 . 23 23 : 59 : 57    Result.volume = 0.0
2016.11 . 23 23 : 59 : 57    Result.price = 0.0
2016.11 . 23 23 : 59 : 57    Result.bid = 0.0
2016.11 . 23 23 : 59 : 57    Result.ask = 0.0
2016.11 . 23 23 : 59 : 57    Result.comment =
2016.11 . 23 23 : 59 : 57    Result.request_id = 0
2016.11 . 23 23 : 59 : 57    Result.retcode_external = 0
 

fxsaber :

테스터 결과

글쎄요, 그럼요?

SL/TP가 작동했음을 어디에서 볼 수 있습니까? - 이것이 어려움이다

 

후 MQL5를 사용하여 이익실현 및 손절매 값을 찾을 수 없습니다 .

이게 문제 야. 그러나 MT5는 닫힌 위치의 로그와 그림으로 판단하여 어떻게든 이 정보를 얻습니다.
 
fxsaber :
이게 문제 야. 그러나 MT5는 닫힌 위치의 로그와 그림으로 판단하여 어떻게든 이 정보를 얻습니다.

그리고 더 이상 작동하지 않습니까?

있고 종가 가 TP보다 좋거나 같고 SL보다 나쁘거나 같은지 확인했습니다.


 
Stanislav Korotky :

그리고 더 이상 작동하지 않습니까?

아마도 코드?

... 네, 네, 마샤는 허벅지로 할 수 있습니다. 죄송합니다 ... 코드를 보여주세요.

 
Stanislav Korotky :

그리고 더 이상 작동하지 않습니까?

예, 결정할 수 없습니다. SL과 TP는 MT 서버만의 본질입니다.
사유: