당사 팬 페이지에 가입하십시오
- 게시자:
- Ivan Titov
- 조회수:
- 3414
- 평가:
- 게시됨:
- 2022.12.01 08:26
- 업데이트됨:
- 2022.12.02 13:44
-
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
The attached .mqh files are designed to export orders and trades from one EA and import them into another one (copying trades), which can be run both in the same terminal and in another terminal on the same computer. It is also possible to exchange trades between different symbols, for example, copy trades of an instrument of spot market on the corresponding futures or any other instrument that correlates with it.
Export
You need to include the GRat_OrderExport.mqh file to your exporting EA with the following command:
#include <GRat_OrderExport.mqh>
This must be done in the input parameters area exactly in the place where the export parameters should be:
- Common - true - export to another terminal on the same computer; false - export to the same terminal.
- KeepSeconds - how many seconds of exported trades are available for import. 0 - unlimited.
Then, in the EA code, wherever orders are executed by the OrderSend() function (or methods of the CTrade class), you need to add a call to the ExportOrder() function, for example:
MqlTradeRequest request = {}; // Market sell request.action = TRADE_ACTION_DEAL; request.symbol = Symbol(); request.volume = 0.2; request.type = ORDER_TYPE_SELL; request.price = SymbolInfoDouble (Symbol(), SYMBOL_BID); request.magic = 20000; OrderExport(request);
The MqlTradeRequest structure can be used the same as for the OrderSend() function, but you should fill additional MqlTradeRequest fields for actions
TRADE_ACTION_DEAL (for closing positions), TRADE_ACTION_SLTP, TRADE_ACTION_REMOVE and TRADE_ACTION_MODIFY:
- type (to modify positions it should be ORDER_TYPE_BUY - for a long position and ORDER_TYPE_SELL - for a short one)
- volume
- price (only for pending orders)
- stoplimit (only for Stop Limit orders)
- sl
- tp
- position (positive value, only for closing positions)
An example implementation of an exporting EA is GRat_OrderExport .
Import
You need to include the GRat_OrderImport.mqh file to your importing EA with the following command:
#include <GRat_OrderImport.mqh>
You need to do this in the input parameters area exactly in the place where the import parameters should be:
- Common - true - import from another terminal on the same computer; false - import from the same terminal.
- VolumeFactor - multiplier for the volume. It can be used to change the risk of trading, or in the case when the lots of instruments differ, for example, when copying trades from spot to futures and vice versa.
- PriceFactor - multiplier for the price. It can be used when the prices of correlated instruments differ, for example, when copying trades from spot to futures and vice versa.
- DeleteAfter - true - delete all trades from the exchange file immediately after import. For the case when trades are imported into only one EA. For several EAs set to false .
Then, to import trades, you need to call the ImportOrder() function. Call example:
MqlTradeRequest aReq[]; OrderImport(aReq, Magic, Symbol());
As a result, the aReq array contains all the latest unprocessed trades with the Magic number and the symbol of the current chart. In the last parameter, specify a different symbol if it differs in imported trades.
Next, in the cycle, you need to execute imporded trades on the desired symbol, adjusting the order parameters if necessary:
for ( int i = 0 ; i < ArraySize (aReq); i++) { aReq[i].symbol = _Symbol ; aReq[i].price = NormalizeDouble (aReq[i].price, _Digits ); aReq[i].stoplimit = NormalizeDouble (aReq[i].stoplimit, _Digits ); aReq[i].sl = NormalizeDouble (aReq[i].sl, _Digits ); aReq[i].tp = NormalizeDouble (aReq[i].tp, _Digits ); if (aReq[i].action == TRADE_ACTION_DEAL ) { ... } ... }
Attached EA is an example of the implementation of an importing EA that opens the imported trades on the symbol of EA's chart.
![The Roofing Filter](https://c.mql5.com/i/code/indicator.png)
The Roofing Filter Indicator was created by John Ehlers ("Cycle Analytics for Traders" pg. 80 - 82).
![BSI Trend and Channel](https://c.mql5.com/i/code/indicator.png)
This indicator shows trend line and channels using the BSI Indicator. Original work of https://www.mql5.com/en/code/13615
![Fear And Greed Function](https://c.mql5.com/i/code/script.png)
It is known that the market is mainly driven by two emotions: fear and greed. This should be seen as an attempt to implement these emotions in the form of a mathematical model.
![Lazy Bot MT5 (Daily Breakout EA)](https://c.mql5.com/i/code/expert.png)
- This Bot use stratery Breakout of Daily Bar, I tested for 3 Pair currency : GBPUSD, EURUSD, XAUUSD - Default setting is not sure the best, you can test for your parameter. - This is version for MT5 that convert from MT4 - this EA is best for broker low spread