당사 팬 페이지에 가입하십시오
- 조회수:
- 4340
- 평가:
- 게시됨:
- 2017.11.03 12:25
-
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
Opening a position opposite to the closed one, with the same volume. It works for any symbol and any magic number.
For example, we have an open AUDUSD BUY 0.01 position. Once this position is closed (e.g. we close it manually) the Opposite trade Expert Advisor will immediately open a new AUDUSD positions, this now a SELL position.
The entire code is contained in the OnTradeTransaction function:
//+------------------------------------------------------------------+ //| 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_type =-1; long deal_entry =-1; double deal_volume =0.0; string deal_symbol =""; if(HistoryDealSelect(trans.deal)) { deal_type =HistoryDealGetInteger(trans.deal,DEAL_TYPE); deal_entry =HistoryDealGetInteger(trans.deal,DEAL_ENTRY); deal_volume =HistoryDealGetDouble(trans.deal,DEAL_VOLUME); deal_symbol =HistoryDealGetString(trans.deal,DEAL_SYMBOL); } else return; if(deal_entry==DEAL_ENTRY_OUT) { switch((int)deal_type) { case DEAL_TYPE_BUY: m_trade.Buy(deal_volume,deal_symbol); break; case DEAL_TYPE_SELL: m_trade.Sell(deal_volume,deal_symbol); break; default: break; } } } }
Here we wait for the position closing deal (DEAL_ENTRY_OUT). Once this deal appears, we check the deal position (if we close a BUY, this will be a Sell deal, and vice versa) and we open a new position.
MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/18904
![up3x1 Investor](https://c.mql5.com/i/code/expert.png)
Candlestick size analysis. The idea of the trading system: candlestick parameters matter after news releases.
![New Random](https://c.mql5.com/i/code/expert.png)
Trading based on a random number generator or in one of the following sequences: BUY - SELL - BUY or SELL - BUY - SELL.
![HTML file converter for the economic calendar](https://c.mql5.com/i/code/script.png)
HTML file converter for the economic calendar. The script parses a page downloaded from http://www.investing.com/economic-calendar, and forms a CSV file with the list of news.
![Psychological](https://c.mql5.com/i/code/indicator.png)
A classic oscillator imported from the FXAccuCharts platform.