How can I prevent saving/retrieving GVs during backtests?

 

Hi friends,

I've noticed when I use GVs in my code, They does save when I do backtest. How can I prevent saving and also retrieving GVs during backtest while they are permitted to save and retrieve in Live trading? Any idea?

 
HosseinKOGO:

Hi friends,

I've noticed when I use GVs in my code, They does save when I do backtest. How can I prevent saving and also retrieving GVs during backtest while they are permitted to save and retrieve in Live trading? Any idea?

check what mode it is running and and control from there

https://docs.mql4.com/check/istesting

https://docs.mql4.com/check/isvisualmode

https://docs.mql4.com/check/isoptimization


but if you require GVs but ignore them in testing will the testing results be valid...

IsTesting - Checkup - MQL4 Reference
IsTesting - Checkup - MQL4 Reference
  • docs.mql4.com
IsTesting - Checkup - MQL4 Reference
 
  1. Why do you care? Other than diagnostics during non-live/non-optimizer modes, you shouldn't be doing anything different.
  2. Test for it.
              Detect optimization mode programmatically - Expert Advisors - MQL5 programming forum (2020.05.15)