I made a simple custom indicator and I'm trying to use it in my EA. But there is a problem with loading values from indicator - iCustom always returns an empty value (tester, demo). When I show graph in EA tester, indicator is showed correct.
There is OnTick method from my EA:
static int SRStartArrowCounter = 0;
double SR_Low = iCustom(NULL, PERIOD_M15, "SR_Levels", 5, 30, 0, 0);
double SR_High = iCustom(NULL, PERIOD_M15, "SR_Levels", 5, 30, 1, 0);
double SR_Low_length = iCustom(NULL, PERIOD_M15, "SR_Levels", 5, 30, 6, 0);
double SR_High_length = iCustom(NULL, PERIOD_M15, "SR_Levels", 5, 30, 7, 0);
if ((SR_Low_length==5 && SR_High_length>=5) || (SR_High_length==5 && SR_Low_length>=5))
ObjectCreate("SRStartArrowCounter"+SRStartArrowCounter, OBJ_ARROW, 0, Time, SR_Low);
I attached a custom indicator and there is a screen:
Thanks for your answers and for your help.
Your EA calls values from the indicator for the current bar (zero). Attach your indicator to a chart you can see it doesn't do anything on the current bar.
Some of the levels do look quite accurate although a lot of them appear to be accurate after the fact.
Your indicator is fasely coded, this is not good because it will draw all the indicator at each tick :
start = prev_calculated - 1;// this is bar 1
for (int i=start; i<rates_total; i++) // from 1 to bars_total
It may work doing this :
start = prev_calculated;//
for (int i=start; i<2000; i++) // from 0 to 2000 bars
this is not true, but this :
Your indicator is fasely coded, this is not good because it will draw all the indicator at each bar.
So it's OK the indicator work fine, but that's why you don't have the 0 bar at iCustom as SDC told you, the indicator will draw all the indicator once par bar
And remember, as Métaquote says: take everything with a pinch of salt
Thanks for your answer, I quite remade indicator and it works (didn't return an empty value).
But there were others problems with getting indicator values into EA, so I integrate indicator calculation direct into EA. It was much more easier :)
Thanks for your answer, it helps me. At the end, I got inspired from example indicators and used this:
for (int i=start; i>=0; i--)
But as I wrote in my previous comment, I included indicator calculations directly into EA (not using iCustom) - looks like much easier solution :)