Is trade context an issue when using technical indicators?

 
Suppose I am using an EA on a GBP/USD chart and another EA on a EUR/USD chart. I know if the EA's want to trade -- buy, sell, or close a trade-- the trade context has to be checked to insure there is no conflict. However, is this necessary when using techinal indicators? For example, if the EA on the GBP/USD chart needs the lastest RSI value using the iRSI technical indicator, does it need to check for trade context first in order to attain this information without possible conflict with the other EA which might simultaneously want the same RSI data?
 
forestmyopia wrote >>
Suppose I am using an EA on a GBP/USD chart and another EA on a EUR/USD chart. I know if the EA's want to trade -- buy, sell, or close a trade-- the trade context has to be checked to insure there is no conflict. However, is this necessary when using techinal indicators? For example, if the EA on the GBP/USD chart needs the lastest RSI value using the iRSI technical indicator, does it need to check for trade context first in order to attain this information without possible conflict with the other EA which might simultaneously want the same RSI data?

I'm not sure by what you mean by "the trade context has to be checked to ensure that there is no conflict". All EAs run in different threads and the only way in which they can possibly interact or have interdependency is by

  1. Looking at the list of open trades or history
  2. Looking at the account balance, equity etc
  3. Using global variables (as in the MT4 sense of GlobalVariableSet() etc)
  4. Reading/writing files to disk

So you can can two EAs on the same pair even, and the RSI that they each calculate is still unrelated.

Paul

http://paulsfxrandomwalk.blogspot.com/

 
phampton wrote >>

I'm not sure by what you mean by "the trade context has to be checked to ensure that there is no conflict". All EAs run in different threads and the only way in which they can possibly interact or have interdependency is by

  1. Looking at the list of open trades or history
  2. Looking at the account balance, equity etc
  3. Using global variables (as in the MT4 sense of GlobalVariableSet() etc)
  4. Reading/writing files to disk

So you can can two EAs on the same pair even, and the RSI that they each calculate is still unrelated.

Paul

http://paulsfxrandomwalk.blogspot.com/

When I say trade context I mean what is checked for when IsTradeAllowed or IsTradeContextBusy are used. I understand these functions are used to prevent 2 or more EA's trying to open or close a trade at the same time. But is this an issue when 2 or more EA's are using the same technical indicators to access the same market info?

 
forestmyopia wrote >>

When I say trade context I mean what is checked for when IsTradeAllowed or IsTradeContextBusy are used. I understand these functions are used to prevent 2 or more EA's trying to open or close a trade at the same time. But is this an issue when 2 or more EA's are using the same technical indicators to access the same market info?

Hi

If you want to prevent 146 errors it is best to check the trade context. However, if your trade signals are not typically generated at the end (or start) of bars, but "randomly" when a technical indicator reaches a specific value or crosses a line or whatever, the chances are that you will not generate 2 trade orders at the same time. So you are not likely to see 146 errors. It is up to you. If you run GetLastError() on the return of OdrderSend() being = -1 you should be able to see if you get 146 errors. you can then make a decision as to how to deal with it. A small delay (2 - 3 seconds with Sleep) and then try to place the order again may be sufficient.

I prefer to use the trade context process for all trades on all EAs no matter how they work. Acordingly I do not have trouble with 146 errors. Once you are there you need to come up with a solution for 130 errors. The trade context solution may cause delays in when your trades are placed and this may introduce 130 errors. As a minimum you should recalculate the the entry price after the trade context becomes available.

Good luck

whocares

 
phampton:

I'm not sure by what you mean by "the trade context has to be checked to ensure that there is no conflict". All EAs run in different threads

This is not correct.

Each terminal instance implements a single trading thread.

Therefore if you have 2 or more EAs (in separate charts) on 1 account, 1 MT4 instance, there is the potential for trading transactions to contend for use of the trading context and conflict with each other. In that case (if the EA behaviour leads to the potential for trading transactions to conflict), you will need to provide 146 error handling.

Another option (if EAs have similar trading patterns) is to run multiple accounts (multiple MT4 instances) with one EA in each. Then you will not encounter trade context busy (146) errors.

So in answer to your original question, it is only trading operations which give rise to this issue.


CB

 
cloudbreaker wrote >>

This is not correct.

Each terminal instance implements a single trading thread.

Therefore if you have 2 or more EAs (in separate charts) on 1 account, 1 MT4 instance, there is the potential for trading transactions to contend for use of the trading context and conflict with each other. In that case (if the EA behaviour leads to the potential for trading transactions to conflict), you will need to provide 146 error handling.

Another option (if EAs have similar trading patterns) is to run multiple accounts (multiple MT4 instances) with one EA in each. Then you will not encounter trade context busy (146) errors.

So in answer to your original question, it is only trading operations which give rise to this issue.

CB

Thanks for the info.

 
whocares wrote >>

Hi

If you want to prevent 146 errors it is best to check the trade context. However, if your trade signals are not typically generated at the end (or start) of bars, but "randomly" when a technical indicator reaches a specific value or crosses a line or whatever, the chances are that you will not generate 2 trade orders at the same time. So you are not likely to see 146 errors. It is up to you. If you run GetLastError() on the return of OdrderSend() being = -1 you should be able to see if you get 146 errors. you can then make a decision as to how to deal with it. A small delay (2 - 3 seconds with Sleep) and then try to place the order again may be sufficient.

I prefer to use the trade context process for all trades on all EAs no matter how they work. Acordingly I do not have trouble with 146 errors. Once you are there you need to come up with a solution for 130 errors. The trade context solution may cause delays in when your trades are placed and this may introduce 130 errors. As a minimum you should recalculate the the entry price after the trade context becomes available.

Good luck

whocares

Thanks. I will look into it.

Reason: