Hello,
why does the follwing happen with two simple custom indicators.
Indicator 1:
Print("calc1") in OnCalculate
Indicator 2:
Print("calc2") in OnCalculate
When called in Strategytester (anny settings), each indicator works as expected.
But when indicator1 loads icustom("indicator2") in oninit, calc2 gets printed twice.
I did not include any code, since it should be faster to just code this in your own environment to confirm.
Any way to solve this problem.
So what?
"calc2" is printed twice on each tick:
2013.11.03 13:05:22 2013.07.01 00:05:01 calc2
2013.11.03 13:05:22 2013.07.01 00:05:01 calc2
2013.11.03 13:05:20 2013.07.01 00:05:00 calc2
2013.11.03 13:05:20 2013.07.01 00:05:00 calc2
2013.11.03 13:05:19 2013.07.01 00:03:59 calc2
2013.11.03 13:05:19 2013.07.01 00:03:59 calc2
2013.11.03 13:05:17 2013.07.01 00:02:59 calc2
2013.11.03 13:05:17 2013.07.01 00:02:59 calc2
If Indicator 2 is called direct, the output in tester is (and should be, in the first case):
2013.11.03 13:05:22 2013.07.01 00:05:01 calc2
2013.11.03 13:05:20 2013.07.01 00:05:00 calc2
2013.11.03 13:05:19 2013.07.01 00:03:59 calc2
2013.11.03 13:05:17 2013.07.01 00:02:59 calc2
look at the first, time column...
Indicator2:
#property copyright "Copyright 2013, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" #property indicator_separate_window //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping Print("init2"); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- //--- return value of prev_calculated for next call Print("calc2"); return(rates_total); }
Indicator1:
#property copyright "Copyright 2013, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" #property indicator_chart_window //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping iCustom(_Symbol,_Period,"indicator2"); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- Print("calc1"); //--- return value of prev_calculated for next call return(rates_total); }
Result:
2013.11.03 13:31:02 2013.01.02 00:05:12 calc1 2013.11.03 13:31:02 2013.01.02 00:05:12 calc2 2013.11.03 13:31:02 2013.01.02 00:05:12 calc2 2013.11.03 13:30:59 2013.01.02 00:05:09 calc1 2013.11.03 13:30:59 2013.01.02 00:05:09 calc2 2013.11.03 13:30:59 2013.01.02 00:05:09 calc2 2013.11.03 13:30:56 2013.01.02 00:05:06 calc1 2013.11.03 13:30:56 2013.01.02 00:05:06 calc2 2013.11.03 13:30:56 2013.01.02 00:05:06 calc2 2013.11.03 13:30:53 2013.01.02 00:05:03 calc1 2013.11.03 13:30:53 2013.01.02 00:05:03 calc2 2013.11.03 13:30:53 2013.01.02 00:05:03 calc2 2013.11.03 13:30:50 2013.01.02 00:05:00 calc1 2013.11.03 13:30:50 2013.01.02 00:05:00 calc2 2013.11.03 13:30:50 2013.01.02 00:05:00 calc2 2013.11.03 13:30:47 2013.01.01 00:00:00 calc1 2013.11.03 13:30:47 2013.01.01 00:00:00 calc2 2013.11.03 13:30:47 2013.01.01 00:00:00 calc2 2013.11.03 13:30:47 2013.01.01 00:00:00 init2
Indicator2:
Indicator1:
Result:
I confirm this behaviour. But still my first question remains : so what ?
If you think it's a problem you can report this to ServiceDesk.
He is talking about the Strategy Tester.
I confirm this behaviour. But still my first question remains : so what ?
If you think it's a problem you can report this to ServiceDesk.
- www.mql5.com
I confirm this behaviour. But still my first question remains : so what ?
The problem is, that i will have to redesign a big part of my ea.
Perhaps i do not see anything you see clear? But why do you think, this should not be a problem? It is not just a performance problem, but filtering out those false ticks (not sure if possible consitent), costs performance again.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
why does the follwing happen with two simple custom indicators.
Indicator 1:
Print("calc1") in OnCalculate
Indicator 2:
Print("calc2") in OnCalculate
When called in Strategytester (anny settings), each indicator works as expected.
But when indicator1 loads icustom("indicator2") in oninit, calc2 gets printed twice.
I did not include any code, since it should be faster to just code this in your own environment to confirm.
Any way to solve this problem.