Forex Factory (https://www.forexfactory.com/forum.php)
-   Trading Systems (https://www.forexfactory.com/forumdisplay.php?f=71)
-   -   LRSF - TMS Expert Advisor - MT5 (https://www.forexfactory.com/showthread.php?t=864355)

jansb000 Jan 1, 2019 1:12pm | Post# 1

LRSF - TMS Expert Advisor - MT5
 
4 Attachment(s)
Hi all,
After 22 versions of my TMS Expert Advisor I decided that it is time to port it to MT5. The reason that attracted me most to MT5 was it's advanced testing capabilities. This should make it a lot more efficient to develop this EA further.

Original thread for the MT4 version: https://www.forexfactory.com/showthr...4#post10597594

This thread will describe how I develop my Expert Advisor. My perspective is the development process. This EA follows the well known Trading Made Simple strategy. So we do not have to discuss that in this thread. Here we just try to automate that strategy as best as possible.

I will post every version here and you can download it for testing purposes. The EA will work on real accounts but with some security measures. First, as a test-version it is time limited, and second, on a real account it will only trade one position at any time. Once we reach a stable version these limitations will be lifted.

Downloadable files:

  1. Version 2.06
  2. BIM_LRSF_206.ex5
  3. Version 2.07
    BIM_LRSF_207.ex5
  4. Version 2.08
    BIM_LRSF_208.ex5

Work in progress:

  1. Version 2.09 wip 1
    BIM_LRSF_209_1.ex5

Goodies:

  1. Scripts for manual trading: Post #4 Post #5
  2. TDI Indicator: Post #11 and #12


jansb000 Jan 1, 2019 1:26pm | Post# 2

LRSF EA - Version 2.03

Version 2.00/2.01/2.02 were all inbetween versions with certain keyparts converted to MT5.

  1. 2.00 Contains the include files in a basic program structure.
  2. 2.01 Contains the main program structure with event processing.
  3. 2.02 Contains the key-function do_open(). This function opens new positions when the entry-conditions are met.
  4. 2.03 Contains the key-function do_manage(). This function manages and closes a position when the close-conditions are met.

Version 2.03 is functional equivalent with MT4 version 1.21. The order processing in MT5 is quite different from MT4 so all those functions must be tested from the most basic level upwards. So this will result in versions 2.04 and further. Only when the EA is working smoothly I will upgrade to the functional equivalent of MT4 version 1.22. And only then I will start to improve the MT5 version further.

PS: Downloading this version only makes sense if you want to help in the development process and run it on the strategy tester. Do not use it on a real account as it definitely has bugs that need to be solved first.
Cheers...


timidave Jan 1, 2019 4:17pm | Post# 3

Well done jansb000 for keeping hopes alive on this thread. I've been following you for a long time and I appreciate your consistency. You promised you'll come back and you've done so! I'm sending you a Private message asking for a favour from you. Pls do check your inbox and get back to me. Thanks in advance.

jansb000 Jan 3, 2019 6:23am | Post# 4

2 Attachment(s)
Scripts for manual trading

The following scripts can be used to manually create orders with the correct MagicNumber.

  1. Script for opening a BUY order
    LRSF - Manual BUY Order.ex5
  2. Script for opening a SELL order
    LRSF - Manual SELL Order.ex5

Once these orders are opened the LRSF EA can be used for further management.

Why use manual trades?
The LRSF EA/TM is an Expert Advisor / Trade Manager. That means it can trade autonomously. Trading has two aspects - The ENTRY- and the EXIT condition. To open trades the EA will monitor the price development and when all conditions apply it will open a trade. This is the EA part. Once a trade is open, the TM-part will monitor the trade and when the close conditions apply it will close the trade.
Both functions of LRSF are not perfect. In most cases a trade will come out with profit, but now and again the EA will open an order that (although all ENTRY-conditions apply) will go against you and can not be recovered. Therefore, it is advised that most of the time you should trade manually (using the TMS-strategy). Even when you leave the EA to trade autonomously you should set the type of trade manually to just BUY or just SELL. In that sense, the best results can be obtained by trading interactively.

Cheers...


jansb000 Mar 1, 2019 2:45pm | Post# 5

2 Attachment(s)
Scripts for manual trading

updated versions.
LRSF - Manual BUY Order.ex5
LRSF - Manual SELL Order.ex5

jansb000 Mar 1, 2019 2:50pm | Post# 6

LRSF Expert Advisor 2.05 wip 1

Find downloadable in post #1.

This version has improved code for trend detection and for checking if the TMS5 is broken. With only these two tests the EA will actually open trades. But with other tests activated no trades seem to open. So more bug fixing is needed.

Do not use this version for real trading!

Cheers...

DJsignals Mar 2, 2019 2:29am | Post# 7

Bro, nice work, but need indicator.

v204 error
2019.03.02 14:27:23.872 Core 1 program file added: Indicators\Examples\Heiken_Ashi.ex5. 13547 bytes loaded
2019.03.02 14:27:23.872 Core 1 program file Indicators\bim\tms\TradersDynamicIndex.ex5 read error

DJsignals Mar 2, 2019 4:59am | Post# 8

v203 error
2019.03.02 16:59:05.454 Core 1 program file Indicators\Heiken_Ashi.ex5 read error

nschwegl Mar 6, 2019 3:03am | Post# 9

Hi all, After 22 versions of my TMS Expert Advisor I decided that it is time to port it to MT5. The reason that attracted me most to MT5 was it's advanced testing capabilities. This should make it a lot more efficient to develop this EA further. Original thread for the MT4 version: https://www.forexfactory.com/showthr...4#post10597594 This thread will describe how I develop my Expert Advisor. My perspective is the...
EA does not work, TDI message, can you help, mt5 file ?. Thanks in advance

goodways100 Mar 6, 2019 3:40am | Post# 10

Subscribed jansb. Good and hard work you do. Thanks and
Regards

jansb000 Mar 6, 2019 5:05am | Post# 11

2 Attachment(s)
TDI - Trader Dynamic Indicator for MT5

The TDI indicator is very popular, but surprisingly there are not a lot of sources for downloading a MT5 version.
In my project I use the version that I found here:
https://www.earnforex.com/blog/trade...5-and-ctrader/

For your convenience I also provide it here in both source and compiled form, but just remember that I take no credits.
TradersDynamicIndex.mq5
TradersDynamicIndex.ex5
Cheers...

jansb000 Mar 6, 2019 5:18am | Post# 12

1 Attachment(s)
Bro, nice work, but need indicator. v204 error 2019.03.02 14:27:23.872 Core 1 program file added: Indicators\Examples\Heiken_Ashi.ex5. 13547 bytes loaded 2019.03.02 14:27:23.872 Core 1 program file Indicators\bim\tms\TradersDynamicIndex.ex5 read error
Hi DJsignals,

it is necessary to have the TDI indicator installed in the correct folder. For the correct indicator please refer to post #11. Install it in the data section:

  1. File->Open data section
  2. Go to Indicators
  3. Create the folders "Indicators\bim" and "Indicators\bim\tms"
  4. Insert the downloaded indicator in this folder:
    Click to Enlarge

Name: Screenshot1.png
Size: 69 KB

Cheers...


jansb000 Mar 6, 2019 5:26am | Post# 13

{quote} EA does not work, TDI message, can you help, mt5 file ?. Thanks in advance
Hi nschwegl,
welcome to the MT5 version of my Expert Advisor.
Posts #11 and #12 will give you info about the TDI indicator.

In general, the current version of this EA is still buggy, because the code for opening and changing orders is very different from MT4. So I have to find all the problems one by one until it works exactly the same as the MT4 version before I can start improving the algorithm. Please, have patience.
Cheers...

nschwegl Mar 7, 2019 1:58am | Post# 14

2 Attachment(s)
{quote} Hi nschwegl, welcome to the MT5 version of my Expert Advisor. Posts #11 and #12 will give you info about the TDI indicator. In general, the current version of this EA is still buggy, because the code for opening and changing orders is very different from MT4. So I have to find all the problems one by one until it works exactly the same as the MT4 version before I can start improving the algorithm. Please, have patience. Cheers...
Hallo , what is wrong with These Settings, it does not work
Click to Enlarge

Name: Screenshot1.png
Size: 313 KB
Click to Enlarge

Name: Screenshot2.png
Size: 296 KB

nschwegl Mar 7, 2019 3:33am | Post# 15

1 Attachment(s)
Next error message: ATR can not be initialesed, but this message only by new added charts
Click to Enlarge

Name: Screenshot1.png
Size: 278 KB

jansb000 Mar 7, 2019 8:39am | Post# 16

Next error message: ATR can not be initialesed, but this message only by new added charts {image}
Hi nschwegl,
thank you for testing this EA.

This is the code for initializing the indicators (ATR as an example).
Inserted Code
OnInit() {
   ...
   //+------------------------------------------------------------------+
   //| Average Daily Range 100                                          |
   //+------------------------------------------------------------------+
  
   atr.setup(isymbol, PERIOD_D1, 100);
   if (!atr.check_indi()) {
      Comment("ERROR: ATR can not be initialised !!");
      return(INIT_FAILED);
   }
   double lv_adr100 = atr.value(0);
   gADR100 = NormalizeDouble(val2pips(lv_adr100), 0);
   ...
}

I found that when I was programming an indicator earlier that during initialisation (OnInit) the indicator cannot be used until at least one tick has arrived.
So far I never had this problem in my EA so I thought it would be just a problem for indicators. so the new setup that I will program will be:
Inserted Code
OnIntit() {
  ...
  atr.setup(...);
  ...
}
 
OnTick() {
  static bool test_indi = false;
  if (!test_indi) {
    if (!atr.check_indi()) <error msg>;
    ...
    test_indi = true;
  }
}

I will have to change this for all indicators that I use in the EA. I will do this ASAP.
Cheers...

jansb000 Mar 8, 2019 6:10am | Post# 17

LRSF Expert Advisor v2.05 wip 2

I updated the Expert Advisor. Dowload this version in post #1.

  1. Testing of all indicators has moved from OnInit() to OnTick() as explained in post #16.
  2. When an order is opened without SL/TP the function do_manage() will try to add valid SL/TP values. When this happens the do_manage() will no longer try to also check for break even in the same tick(). So for single orders the logic is now like this:

  1. do_open() - Order creation
  2. do_manage() - Apply basic SL/TP (SL <> 0 and TP <> 0)
  3. do_manage() - Apply break-even (SL positive)
  4. do_manage() - Apply trailing SL (SL more positive)

Cheers...


jansb000 Mar 11, 2019 5:49am | Post# 18

LRSF Expert Advisor v2.05 wip 3

A small correction. The trends are now displayed correctly on the chart.
This means no change to the ENTRY-logic. It was just the display logic that had a problem.

Cheers...

jansb000 Mar 11, 2019 12:35pm | Post# 19

LRSF Expert Advisor v2.05 wip 4

A small but important correction. In function "symbol_apply_sltp()" I referenced Orders, but this should be Positions. This is a conversion error MT4-->MT5.
The function "symbol_apply_sltp()" get called when the EA has determined that there are several open positions and they need to have their SL and TP adjusted.

PS: In the current implementation, all open positions are set to the same SL and TP. The TP is chosen so that the average close-price of all positions will guarantee a small profit. In the future this will be a bit more advanced.

Cheers...

jansb000 Mar 13, 2019 9:32am | Post# 20

LRSF Expert Advisor v2.06 wip 1

Starting the next step in the development of this Expert Advisor:

  1. I changed the logic for entering a new trade. It is now looking for a trend (as indicated by all the activated trends in the input parameter) and for a signal from Heiken Ashi that a new sequence has started. This is not how Trading Made Simple works, but I decided to disable the other tests until I am happy with these two.
    The change to the logic of when to enter a new trade should solve a big problem that we had with the MT4 version, namely that we would miss lots of good opportunities.
  2. I added some logic that detects changes in the number of open positions and pending orders. This will automatically recalculate the MEME settings. This works even when one adds an order manually (using the scripts).

You can download this wip version in post #1.

Note: Do not use this version on a real account. It is not stable and it may blow your account.

Cheers...



© Forex Factory