Strategy Tester shows zero results on my EA - SOLVED: Add #property tester_everytick_calculate to EA + indicator - page 2

 
Minions Labs:

What I meant with that is, since recent updates of MT5, at least, and for instance, for Brazil, the Currency Box keeps empty, and the Strategy Tester fails... I have to type - in my case BRL - in order to have it run properly... Maybe it is your case... You just have to check in what currency your Broker Signal is from...


;)

That's because if you trade PETR4 (for example), the profit currency is BRL. If you try USD, as your broker doesn't provide USDBRL conversion rate, the strategy tester is unable to calculate profit and so no trade appears.

That's why I suggested the OP to use USD, as Usa500 is I suppose using USD as profit currency. As it doesn't work, must be an other problem.

 
Admiral Thrawn:

ActivTrades, demo account. Just created a fresh demo account today, cause I thought it could have something to do with the old one soon running out in 3 days.

Usually, their demo servers are very reliable. What do you think could cause "my" ST to go crazy?


Btw. looks like it doesn't matter what settings I pick, all the same:


Unfortunately I can't get a demo account on ActivTrades ("not allowed for your country"). If you provide me a login/password, I will check, otherwise I can't help.
 

Yes, I noticed that bug, especially in the MetaEditor -> Extras -> Options. There the currency selection always falls back to USD.

My demo account with the broker is in EUR currency. I'm pretty sure that last update (which was how long ago? A month or more?) did not have any impact on my simulations (and I was very busy with those). I have 4 machines working in parallel while one of them is nonstop daytrading.

It all started like 2-3 days ago and I dont know why..

 
Sounds great, Alain. I'll PM you directly.
 
Admiral Thrawn:
Sounds great, Alain. I'll PM you directly.

Did you try a simple backtesting ?

I tried ExpertMACD.ex5 on Usa500, and it doesn't trade because there are always an error :

2019.01.09 17:21:48.918    Core 1    2018.11.07 08:14:00   CTrade::OrderSend: market sell 0.01 Usa500 sl: 2761.45 tp: 2760.75 [invalid stops]

On EURUSD it works.

EDIT: With one of my EA (well coded ;-) it takes trades without problem on Usa500

