Forex Zone - Forex Forum

Adding Delay to your EA

Discussion started on MT4 / MT5 EAs

  • Newbie
  • Posts: 32
  • Points: 0
  • Likes Received: 4
  • Reputation: +2/-0
Hi Coders (CrazyProg)
I am currently having an EA coded but while that is going on (not yet concluded) I have been reading around the web to check the wisdom of going the EA route at all. From everything I have read so far - the chances of coming up with a profitable EA in the live environment tends toward zero due all sorts of issues and especially the difference between the EA testing environment and the live trading environment - which means there is no reliable means of judging the potential of my EA currently in the works. However, I discovered this site with some advice on reconciling the two environments to be close and therefore allow prediction of performance to some extent. My interest is on the question of adding delay to the EA - here is a quote about this on the site: "In the simulator, delay is not importance and serve as a pause while executing in back testing mode. But to live trading is actually waiting for price changes in the live server and serve as a delay task for trade opening at server side. The historical data is stored in smallest data of 1 minute interval and a delay of 1 or 2 minutes will help live data server to execute with similar results as back testing." My questions for help are as follows: a) Is the above statement correct? Partly correct? or correct with qualifications? - which is it and how and why? (I do not have any coding knowledge)b) If this will help as suggested how should I describe this to my coder in order to get him to add the required delay?c) In fact what the hell is this all about and what difference would it make to the prospects of a better EA or at least one that mirrors results live close to test results?I shall be most grateful for a basic explanation on this topic (bearing in mind I know nothing really about coding) but I want to do whatever I can to improve the chances of my EA once I take delivery or before I do. Thank you all,
TM

Linkback: https://www.forex.zone/mt4-mt5-eas/7/adding-delay-to-your-ea/92/
#1 - July 12, 2018, 11:35:50 AM
« Last Edit: July 28, 2019, 02:27:38 PM by Admin »

Administrator
  • Hero Member
  • Posts: 4731
  • Points: 34628
  • Likes Received: 4838
  • Reputation: +220/-14

a) It is partly correct. There is indeed a 1 minute limitation for data in the back tester. The smallest TF available in Metatrader is the M1. Which means almost all ticks generated in the back tester are interpolated. In other words, they are fake and do not represent the live tick-by-tick action that actually occurred at that time in the real market. However, that being the case, it is a meaningless action to intentionally introduce a delay feature into the EA for back testing. Why? First, it depends on the EA itself and it's strategy. For example, some EA's are based on price action and only open/close orders at the beginning of candles. In this case, the back tester results will be near accurate since an EA can get accurate values at those specific times no problem and it will not be using values during fake ticks. Secondly, let's say a delay would be introduced only for back testing. That still would not solve other issues. For example, the back tester uses a set spread instead of a dynamic spread as is usually the case with most brokers. The back tester doesn't have other issues that can occur during live trading such as trade context being busy and internet connection issues. Also, the back tester doesn't use dynamic stop level distances as some brokers do. For example, during normal market conditions, a TP/SL of 2 pips might be accepted, but during volatile times a TP/SL of 2 pips would be rejected. And there are other things too that the back tester doesn't account for. To summarize, introducing a delay would cause back test results to mismatch live results even more. It would be counterproductive. Not only that, but it would be a complete waste of time. You could just increase the spread in the back tester to a spread higher than typically normal. It would accomplish similar results as would using a delay. The back tester is only meant for general testing purposes. Plain and simple.


b) Explaining this to a coder is simple. Just say add a delay into the EA for back testing. For example, if an order signal is generated at 15:55:42, instead of placing the order right away, have the EA wait until actually 15:57:42 to place the order.


c) It is a waste of time as explained above. It accomplishes nothing other than giving you results that will mismatch live results even more. In my opinion, the only value to the article you are referring to is the amount of coding orders that website probably generated by people reading it and asking for their EA to have a delay added!
#2 - July 12, 2018, 12:44:52 PM

  • Newbie
  • Posts: 32
  • Points: 0
  • Likes Received: 4
  • Reputation: +2/-0


