우리는 다른 방향으로 2개의 보류 중인 주문 을 배치합니다. 그 중 하나가 실행되는 즉시 다른 하나는 삭제되고 더 이상 배치되지 않습니다.
도움을 주시면 대단히 감사하겠습니다.
고맙습니다.
여러 가지 방법이 있습니다. 그 중 하나는 OnTradeTransaction을 사용하는 것입니다.
우리는 거래를 잡습니다
TRADE_TRANSACTION_DEAL_ADD
역사에 거래를 추가합니다. 주문 실행 또는 계정 잔액 작업의 결과로 수행됩니다.
이 거래가 시장 진입인지 확인하십시오.
DEAL_ENTRY_IN
시장 진입
//+------------------------------------------------------------------+ //| TradeTransaction function | //+------------------------------------------------------------------+ voidOnTradeTransaction ( constMqlTradeTransaction &trans, constMqlTradeRequest &request, constMqlTradeResult &result) { //--- get transaction type as enumeration value ENUM_TRADE_TRANSACTION_TYPE type=trans.type; //--- if transaction is result of addition of the transaction in history if (type== TRADE_TRANSACTION_DEAL_ADD ) { long deal_entry = 0 ; long deal_type = 0 ; string deal_symbol = "" ; long deal_magic = 0 ; if ( HistoryDealSelect (trans.deal)) { deal_entry= HistoryDealGetInteger (trans.deal, DEAL_ENTRY ); deal_type= HistoryDealGetInteger (trans.deal, DEAL_TYPE ); deal_symbol= HistoryDealGetString (trans.deal, DEAL_SYMBOL ); deal_magic= HistoryDealGetInteger (trans.deal, DEAL_MAGIC ); } else return ; if (deal_symbol== Symbol () && deal_magic==m_magic) if (deal_entry== DEAL_ENTRY_IN ) { CloseAll(); } } }
이 거래는 보류 주문이 트리거되고 거래가 내역에 기록된 후에 발생합니다.
이 거래를 포착하면 남아 있는 모든 보류 주문을 삭제해야 합니다.
//+------------------------------------------------------------------+ //| Close All Orders | //+------------------------------------------------------------------+ void CloseAll() { Print ( __FUNCTION__ ); for ( int i= OrdersTotal ()- 1 ;i>= 0 ;i--) // returns the number of open positions if (m_order.SelectByIndex(i)) if (m_order. Symbol ()== Symbol () && m_order.Magic()==m_magic) m_trade. OrderDelete (m_order.Ticket()); }
} //+------------------------------------------------------------------+ //| TradeTransaction function | //+------------------------------------------------------------------+ voidOnTradeTransaction ( constMqlTradeTransaction &trans, constMqlTradeRequest &request, constMqlTradeResult &result) { //--- get transaction type as enumeration value ENUM_TRADE_TRANSACTION_TYPE type=trans.type; //--- if transaction is result of addition of the transaction in history if (type== TRADE_TRANSACTION_DEAL_ADD ) { long deal_entry = 0 ; long deal_type = 0 ; string deal_symbol = "" ; long deal_magic = 0 ; if ( HistoryDealSelect (trans.deal)) { deal_entry= HistoryDealGetInteger (trans.deal, DEAL_ENTRY ); deal_type= HistoryDealGetInteger (trans.deal, DEAL_TYPE ); deal_symbol= HistoryDealGetString (trans.deal, DEAL_SYMBOL ); deal_magic= HistoryDealGetInteger (trans.deal, DEAL_MAGIC ); } else return ; if (deal_symbol== Symbol () && deal_magic==m_magic) if (deal_entry== DEAL_ENTRY_IN ) { CloseAll(); } } } //+------------------------------------------------------------------+ //| Close All Orders | //+------------------------------------------------------------------+ void CloseAll() { Print ( __FUNCTION__ ); for ( int i= OrdersTotal ()- 1 ;i>= 0 ;i--) // returns the number of open positions if (m_order.SelectByIndex(i)) if (m_order. Symbol ()== Symbol () && m_order.Magic()==m_magic) m_trade. OrderDelete (m_order.Ticket()); } //+------------------------------------------------------------------+
여러 가지 방법이 있습니다. 그 중 하나는 OnTradeTransaction을 사용하는 것입니다.
우리는 거래를 잡습니다
TRADE_TRANSACTION_DEAL_ADD
역사에 거래를 추가합니다. 주문 실행 또는 계정 잔액 작업의 결과로 수행됩니다.
이 거래가 시장 진입인지 확인하십시오.
DEAL_ENTRY_IN
시장 진입
//+------------------------------------------------------------------+ //| TradeTransaction function | //+------------------------------------------------------------------+ voidOnTradeTransaction ( constMqlTradeTransaction &trans, constMqlTradeRequest &request, constMqlTradeResult &result) { //--- get transaction type as enumeration value ENUM_TRADE_TRANSACTION_TYPE type=trans.type; //--- if transaction is result of addition of the transaction in history if (type== TRADE_TRANSACTION_DEAL_ADD ) { long deal_entry = 0 ; long deal_type = 0 ; string deal_symbol = "" ; long deal_magic = 0 ; if ( HistoryDealSelect (trans.deal)) { deal_entry= HistoryDealGetInteger (trans.deal, DEAL_ENTRY ); deal_type= HistoryDealGetInteger (trans.deal, DEAL_TYPE ); deal_symbol= HistoryDealGetString (trans.deal, DEAL_SYMBOL ); deal_magic= HistoryDealGetInteger (trans.deal, DEAL_MAGIC ); } else return ; if (deal_symbol== Symbol () && deal_magic==m_magic) if (deal_entry== DEAL_ENTRY_IN ) { CloseAll(); } } }
이 거래는 보류 주문이 트리거되고 거래가 내역에 기록된 후에 발생합니다.
이 거래를 포착하면 남아 있는 모든 보류 주문을 삭제해야 합니다.
//+------------------------------------------------------------------+ //| Close All Orders | //+------------------------------------------------------------------+ void CloseAll() { Print ( __FUNCTION__ ); for ( int i= OrdersTotal ()- 1 ;i>= 0 ;i--) // returns the number of open positions if (m_order.SelectByIndex(i)) if (m_order. Symbol ()== Symbol () && m_order.Magic()==m_magic) m_trade. OrderDelete (m_order.Ticket()); }
} //+------------------------------------------------------------------+ //| TradeTransaction function | //+------------------------------------------------------------------+ voidOnTradeTransaction ( constMqlTradeTransaction &trans, constMqlTradeRequest &request, constMqlTradeResult &result) { //--- get transaction type as enumeration value ENUM_TRADE_TRANSACTION_TYPE type=trans.type; //--- if transaction is result of addition of the transaction in history if (type== TRADE_TRANSACTION_DEAL_ADD ) { long deal_entry = 0 ; long deal_type = 0 ; string deal_symbol = "" ; long deal_magic = 0 ; if ( HistoryDealSelect (trans.deal)) { deal_entry= HistoryDealGetInteger (trans.deal, DEAL_ENTRY ); deal_type= HistoryDealGetInteger (trans.deal, DEAL_TYPE ); deal_symbol= HistoryDealGetString (trans.deal, DEAL_SYMBOL ); deal_magic= HistoryDealGetInteger (trans.deal, DEAL_MAGIC ); } else return ; if (deal_symbol== Symbol () && deal_magic==m_magic) if (deal_entry== DEAL_ENTRY_IN ) { CloseAll(); } } } //+------------------------------------------------------------------+ //| Close All Orders | //+------------------------------------------------------------------+ void CloseAll() { Print ( __FUNCTION__ ); for ( int i= OrdersTotal ()- 1 ;i>= 0 ;i--) // returns the number of open positions if (m_order.SelectByIndex(i)) if (m_order. Symbol ()== Symbol () && m_order.Magic()==m_magic) m_trade. OrderDelete (m_order.Ticket()); } //+------------------------------------------------------------------+
모두 좋은 하루! 어드바이저에 주문 삭제 넣는 방법을 알려주세요.
상황은 이렇습니다.
우리는 다른 방향으로 2개의 보류 중인 주문 을 배치합니다. 그 중 하나가 실행되는 즉시 다른 하나는 삭제되고 더 이상 배치되지 않습니다.
도움을 주시면 대단히 감사하겠습니다.
고맙습니다.
여러 가지 방법이 있습니다. 그 중 하나는 OnTradeTransaction을 사용하는 것입니다.
우리는 거래를 잡습니다
TRADE_TRANSACTION_DEAL_ADD
역사에 거래를 추가합니다. 주문 실행 또는 계정 잔액 작업의 결과로 수행됩니다.
이 거래가 시장 진입인지 확인하십시오.
DEAL_ENTRY_IN
시장 진입
//| TradeTransaction function |
//+------------------------------------------------------------------+
void OnTradeTransaction ( const MqlTradeTransaction &trans,
const MqlTradeRequest &request,
const MqlTradeResult &result)
{
//--- get transaction type as enumeration value
ENUM_TRADE_TRANSACTION_TYPE type=trans.type;
//--- if transaction is result of addition of the transaction in history
if (type== TRADE_TRANSACTION_DEAL_ADD )
{
long deal_entry = 0 ;
long deal_type = 0 ;
string deal_symbol = "" ;
long deal_magic = 0 ;
if ( HistoryDealSelect (trans.deal))
{
deal_entry= HistoryDealGetInteger (trans.deal, DEAL_ENTRY );
deal_type= HistoryDealGetInteger (trans.deal, DEAL_TYPE );
deal_symbol= HistoryDealGetString (trans.deal, DEAL_SYMBOL );
deal_magic= HistoryDealGetInteger (trans.deal, DEAL_MAGIC );
}
else
return ;
if (deal_symbol== Symbol () && deal_magic==m_magic)
if (deal_entry== DEAL_ENTRY_IN )
{
CloseAll();
}
}
}
이 거래는 보류 주문이 트리거되고 거래가 내역에 기록된 후에 발생합니다.
이 거래를 포착하면 남아 있는 모든 보류 주문을 삭제해야 합니다.
//| Close All Orders |
//+------------------------------------------------------------------+
void CloseAll()
{
Print ( __FUNCTION__ );
for ( int i= OrdersTotal ()- 1 ;i>= 0 ;i--) // returns the number of open positions
if (m_order.SelectByIndex(i))
if (m_order. Symbol ()== Symbol () && m_order.Magic()==m_magic)
m_trade. OrderDelete (m_order.Ticket());
}
고문의 일반 코드(여기서만 "0"과 같은 마법을 표시했습니다. 마법을 설정해야 함):
//| There will be only one.mq5 |
//| Copyright © 2016, Vladimir Karputov |
//| http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2016, Vladimir Karputov"
#property link "http://wmua.ru/slesar/"
#property version "1.00"
#include <Trade\Trade.mqh>
#include <Trade\OrderInfo.mqh>
CTrade m_trade; // trading object
COrderInfo m_order; // pending orders object
//---
ulong m_magic= 0 ; // magic number
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit ()
{
//---
//---
return ( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick ()
{
//---
}
//+------------------------------------------------------------------+
//| TradeTransaction function |
//+------------------------------------------------------------------+
void OnTradeTransaction ( const MqlTradeTransaction &trans,
const MqlTradeRequest &request,
const MqlTradeResult &result)
{
//--- get transaction type as enumeration value
ENUM_TRADE_TRANSACTION_TYPE type=trans.type;
//--- if transaction is result of addition of the transaction in history
if (type== TRADE_TRANSACTION_DEAL_ADD )
{
long deal_entry = 0 ;
long deal_type = 0 ;
string deal_symbol = "" ;
long deal_magic = 0 ;
if ( HistoryDealSelect (trans.deal))
{
deal_entry= HistoryDealGetInteger (trans.deal, DEAL_ENTRY );
deal_type= HistoryDealGetInteger (trans.deal, DEAL_TYPE );
deal_symbol= HistoryDealGetString (trans.deal, DEAL_SYMBOL );
deal_magic= HistoryDealGetInteger (trans.deal, DEAL_MAGIC );
}
else
return ;
if (deal_symbol== Symbol () && deal_magic==m_magic)
if (deal_entry== DEAL_ENTRY_IN )
{
CloseAll();
}
}
}
//+------------------------------------------------------------------+
//| Close All Orders |
//+------------------------------------------------------------------+
void CloseAll()
{
Print ( __FUNCTION__ );
for ( int i= OrdersTotal ()- 1 ;i>= 0 ;i--) // returns the number of open positions
if (m_order.SelectByIndex(i))
if (m_order. Symbol ()== Symbol () && m_order.Magic()==m_magic)
m_trade. OrderDelete (m_order.Ticket());
}
//+------------------------------------------------------------------+
OnDeinit 이벤트에 대한 또 다른 질문:
이 코드는 작동합니다:
무효 OnDeinit(const int 이유)
{
if(이유==REASON_REMOVE)
{
포지션 마감 코드(있는 경우)
}
}
일반적으로 OnDeinit 이벤트 처리에서 포지션을 청산할 수 있는지 알아내야 합니다.
좋은 시간 전문가, 경험을 공유하십시오.
값 배열이 있으며 특정 개체/필드를 반영합니다. 즉, 작업이 이 개체/필드를 어떻게든 지정하는 것이라면 어떤 작업이 가능한지 나타냅니다.
예를 들어, 어레이의 볼륨이 x 및 y에서 수천 개의 셀에 도달할 수 있는 경우 이 어레이를 Kohonen 맵 네트워크에 넣는 것이 적절할까요?
2차원 배열 중 하나(큰 차원 포함)를 Kohonen 네트워크에 넣는 방법을 알려주실 수 있습니까?
그리고 Cohon은 분석에 적합합니까 - 배열 재귀(배열의 배열)
아니면 누군가가 올바른 질문을 하는 데 도움을 줄 것입니다.
여러 가지 방법이 있습니다. 그 중 하나는 OnTradeTransaction을 사용하는 것입니다.
우리는 거래를 잡습니다
TRADE_TRANSACTION_DEAL_ADD
역사에 거래를 추가합니다. 주문 실행 또는 계정 잔액 작업의 결과로 수행됩니다.
이 거래가 시장 진입인지 확인하십시오.
DEAL_ENTRY_IN
시장 진입
//| TradeTransaction function |
//+------------------------------------------------------------------+
void OnTradeTransaction ( const MqlTradeTransaction &trans,
const MqlTradeRequest &request,
const MqlTradeResult &result)
{
//--- get transaction type as enumeration value
ENUM_TRADE_TRANSACTION_TYPE type=trans.type;
//--- if transaction is result of addition of the transaction in history
if (type== TRADE_TRANSACTION_DEAL_ADD )
{
long deal_entry = 0 ;
long deal_type = 0 ;
string deal_symbol = "" ;
long deal_magic = 0 ;
if ( HistoryDealSelect (trans.deal))
{
deal_entry= HistoryDealGetInteger (trans.deal, DEAL_ENTRY );
deal_type= HistoryDealGetInteger (trans.deal, DEAL_TYPE );
deal_symbol= HistoryDealGetString (trans.deal, DEAL_SYMBOL );
deal_magic= HistoryDealGetInteger (trans.deal, DEAL_MAGIC );
}
else
return ;
if (deal_symbol== Symbol () && deal_magic==m_magic)
if (deal_entry== DEAL_ENTRY_IN )
{
CloseAll();
}
}
}
이 거래는 보류 주문이 트리거되고 거래가 내역에 기록된 후에 발생합니다.
이 거래를 포착하면 남아 있는 모든 보류 주문을 삭제해야 합니다.
//| Close All Orders |
//+------------------------------------------------------------------+
void CloseAll()
{
Print ( __FUNCTION__ );
for ( int i= OrdersTotal ()- 1 ;i>= 0 ;i--) // returns the number of open positions
if (m_order.SelectByIndex(i))
if (m_order. Symbol ()== Symbol () && m_order.Magic()==m_magic)
m_trade. OrderDelete (m_order.Ticket());
}
고문의 일반 코드(여기서만 "0"과 같은 마법을 표시했습니다. 마법을 설정해야 함):
//| There will be only one.mq5 |
//| Copyright © 2016, Vladimir Karputov |
//| http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2016, Vladimir Karputov"
#property link "http://wmua.ru/slesar/"
#property version "1.00"
#include <Trade\Trade.mqh>
#include <Trade\OrderInfo.mqh>
CTrade m_trade; // trading object
COrderInfo m_order; // pending orders object
//---
ulong m_magic= 0 ; // magic number
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit ()
{
//---
//---
return ( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick ()
{
//---
}
//+------------------------------------------------------------------+
//| TradeTransaction function |
//+------------------------------------------------------------------+
void OnTradeTransaction ( const MqlTradeTransaction &trans,
const MqlTradeRequest &request,
const MqlTradeResult &result)
{
//--- get transaction type as enumeration value
ENUM_TRADE_TRANSACTION_TYPE type=trans.type;
//--- if transaction is result of addition of the transaction in history
if (type== TRADE_TRANSACTION_DEAL_ADD )
{
long deal_entry = 0 ;
long deal_type = 0 ;
string deal_symbol = "" ;
long deal_magic = 0 ;
if ( HistoryDealSelect (trans.deal))
{
deal_entry= HistoryDealGetInteger (trans.deal, DEAL_ENTRY );
deal_type= HistoryDealGetInteger (trans.deal, DEAL_TYPE );
deal_symbol= HistoryDealGetString (trans.deal, DEAL_SYMBOL );
deal_magic= HistoryDealGetInteger (trans.deal, DEAL_MAGIC );
}
else
return ;
if (deal_symbol== Symbol () && deal_magic==m_magic)
if (deal_entry== DEAL_ENTRY_IN )
{
CloseAll();
}
}
}
//+------------------------------------------------------------------+
//| Close All Orders |
//+------------------------------------------------------------------+
void CloseAll()
{
Print ( __FUNCTION__ );
for ( int i= OrdersTotal ()- 1 ;i>= 0 ;i--) // returns the number of open positions
if (m_order.SelectByIndex(i))
if (m_order. Symbol ()== Symbol () && m_order.Magic()==m_magic)
m_trade. OrderDelete (m_order.Ticket());
}
//+------------------------------------------------------------------+
감사합니다. 하지만 MQL4용으로 어떻게 준비하나요? 바로 해명하지 못한 점 죄송합니다.
감사합니다. 하지만 MQL4용으로 어떻게 준비하나요? 바로 해명하지 못한 점 죄송합니다.
왜 나는 주식과 선물 시장에서 실수를 하지만 Forex와 Komodis에서는 모든 것이 정상입니까?
판매 한도 실패 1.00 USDRUB_TOM at 63.8679 sl: 63.8829 tp: 63.8329 [잘못된 만료]
왜 나는 주식과 선물 시장에서 실수를 하지만 Forex와 Komodis에서는 모든 것이 정상입니까?
판매 한도 실패 1.00 USDRUB_TOM at 63.8679 sl: 63.8829 tp: 63.8329 [잘못된 만료]
매개변수를 추가해야 합니다
안녕하세요 동료 여러분, mql5에 대한 질문:
오늘 열린 포지션(거래)의 이익을 계산하는 방법(포지션이 어제 열리고 오늘 닫힌 경우 이 포지션은 고려되지 않음)????
안녕하세요 동료 여러분, mql5에 대한 질문:
오늘 열린 포지션(거래)의 이익을 계산하는 방법(포지션이 어제 열리고 오늘 닫힌 경우 이 포지션은 고려되지 않음)????
분명히, 포지션을 여는 시간을 하루 시작 시간과 비교합니다 .