2019.01.09 17:28:57.792    Core 1    2018.11.08 23:59:59   order performed buy 0.10 at 2805.52 [#11 buy 0.10 Usa500 at 2805.52]
2019.01.09 17:28:57.792    Core 1    final balance 10243.34 EUR

 

Yes, I can confirm the invalid stops here. Thanks for looking into it!

I guess, I should check out which of the single runs of my own EA (that lead to the ST to utterly fail) is having some error then.

Thank you again!

 
It looks like your chart history is empty:
History Usa500: load 27 bytes of history data to synchronize in 0:00:00.000
So the strategy tester is not able to generate sufficient ticks for the test. By default, if you do a optimization run, results with negative outcome will be discarded. This is why sometimes you don't get any results at all, because all of them were negative or empty (no trades). You may need to assure the chart has enough data to run a test. HTH
 

Quick update: My EA seems to have some issue with updating Global Variables, but only in that "optimization mode" of the ST. The GVs are properly updated during a single Strategy Tester run. Very weird.

Sadly, in that "optimization mode" no logs are printed within OnTick() or OnCalculate(..) regarding the employed indicator. The only debug messages seem to occur during OnInit() and OnDeinit(). Well, this is quite some challenge now.


Regarding your hint @lippmaje:

On my machine that runs the EA nonstop (currently with outdated sources) the Strategy Tester works fine and the log shows the history of Usa500 having so few bytes there, as well. interestingly, the time for synchronization is not 0:00:00.000. Hmmmm...


NP      0       07:25:58.918    Startup MetaTester 5 x64 build 1940 (02 Nov 2018)
HD      0       07:25:58.926    Server  MetaTester 5 started on 127.0.0.1:3000
PO      0       07:25:58.926    Startup initialization finished
NM      0       07:25:59.647    127.0.0.1       login (build 1940)
HK      0       07:25:59.742    Network 3860 bytes of account info loaded
KM      0       07:25:59.742    Network 1482 bytes of tester parameters loaded
GH      0       07:25:59.742    Network 27836 bytes of input parameters loaded
MR      0       07:25:59.746    Network 5059 bytes of symbols list loaded
IH      0       07:25:59.749    Tester  expert file added: Experts\Advisors\OPATraders\OPA1Trader.ex5. 540016 bytes loaded
MF      0       07:25:59.749    Tester  program file added: Indicators\VIX_Indicator\VIX_Indicator.ex5. 27292 bytes loaded
HO      0       07:25:59.749    Tester  program file added: Indicators\OptimisticPessimisticArea\OPAIndicator.ex5. 142389 bytes loaded
NP      0       07:25:59.749    Network 37968 bytes of optimized inputs info loaded
CI      0       07:25:59.755    Tester  successfully initialized
JL      0       07:25:59.755    Network 718 Kb of total initialization data received
HE      0       07:25:59.755    Tester  Intel Core i5-5300U  @ 2.30GHz, 16259 MB
NN      0       07:25:59.756    Tester  optimization pass 0 started (batch of 3 tasks)
JD      0       07:25:59.818    Symbols Usa500: symbol to be synchronized
CL      0       07:25:59.818    Symbols Usa500: symbol synchronized, 3864 bytes of symbol info received
DR      0       07:25:59.849    History Usa500: load 27 bytes of history data to synchronize in 0:00:00.016
LG      0       07:25:59.849    History Usa500: history synchronized from 2017.04.03 to 2018.02.01
RJ      3       07:25:59.851    Tester  Usa500: start time changed to 2017.04.08 00:00 to provide data at beginning
KN      0       07:25:59.851    History Usa500,H1: history cache allocated for 13062 bars and contains 115 bars from 2017.04.03 00:00 to 2017.04.07 22:00
FS      0       07:25:59.851    History Usa500,H1: history begins from 2017.04.03 00:00
GG      0       07:25:59.938    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   Execution mode: SYMBOL_TRADE_EXECUTION_REQUEST
GF      0       07:25:59.938    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   The account of the client <....>
FM      0       07:25:59.938    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   Account currency - EUR, MarginCall and StopOut levels are set in  percentage
HL      0       07:25:59.938    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   MarginCall=70, StopOut=50
DL      0       07:25:59.938    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   Using regular Trailing stop loss mechanism.
DD      0       07:25:59.943    Symbols UsaVixJan19: symbol to be synchronized
CP      0       07:25:59.943    Symbols UsaVixJan19: symbol synchronized, 3464 bytes of symbol info received
GM      0       07:25:59.962    History UsaVixJan19: load 37 bytes of history data to synchronize in 0:00:00.016
QE      0       07:25:59.962    History UsaVixJan19: history synchronized from 2016.01.04 to 2018.02.01
NK      0       07:26:00.063    VIX_Indicator (UsaVixJan19,H1)  2017.04.08 00:00:00   [VIX-Indicator:] Initializing on period H1
QF      0       07:26:00.067    History UsaVixJan19,H1: history cache allocated for 13062 bars and contains 1229 bars from 2016.01.04 00:00 to 2017.04.07 22:00
QH      0       07:26:00.067    History UsaVixJan19,H1: history begins from 2016.01.04 00:00
RL      0       07:26:00.186    OPAIndicator (Usa500,H1)        2017.04.08 00:00:00   OPA-Indicator successfully initialized.
LR      0       07:26:00.186    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   Initializing indicator 'MovingAverage' on period H1
NL      0       07:26:00.186    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   Execution mode: SYMBOL_TRADE_EXECUTION_REQUEST
CE      0       07:26:00.186    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   The account of the client <.....>
JR      0       07:26:00.186    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   Account currency - EUR, MarginCall and StopOut levels are set in  percentage
HO      0       07:26:00.186    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   MarginCall=70, StopOut=50
DM      0       07:26:00.186    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   Using regular Trailing stop loss mechanism.
RJ      0       07:26:00.186    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   Number of deals in position: 0
KI      0       07:26:00.186    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   Number of buy deals: 0
KP      0       07:26:00.186    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   Number of sell deals: 0
RL      0       07:26:00.186    OPA1Trader (Usa500,H1)  2017.04.08 00:00:00   Last deal in current position: 1970.01.01 00:00:00
FH      0       07:26:00.600    Symbols EURUSD: symbol to be synchronized
OQ      0       07:26:00.600    Symbols EURUSD: symbol synchronized, 3544 bytes of symbol info received
HQ      0       07:26:01.202    History EURUSD: load 27 bytes of history data to synchronize in 0:00:00.000
EF      0       07:26:01.202    History EURUSD: history synchronized from 2016.01.03 to 2018.02.01
HG      0       07:26:23.573    Tester  0 : passed in 0:00:23.765 (history synchronized in 0:00:00.609)
...
IH      0       07:26:45.455    Tester  1 : passed in 0:00:21.875
...
CJ      0       07:26:54.976    Tester  2 : passed in 0:00:09.500
...
CH      0       07:26:54.988    Tester  3 of 3 passes processed (3 successfully finished) in 0:00:55.140, history synchronized in 0:00:00.609
OD      3       07:26:54.999    127.0.0.1       MetaTester 5 forced to stop
HQ      0       07:32:22.866    Server  MetaTester 5 stopped
 

Found out that my signal indicator is only placing its signal (per bar) into a global variable (GV) when the strategy tester is being run in visualization mode.

When visualization is checked off and the ST is run either with a single parameter set or an array of parameters for optimization, the EA (OPA1Trader) only obtains zero values.

Technically I realized the communication between the OPA1Trader and the OPAIndicator via global variables. In my codebase, I cannot find any changes that could relate to the problem. So far, this mechanism has been working for over a year without a problem.


As you can see, when I start a single simulation (with visualization off, timespan: 2018.03.13 - 2018.03.23) the following logs show that a signal is properly computed until to the date where the simulation should actually start (March 13th); after that the indicator no more places its signal into a global variable. Again, when I use the strategy tester with visualization on the signals come properly and the bot is trading just fine.

QR      0       10:31:58.540    OPA1Trader (Usa500,H1)  2018.03.13 00:00:00   [OPA-1-EA:] Initializing OPA Global variable utility class with OPA indicator handle.
GL      0       10:31:58.540    OPA1Trader (Usa500,H1)  2018.03.13 00:00:00   Initializing OPA Global variable helper ...
JQ      0       10:31:58.540    OPA1Trader (Usa500,H1)  2018.03.13 00:00:00   ... with OPA indicator handle!
HG      0       10:31:58.569    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   [OPA1-Indicator:] Initializing on Symbol Usa500, Period H1.
GE      0       10:31:58.569    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   [OPA1-Indicator:] Initializing OPA Global variable utility class without OPA indicator handle.
ER      0       10:31:58.569    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   Initializing OPA Global variable helper ...
CF      0       10:31:58.569    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   ... without OPA indicator handle.
NH      0       10:31:58.569    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   [OPA1-Indicator:] Successfully initialized!
RG      0       10:31:58.569    OPA1Trader (Usa500,H1)  2018.03.13 00:00:00   ... Success. OPA indicator handle obtained.
KN      0       10:31:58.569    OPA1Trader (Usa500,H1)  2018.03.13 00:00:00   Initializing indicator 'MovingAverage' on period H1
NO      0       10:31:58.569    OPA1Trader (Usa500,H1)  2018.03.13 00:00:00   MA indicator successfully initialized.
PO      0       10:31:58.569    OPA1Trader (Usa500,H1)  2018.03.13 00:00:00   Initializing CandleSizeIndicator on period H1 for symbol 'Usa500'.
CK      0       10:31:58.589    OPA1Trader (Usa500,H1)  2018.03.13 00:00:00   [OPA-1-EA:] Successfully initialized.
QM      0       10:31:58.627    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   Setting GV signal: 0.0 for time: 2017.04.04 15:00
..      .       ............    ............  .........         ...................   .................................................
OE      0       10:31:58.627    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   Setting GV signal: 0.0 for time: 2017.04.07 14:00
RG      0       10:31:58.627    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   Setting GV signal: 1.0 for time: 2017.04.10 09:00
RF      0       10:31:58.627    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   Setting GV signal: 0.0 for time: 2017.04.10 11:00
..      .       ............    ............  .........         ...................   .................................................
HP      0       10:31:58.628    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   Setting GV signal: 0.0 for time: 2017.04.26 22:00
MR      0       10:31:58.628    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   Setting GV signal: 1.0 for time: 2017.04.27 07:00
..      .       ............    ............  .........         ...................   .................................................
FO      0       10:31:58.628    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   Setting GV signal: -1.0 for time: 2017.05.01 06:00
GP      0       10:31:58.628    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   Setting GV signal: 1.0 for time: 2017.05.02 05:00
FJ      0       10:31:58.628    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   Setting GV signal: 1.0 for time: 2017.05.02 13:00
..      .       ............    ............  .........         ...................   .................................................
DS      0       10:31:58.632    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   Setting GV signal: -1.0 for time: 2018.02.14 12:00
DL      0       10:31:58.632    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   Setting GV signal: 0.0 for time: 2018.02.14 14:00
..      .       ............    ............  .........         ...................   .................................................
KE      0       10:31:58.632    OPAIndicator (Usa500,H1)        2018.03.13 00:00:00   Setting GV signal: 0.0 for time: 2018.03.12 21:00
QR      0       10:31:58.638    OPA1Trader (Usa500,H1)  2018.03.13 01:00:00   Fetching GV signal: 0.0
GS      0       10:31:58.638    OPA1Trader (Usa500,H1)  2018.03.13 01:00:00   Received signal: 0.0
OF      0       10:31:58.638    OPA1Trader (Usa500,H1)  2018.03.13 01:00:00   Received timeOfSignal: 1970.01.01 00:00
EK      0       10:31:58.638    OPA1Trader (Usa500,H1)  2018.03.13 02:00:00   Fetching GV signal: 0.0
KR      0       10:31:58.638    OPA1Trader (Usa500,H1)  2018.03.13 02:00:00   Received signal: 0.0
DE      0       10:31:58.638    OPA1Trader (Usa500,H1)  2018.03.13 02:00:00   Received timeOfSignal: 1970.01.01 00:00
OF      0       10:31:58.639    OPA1Trader (Usa500,H1)  2018.03.13 03:00:00   Fetching GV signal: 0.0
IQ      0       10:31:58.639    OPA1Trader (Usa500,H1)  2018.03.13 03:00:00   Received signal: 0.0
NS      0       10:31:58.639    OPA1Trader (Usa500,H1)  2018.03.13 03:00:00   Received timeOfSignal: 1970.01.01 00:00
..      .       ............    ..........  .........   ...................   ........ ..............................
GS      0       10:31:58.690    OPA1Trader (Usa500,H1)  2018.03.22 21:00:00   Fetching GV signal: 0.0
KG      0       10:31:58.690    OPA1Trader (Usa500,H1)  2018.03.22 21:00:00   Received signal: 0.0
LH      0       10:31:58.690    OPA1Trader (Usa500,H1)  2018.03.22 21:00:00   Received timeOfSignal: 1970.01.01 00:00
KN      0       10:31:58.690    OPA1Trader (Usa500,H1)  2018.03.22 23:00:00   Fetching GV signal: 0.0
GP      0       10:31:58.690    OPA1Trader (Usa500,H1)  2018.03.22 23:00:00   Received signal: 0.0
DJ      0       10:31:58.690    OPA1Trader (Usa500,H1)  2018.03.22 23:00:00   Received timeOfSignal: 1970.01.01 00:00
FG      0       10:31:58.690    Tester  final balance 25000.00 EUR
JK      0       10:31:58.690    OPA1Trader (Usa500,H1)  2018.03.22 23:59:59   The 'OPA1Trader' program has been removed from the chart.
IG      0       10:31:58.690    OPA1Trader (Usa500,H1)  2018.03.22 23:59:59   [OPA-1-EA:] De-Initialization OPA1-Trader.

(the lines with "..." indicate that there are dozens more lines inbetween, all with similar values)


Did anyone of you have similar good/bad experiences with global variables? Did the last MQL5 update change something in this respect?

I can now go ahead and just fetch the signals with CopyBuffer, but I think during strategy tester there was a nasty delay of 1 additional bar. Correct me if I'm wrong here.


And again, thanks for any input. It is really nice to see how some friendly people seem to be here reguarly checking to help. Really, much appreciated :)

Cheers,

AT

 

Probably related to this :

MQL5: Added the new property for custom indicators #property tester_everytick_calculate. It is used in the strategy tester and allows for forced indicator calculation at each tick.

Add it to your EA. See documentation.
Reason: