You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
Kl_Urt: thanks for your code. This is similar to my code which I'm using for a while.
I define a class with special methods:
Usage of this class can be:
Hi @Dr Matthias Hammelsbeck
Would you share the customized DealInfo.mqh file, too?
Thanks & Regards
Hi @Dr Matthias Hammelsbeck
Would you share the customized DealInfo.mqh file, too?
Thanks & Regards
Yes. Please see the attached file
Yes. Please see the attached file
I need to have an OnClosePosition event when a position is closed manually....
Can this be done through OnTradeTransaction event?
Can someone show me how it is done?
Thanks & Regards
I need to have an OnClosePosition event when a position is closed manually....
Can this be done through OnTradeTransaction event?
Can someone show me how it is done?
Thanks & Regards
Printing out all in OnTradeTransaction did not trigger "close position" MANUALLY....
It only triggers close position when TP or SL is hit!
The following is my OnTradeTransaction code in order to catch the deal type or result code, but none was fired when I close a position MANUALLY...
Hope somebody can help me with it...
Thanks & regards...
//+------------------------------------------------------------------+ //| TradeTransaction function | //+------------------------------------------------------------------+ void OnTradeTransaction(const MqlTradeTransaction & trans, const MqlTradeRequest & request, const MqlTradeResult & result) { Print(GetRetcodeID(result.retcode)); // TRADE_RETCODE_POSITION_CLOSED Print(GetDealDescription(trans.deal_type)); } //+------------------------------------------------------------------+ //| convert numeric response codes to string mnemonics | //+------------------------------------------------------------------+ string GetRetcodeID(int retcode) { switch(retcode) { case 10004: return("TRADE_RETCODE_REQUOTE"); case 10006: return("TRADE_RETCODE_REJECT"); case 10007: return("TRADE_RETCODE_CANCEL"); case 10008: return("TRADE_RETCODE_PLACED"); case 10009: return("TRADE_RETCODE_DONE"); case 10010: return("TRADE_RETCODE_DONE_PARTIAL"); case 10011: return("TRADE_RETCODE_ERROR"); case 10012: return("TRADE_RETCODE_TIMEOUT"); case 10013: return("TRADE_RETCODE_INVALID"); case 10014: return("TRADE_RETCODE_INVALID_VOLUME"); case 10015: return("TRADE_RETCODE_INVALID_PRICE"); case 10016: return("TRADE_RETCODE_INVALID_STOPS"); case 10017: return("TRADE_RETCODE_TRADE_DISABLED"); case 10018: return("TRADE_RETCODE_MARKET_CLOSED"); case 10019: return("TRADE_RETCODE_NO_MONEY"); case 10020: return("TRADE_RETCODE_PRICE_CHANGED"); case 10021: return("TRADE_RETCODE_PRICE_OFF"); case 10022: return("TRADE_RETCODE_INVALID_EXPIRATION"); case 10023: return("TRADE_RETCODE_ORDER_CHANGED"); case 10024: return("TRADE_RETCODE_TOO_MANY_REQUESTS"); case 10025: return("TRADE_RETCODE_NO_CHANGES"); case 10026: return("TRADE_RETCODE_SERVER_DISABLES_AT"); case 10027: return("TRADE_RETCODE_CLIENT_DISABLES_AT"); case 10028: return("TRADE_RETCODE_LOCKED"); case 10029: return("TRADE_RETCODE_FROZEN"); case 10030: return("TRADE_RETCODE_INVALID_FILL"); case 10031: return("TRADE_RETCODE_CONNECTION"); case 10032: return("TRADE_RETCODE_ONLY_REAL"); case 10033: return("TRADE_RETCODE_LIMIT_ORDERS"); case 10034: return("TRADE_RETCODE_LIMIT_VOLUME"); case 10035: return("TRADE_RETCODE_INVALID_ORDER"); case 10036: return("TRADE_RETCODE_POSITION_CLOSED"); default: return("TRADE_RETCODE_UNKNOWN="+IntegerToString(retcode)); } //--- } string GetDealDescription(int deal_type) { //--- switch(deal_type) { case DEAL_TYPE_BALANCE: return ("balance"); case DEAL_TYPE_CREDIT: return ("credit"); case DEAL_TYPE_CHARGE: return ("charge"); case DEAL_TYPE_CORRECTION: return ("correction"); case DEAL_TYPE_BUY: return ("buy"); case DEAL_TYPE_SELL: return ("sell"); case DEAL_TYPE_BONUS: return ("bonus"); case DEAL_TYPE_COMMISSION: return ("additional commission"); case DEAL_TYPE_COMMISSION_DAILY: return ("daily commission"); case DEAL_TYPE_COMMISSION_MONTHLY: return ("monthly commission"); case DEAL_TYPE_COMMISSION_AGENT_DAILY: return ("daily agent commission"); case DEAL_TYPE_COMMISSION_AGENT_MONTHLY: return ("monthly agent commission"); case DEAL_TYPE_INTEREST: return ("interest rate"); case DEAL_TYPE_BUY_CANCELED: return ("cancelled buy deal"); case DEAL_TYPE_SELL_CANCELED: return ("cancelled sell deal"); default: return("DEAL_TYPE_UNKNOWN="+IntegerToString(deal_type)); } }Hi,
please see the content of the header file myTrade/Transaction.mqh:
Usage of this header can be:
Hi,
please see the content of the header file myTrade/Transaction.mqh:
Usage of this header can be:
Thanks for your help.... It worked! :-)
But one thing I need to ask you...
What is the need of putting DEAL_REASON_EXPERT & DEAL_REASON_CLIENT in the DEAL_ENTRY_IN block?
In my case, I don't care if BUY or SELL is done manually or by EA... Isn't that so in most cases?
Having that said, we don't need the OnOpenPositionManually event because by omitting the DEAL_REASON_EXPERT & DEAL_REASON_CLIENT in the DEAL_ENTRY_IN block covers it already...
The following is my DEAL_ENTRY_IN block of code and it worked as I wanted...
Regards,
Thanks for your help.... It worked! :-)
But one thing I need to ask you...
What is the need of putting DEAL_REASON_EXPERT & DEAL_REASON_CLIENT in the DEAL_ENTRY_IN block?
Because I want to distinguish between opening an order manually by the terminal and automatically by an expert advisor.
Matthias
Because I want to distinguish between opening an order manually by the terminal and automatically by an expert advisor.
Matthias
OK, gotcha!
Thanks again for your help...
Regards,