Are EA cached?

 

I've searched this forum and the internet and I did not find any discussion that hints that EAs are cached. 

I am new to MQL programming and I am trying out a simple strategy to get my feet wet with how it works. I have a simple code that looks like the following:


 CTrade trade;
   if (buyNow) {
      trade.PositionOpen(_Symbol, ORDER_TYPE_BUY,1.0,ask,sl,tp,"MA");
   }
   if (sellNow) {
      trade.PositionOpen(_Symbol, ORDER_TYPE_SELL,1.0,bid,sl,tp,"MA");
   }

 The "sellNow" logic doesn't behave the way I expected it too. To isolate it and make sure that the opening of long positions has no issues, I removed it from the code such that there is only the if (buyNow) logic. However, when I run my code the Strategy Tester chart is still showing short positions. Now, I removed both conditions (buyNow and sellNow), compiled my code, and then tested it. I don't see both long and short positions on the chart, which is correct. I also tried compiling then closing the editor and my MT client and restarted everything. After testing my code the result is still the same.


What am I missing?

 
dinotrader15: I've searched this forum and the internet and I did not find any discussion that hints that EAs are cached. I am new to MQL programming and I am trying out a simple strategy to get my feet wet with how it works. I have a simple code that looks like the following: The "sellNow" logic doesn't behave the way I expected it too. To isolate it and make sure that the opening of long positions has no issues, I removed it from the code such that there is only the if (buyNow) logic. However, when I run my code the Strategy Tester chart is still showing short positions. Now, I removed both conditions (buyNow and sellNow), compiled my code, and then tested it. I don't see both long and short positions on the chart, which is correct. I also tried compiling then closing the editor and my MT client and restarted everything. After testing my code the result is still the same. What am I missing?

EAs are not cached but sometimes due certain conditions, EAs may be "stuck" in memory.

In those cases, simply closing the editor, terminal e maybe even deleting the offending ".ex?" file, will reset things.

Tester results however are cached, so you might as well clear those while you are resetting things ... "<data folder>/Tester/Cache".

 

Thanks for your reply.


I already tried deleting the .ex file and it did not help. I tried your suggestion of deleting the Tester/Cache folder even the logs (though sounds it doesn't matter) but doing so produces the same issue. What's interesting is if I delete both logic that Strategy Tester doesn't show any position opened. That indicates that the EA is being refreshed on each compile. But if leave only one logic, either Buy or Sell, both positions (long and short) show up on the chart. It doesn't matter which one I remove both will show up.

 
dinotrader15 #: Thanks for your reply. I already tried deleting the .ex file and it did not help. I tried your suggestion of deleting the Tester/Cache folder even the logs (though sounds it doesn't matter) but doing so produces the same issue. What's interesting is if I delete both logic that Strategy Tester doesn't show any position opened. That indicates that the EA is being refreshed on each compile. But if leave only one logic, either Buy or Sell, both positions (long and short) show up on the chart. It doesn't matter which one I remove both will show up.

The problem is probably in your code. To prove this, rename the source file and then recompile it. If the new name ".ex?" file still has the issue, then it is your code that is causing the problem.

 
I actually just did similar, I copied the entire script in a completely new file and compiled and ran it. Both logic seems to be working fine now. Thanks for you input, definitely pushed me in the right direction in troubleshooting.
 
dinotrader15 #: I actually just did similar, I copied the entire script in a completely new file and compiled and ran it. Both logic seems to be working fine now. Thanks for you input, definitely pushed me in the right direction in troubleshooting.

👍 You are welcome!