hi all, I'm creating a bot using Python and mql5, I have a doubt, I want to let the script open a trade, and if that trade hit TP or SL it opens a new trade, is it possible? I can't find the variable to use in comparison I think it's ORDER_REASON_TP but I don't quite understand how to implement could you help me?
- Cryptography
- Working with Python - Developing programs
- MQL5 Wizard: Development of trading robots for MetaTrader 5
#include <Trade\DealInfo.mqh> CDealInfo m_deal; void OnTradeTransaction(const MqlTradeTransaction& trans, const MqlTradeRequest& request, const MqlTradeResult& result) { if(trans.type==TRADE_TRANSACTION_DEAL_ADD) { if(HistoryDealSelect(trans.deal)) m_deal.Ticket(trans.deal); else return; long reason=-1; m_deal.InfoInteger(DEAL_REASON,reason); if(reason==DEAL_REASON_TP) { // open new trade here } } }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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