- Reading via iCustom does not run the indicator, all it does is read out the buffers.
- You must have the indicator running on two different charts, or one with non-default parameters, and one with default parameters (iCustom.)
- Reading via iCustom does not run the indicator, all it does is read out the buffers.
- You must have the indicator running on two different charts, or one with non-default parameters, and one with default parameters (iCustom.)
Actually, reading via iCustom runs the OnCalculate() method every time, and its first call (with unique parameters) runs OnInit() before the OnCalculate.
BTW, why do you so often use the obsolete event methods naming, while the Documentation has been describing the newer ones for nearly two years?
Ovo: Actually, reading via iCustom runs the OnCalculate() method every time,
| Where do you get that?
Tick comes in, Indicators get called. EA gets called and calls iCustom. Why don't you try, move your indicator's Alert outside the once per bar and you'll see OnCalculate without any iCustom. or try: OnTick(){ Print("EA sleeping"); sleep(10000); Print("EA iCustom"); ... iCustom() Print("EA done"); |
Ovo: Actually, reading via iCustom runs the OnCalculate() method every time, | Where do you get that?
Tick comes in, Indicators get called. EA gets called and calls iCustom. Why don't you try, move your indicator's Alert outside the once per bar and you'll see OnCalculate without any iCustom. or try: |
I am afraid I have a different Terminal than you have, as I could not see OnCalculate() call without iCustom. Perhaps you should follow your advice and try the things out.
Ovo: I am afraid I have a different Terminal than you have, as I could not see OnCalculate() call without iCustom. Perhaps you should follow your advice and try the things out.
| Perhaps you should follow your own advice before posting. If you only call iCustom, it calls onCalc once. If you attach it to a chart, it calls onCalc per tick. You have two indicators running. |
Indicator | EA |
---|---|
void OnTick() { Print("ea ontick"); Sleep(10000); Print("ea iCustom"); iCustom(NULL,0, "test",0,0); Print("ea iCustom end"); } | 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("indicator ontick"); return(rates_total); } |
iCustom only | On chart and iCustom |
---|---|
2015.07.07 13:48:47.926 Expert test EURUSD,H1: removed 2015.07.07 13:48:47.926 Custom indicator test EURUSD,H1: removed 2015.07.07 13:48:47.926 test EURUSD,H1: uninit reason 1 2015.07.07 13:48:47.924 test EURUSD,H1: uninit reason 1 2015.07.07 13:48:14.165 test EURUSD,H1: ea iCustom end 2015.07.07 13:48:14.165 test EURUSD,H1: indicator ontick 2015.07.07 13:48:14.165 test EURUSD,H1: ea iCustom 2015.07.07 13:48:04.151 test EURUSD,H1: ea ontick 2015.07.07 13:48:04.151 test EURUSD,H1: ea iCustom end 2015.07.07 13:48:04.150 test EURUSD,H1: indicator ontick 2015.07.07 13:48:04.150 test EURUSD,H1: initialized 2015.07.07 13:48:04.146 Custom indicator test EURUSD,H1: loaded successfully 2015.07.07 13:48:04.140 test EURUSD,H1: ea iCustom 2015.07.07 13:47:54.117 test EURUSD,H1: ea ontick 2015.07.07 13:47:52.034 test EURUSD,H1: initialized 2015.07.07 13:47:50.038 Expert test EURUSD,H1: loaded successfully | 2015.07.07 13:18:23.160 Custom indicator test EURUSD,H1: removed 2015.07.07 13:18:23.160 test EURUSD,H1: uninit reason 1 2015.07.07 13:18:23.044 test EURUSD,H1: indicator ontick 2015.07.07 13:18:14.404 test EURUSD,H1: indicator ontick 2015.07.07 13:18:12.411 Expert test EURUSD,H1: removed 2015.07.07 13:18:12.411 Custom indicator test EURUSD,H1: removed 2015.07.07 13:18:12.411 test EURUSD,H1: uninit reason 1 2015.07.07 13:18:12.407 test EURUSD,H1: uninit reason 1 2015.07.07 13:18:12.407 test EURUSD,H1: ea iCustom end 2015.07.07 13:18:12.407 test EURUSD,H1: indicator ontick 2015.07.07 13:18:12.407 test EURUSD,H1: ea iCustom 2015.07.07 13:18:11.034 test EURUSD,H1: indicator ontick 2015.07.07 13:18:05.776 test EURUSD,H1: indicator ontick 2015.07.07 13:18:05.605 test EURUSD,H1: indicator ontick 2015.07.07 13:18:05.590 test EURUSD,H1: ea ontick 2015.07.07 13:18:05.590 test EURUSD,H1: ea iCustom end 2015.07.07 13:18:05.590 test EURUSD,H1: indicator ontick 2015.07.07 13:18:05.590 test EURUSD,H1: initialized 2015.07.07 13:18:05.587 Custom indicator test EURUSD,H1: loaded successfully 2015.07.07 13:18:05.582 test EURUSD,H1: ea iCustom 2015.07.07 13:18:03.857 test EURUSD,H1: indicator ontick 2015.07.07 13:17:55.637 test EURUSD,H1: indicator ontick 2015.07.07 13:17:55.563 test EURUSD,H1: ea ontick 2015.07.07 13:17:55.561 test EURUSD,H1: indicator ontick 2015.07.07 13:17:53.349 test EURUSD,H1: indicator ontick 2015.07.07 13:17:53.260 test EURUSD,H1: indicator ontick 2015.07.07 13:17:53.147 test EURUSD,H1: indicator ontick 2015.07.07 13:17:52.221 Expert test EURUSD,H1: loaded successfully 2015.07.07 13:17:44.593 test EURUSD,H1: indicator ontick 2015.07.07 13:17:44.593 test EURUSD,H1: initialized 2015.07.07 13:17:41.455 Custom indicator test EURUSD,H1: loaded successfully |
Ovo: Actually, reading via iCustom runs the OnCalculate() method every time, | Where do you get that? ........ ........
|
Using your words, which part of the previous communication was unclear?
Ovo: Using your words, which part of the previous communication was unclear?
| as I could not see OnCalculate() call without iCustom is wrong. I showed where OnCalculate is called per tick as I showed.
|
Ok, once more, from the beginning:
- Reading via iCustom does not run the indicator, all it does is read out the buffers.
- You must have the indicator running on two different charts, or one with non-default parameters, and one with default parameters (iCustom.)
Actually, reading via iCustom runs the OnCalculate() method every time, and its first call (with unique parameters) runs OnInit() before the OnCalculate.
Ovo: Actually, reading via iCustom runs the OnCalculate() method every time, | Where do you get that?
|
I am afraid I have a different Terminal than you have, as I could not see OnCalculate() call without iCustom. Perhaps you should follow your advice and try the things out.
if(Time[0]!=time0) { time0=Time[0]; // RUN ONCE PER BAR return(0); // DO INDICATOR STUFF }try that
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm sure it's out there, but I have not found a discussion of this:
Brief: The Custom Indicator runs twice each bar, once on it's own and again when referenced in the EA. Is this a necessary behavior or am I doing something fundamentally wrong?
Detail, as short as I can make it:
1. Here's a Custom Indicator:
2. Here's an EA referencing the CI:
• When I compile the CI, it runs once, I see the Alert once.
• When I compile the EA, the CI runs once, I see the Alert once. The EA referencing the CI apparently recompiles the CI, as the var time0 in the CI resets.
• But when a new Bar comes along, the CI runs twice, the Alert appears twice. It appears to run once on it's own and a second time per the EA.
Q: What am I doing wrong here? Is there a way to tell the EA to just read what the CI has already put in the buffer and not rerun the CI?