c) It is a waste of time as explained above. It accomplishes nothing other than giving you results that will mismatch live results even more. In my opinion, the only value to the article you are referring to is the amount of coding orders that website probably generated by people reading it and asking for their EA to have a delay added!
Ok great but how about adding a delay to the EA itself - (not for back testing but for live trading) does that in your opinion add anything to improve the EA? Thanks in advance, your answer so far has been simple, direct and clear. But my intention is with reference to having the coder add a delay to my EA for live trading (I am having the EA coded not buying from the site). MY EA specifies entry on the change of a basic indicator from buy to sell or from sell to buy and I also intend to trade on an ECN (to avoid some of the delays you point out and on VPS to eliminate as much as is possible issues of internet connectivity). Will those help in your opinion and should I therefore ignore adding a delay for live trading (not for back testing). Thanks so much.
TM
#3 - July 12, 2018, 01:09:02 PM

Administrator
  • Hero Member
  • Posts: 4731
  • Points: 34628
  • Likes Received: 4838
  • Reputation: +220/-14
Ok great but how about adding a delay to the EA itself - (not for back testing but for live trading) does that in your opinion add anything to improve the EA?

I was actually talking about adding the delay to the EA itself. It would be in it's code, but would only work during back testing. It is still a change to the EA itself though.

The article has some English that is unclear, but I interpreted the article to mean that back testing would have the delay. For example:

"I will explain some factors which will help the backtest results to be comparable to live result"



But my intention is with reference to having the coder add a delay to my EA for live trading (I am having the EA coded not buying from the site). MY EA specifies entry on the change of a basic indicator from buy to sell or from sell to buy and I also intend to trade on an ECN (to avoid some of the delays you point out and on VPS to eliminate as much as is possible issues of internet connectivity). Will those help in your opinion and should I therefore ignore adding a delay for live trading (not for back testing).
To be honest, adding a delay to live trading makes even less sense to me. Especially when indicators are involved. It is already hard enough to make profit with indicators as it is. For example, if you consider most indicators repaint or give lagging signals. I don't understand why someone would want to make it even harder to make profit by getting an order signal from indicators and then waiting even longer to act on it.


About using ECN and VPS, this may help, but there will always be problems of some sort sooner or later. If not from your side, then from your broker's side. The point I was trying to make is that back testing is only for general testing and there will be reasons results will not match. No matter what.


What makes sense to me would be making a back test reflect as close to possible the results that a live trading test would make, but not making live testing results match the results a back test would make. Your delay in live trading seems to be an effort to make live trading results match back test results, which to me doesn't make sense. Unless an EA's strategy is strictly time based, I see no reason why introducing a time delay into an EA for live trading would be worth the effort.
#4 - July 12, 2018, 02:04:35 PM

  • Newbie
  • Posts: 32
  • Points: 0
  • Likes Received: 4
  • Reputation: +2/-0
 Thank you so very much sir - I guess you have educated me thoroughly on the matter and I take your good advice and let the matter rest once and for all. I am sure there are no options for cutting lags in indicator signals or speeding them up or you would have mentioned. But be that as it may - this forum is most useful and your help very much appreciated - thank you and all the best always.


TM
#5 - July 12, 2018, 03:37:05 PM

Administrator
  • Hero Member
  • Posts: 4731
  • Points: 34628
  • Likes Received: 4838
  • Reputation: +220/-14
Thank you so very much sir - I guess you have educated me thoroughly on the matter and I take your good advice and let the matter rest once and for all. I am sure there are no options for cutting lags in indicator signals or speeding them up or you would have mentioned. But be that as it may - this forum is most useful and your help very much appreciated - thank you and all the best always.


TM
Sure, no problem. I hope that all made sense. About the indicator lags and speeding them up, it depends on the specific indicator. That is another topic though. I just wanted to explain why introducing a delay, especially in live trading, doesn't make much sense. Unless of course the strategy is based strictly on time. That's just my opinion though. If you do get that done and it was worth it, please come back and let us know.
#6 - July 12, 2018, 04:00:12 PM

  • Full Member
  • Posts: 244
  • Points: 363
  • Likes Received: 140
  • Reputation: +16/-1
I completely agree with Admin. In addition, using a delay in real trading, in most cases, can worsen the result. Because the chance to get the worst price increases.
#7 - July 12, 2018, 05:20:04 PM

  • Newbie
  • Posts: 32
  • Points: 0
  • Likes Received: 4
  • Reputation: +2/-0
Thank you so very much sir - I guess you have educated me thoroughly on the matter and I take your good advice and let the matter rest once and for all. I am sure there are no options for cutting lags in indicator signals or speeding them up or you would have mentioned. But be that as it may - this forum is most useful and your help very much appreciated - thank you and all the best always.


TM
Sure, no problem. I hope that all made sense. About the indicator lags and speeding them up, it depends on the specific indicator. That is another topic though. I just wanted to explain why introducing a delay, especially in live trading, doesn't make much sense. Unless of course the strategy is based strictly on time. That's just my opinion though. If you do get that done and it was worth it, please come back and let us know.

I am back again - still on delays but this time I seek direct insight. I have a manual trading tool - a panel indicator and I depend on this tool to trade - using two specific signals. Now of late and due illness I cannot be there a lot of the time and sometimes I get trade setups outside my waking time etc. So this is my question - since in fact if I were around at such times I will still trade exactly those signals at definite points - if I asked my EA program to simply trigger trades based on my panel indicator signals should I expect any delays in execution and or other asynchronous behaviour between the two programs? And in broad speak why would such an arrangement not trade exactly alike? Both are computer programs and one just triggers the other? Or is it better to more directly code the same behaviour into the EA rather than have the behaviours desired triggered by my panel indicator signals? For instance some MQL recognized indicator such as the Chaos Semaphore appears and if following that appearance a volatility band indicator signals a change in direction I would on those visuals enter spot (and I might add, with little inconvenience on an ECN - so the question is would there be any reasons why an EA doing exactly that on my behalf, should not trade with the same convenience or more?

Will be glad to know this - thank you.

TM
#8 - July 18, 2018, 06:57:21 PM
« Last Edit: July 19, 2018, 11:29:22 AM by The Magician »

  • Newbie
  • Posts: 32
  • Points: 0
  • Likes Received: 4
  • Reputation: +2/-0
I completely agree with Admin. In addition, using a delay in real trading, in most cases, can worsen the result. Because the chance to get the worst price increases.

Hey CrazyProg I just asked Admin a question and I like it when you weigh in - gives the forum a real good feel. Cheers

TM
#9 - July 18, 2018, 07:02:10 PM
« Last Edit: July 18, 2018, 09:29:58 PM by Admin »

Administrator
  • Hero Member
  • Posts: 4731
  • Points: 34628
  • Likes Received: 4838
  • Reputation: +220/-14
Quote
if I asked my EA program to simply trigger trades based on my panel indicator signals should I expect any delays in execution and or other asynchronous behaviour between the two programs?
All the EA would be doing is reading the chart objects displayed from the panel indicator or else importing from that indicator and then placing trades just as you would manually. So no, you should not expect any noticable delays. No more delays than it would take you to physically move your mouse, click a button, and set the order manually. The EA might even do it faster than you can manually.



Quote
And in broad speak why would such an arrangement not trade exactly alike? Both are computer programs and one just triggers the other? Or is it better to more directly code the same behaviour into the EA rather than have the behaviours desired triggered by my panel indicator signals?
I would rather see the panel indicator to understand exactly what you are talking about before I answer any of this.


Quote
so the question is would there be any reasons why an EA doing exactly that on my behalf, should not trade with the same convenience or more?
I see no reason.
#10 - July 19, 2018, 12:04:31 PM

  • Newbie
  • Posts: 32
  • Points: 0
  • Likes Received: 4
  • Reputation: +2/-0
Quote
if I asked my EA program to simply trigger trades based on my panel indicator signals should I expect any delays in execution and or other asynchronous behaviour between the two programs?
All the EA would be doing is reading the chart objects displayed from the panel indicator or else importing from that indicator and then placing trades just as you would manually. So no, you should not expect any noticable delays. No more delays than it would take you to physically move your mouse, click a button, and set the order manually. The EA might even do it faster than you can manually.



Quote
And in broad speak why would such an arrangement not trade exactly alike? Both are computer programs and one just triggers the other? Or is it better to more directly code the same behaviour into the EA rather than have the behaviours desired triggered by my panel indicator signals?
I would rather see the panel indicator to understand exactly what you are talking about before I answer any of this.


Quote
so the question is would there be any reasons why an EA doing exactly that on my behalf, should not trade with the same convenience or more?
I see no reason.
Thank you - to the point as usual. Lets see how things play - I have an interesting idea and we may yet have this coded right here. More for how this EA can show us a complete alternative to technical and fundamental (news) trading than anything else. But until then I remain humbled by the goodness here.

The Magician (-_-)
#11 - July 19, 2018, 01:01:21 PM
« Last Edit: July 19, 2018, 01:34:50 PM by Admin »

Administrator
  • Hero Member
  • Posts: 4731
  • Points: 34628
  • Likes Received: 4838
  • Reputation: +220/-14
Thank you - to the point as usual. Lets see how things play - I have an interesting idea and we may yet have this coded right here. More for how this EA can show us a complete alternative to technical and fundamental (news) trading than anything else. But until then I remain humbled by the goodness here.

The Magician (-_-)
Sure, no problem. Just a note, please use the preview button prior to posting. I noticed that your posts usually are not displaying correctly. For example, you are including your reply within someone else's quote. Your reply should be on the outside of a quote. Thank you:)
#12 - July 19, 2018, 01:37:17 PM

  • Newbie
  • Posts: 32
  • Points: 0
  • Likes Received: 4
  • Reputation: +2/-0
Thank you - to the point as usual. Lets see how things play - I have an interesting idea and we may yet have this coded right here. More for how this EA can show us a complete alternative to technical and fundamental (news) trading than anything else. But until then I remain humbled by the goodness here.

The Magician (-_-)
Sure, no problem. Just a note, please use the preview button prior to posting. I noticed that your posts usually are not displaying correctly. For example, you are including your reply within someone else's quote. Your reply should be on the outside of a quote. Thank you:)

Sure, now I think I got it
 
The Magician (-_-)
#13 - July 19, 2018, 10:28:06 PM

  • Newbie
  • Posts: 32
  • Points: 0
  • Likes Received: 4
  • Reputation: +2/-0
Thank you - to the point as usual. Lets see how things play - I have an interesting idea and we may yet have this coded right here. More for how this EA can show us a complete alternative to technical and fundamental (news) trading than anything else. But until then I remain humbled by the goodness here.

The Magician (-_-)
Sure, no problem. Just a note, please use the preview button prior to posting. I noticed that your posts usually are not displaying correctly. For example, you are including your reply within someone else's quote. Your reply should be on the outside of a quote. Thank you:)
Hi Admin,

Here (attached) is a picture and I was wondering what I might learn from you about this. As can be seen, this difference in visual and EA signals is greater than the so called 2 bar delay rule (where because the zero bar data might change the EA may not or does not execute the visual signal until the next bar after the zero bar). So is this (the gap in the screenshot) normal? What can a coder do to "correct" this situation. Because clearly even with a very good strategy such entry misnomers would destroy capital faster than human trading. And can we say computer programs are faster more accurate than humans with this sort of gap in entry? BTW I see this in tools other than that in picture and also EABuilder code (which is supposed to be error free) generates exactly such entries causing losses. Thanks in advance.

The Magician (-_-)

PS: The EA code in this case is supposed to match EA entry signal with visual signal exactly.
#14 - July 23, 2018, 09:36:44 AM
Attachments:
« Last Edit: July 23, 2018, 09:42:25 AM by The Magician »

Administrator
  • Hero Member
  • Posts: 4731
  • Points: 34628
  • Likes Received: 4838
  • Reputation: +220/-14
Here (attached) is a picture and I was wondering what I might learn from you about this. As can be seen, this difference in visual and EA signals is greater than the so called 2 bar delay rule (where because the zero bar data might change the EA may not or does not execute the visual signal until the next bar after the zero bar). So is this (the gap in the screenshot) normal? What can a coder do to "correct" this situation. Because clearly even with a very good strategy such entry misnomers would destroy capital faster than human trading. And can we say computer programs are faster more accurate than humans with this sort of gap in entry? BTW I see this in tools other than that in picture and also EABuilder code (which is supposed to be error free) generates exactly such entries causing losses. Thanks in advance.

The Magician (-_-)

PS: The EA code in this case is supposed to match EA entry signal with visual signal exactly.
I don't think I can answer your questions properly because I did not code this EA or have it's code. The big delay in this case can be an illusion simply because you can be looking at indicators that have repainted. It would be best to look at the indicators at the time of the order instead of showing a chart that has had a lot of time pass by already. So maybe the EA is working correctly and there is no large delay more than 2 candles. You can see whether or not your indicators repaint simply by back testing them. Record the values and colors and then let a few candles form. And so on. Then go back and check all the values and colors at those exact times. If they have changed, then your indicator repaints. You can also test them live on the 1 minute chart and see the same thing.
#15 - July 23, 2018, 01:13:12 PM

Members:

0 Members and 1 Guest are viewing this topic.