Sorry (New to EA code mistake) Just realised that when I tried to compile.
When I tried to split the files and comple I got end of bracket (block) problems to sort out so simplification got complicated for me!
I will leave it to the more experienced helpers.
Of course are the EA and the indicator in separates files. I jion the files for simplicity in attachment.
Embedding full indicator inside an EA is actually achieving the opposite. For one, the function for optimizing re-calculation 'IndicatorCounted()' doesn't work in EA. You'd have to emulate it. See this article.
And seeing your code I don't think you wanted/needed to do that. A once-off call to iCustom to know value of current or previous closed bar is usually enough. See other EAs in codebase to get some ideas.
Good luck.
double sT_5 = iCustom(NULL,0,"Heiken Ashi and TK1",Nbr_Periods,Multiplier,7,5); // this is sufficient without the full indicators double sT_4 = iCustom(NULL,0,"Heiken Ashi and TK1",Nbr_Periods,Multiplier,7,4); // copy-pasted above.
Clarification!!!!
I have implemented full indicator in "Heiken Ashi and TK1.mq4" (see second part of attachment) and in the EA "ADI_EA_14112010_1.mq4" (see first part of attachment) calls the indicator by iCustom(....).
I have not embedded indicator inside the EA (see right attachment).
Thank you for help!!!
Only comment was wrong, contents of indicators source code correct. I have corrected the comment. See above for attachment.
This is not the source of error!
I updated and improved the description.
Thank you for help!!!
if (c_altBars < Bars) { c_altBars = Bars;
This lines are probably meant for optimizing. But it's nowhere near it. Try using Time[0] to detect New Bar opening. Search for it.
I recommend reading the book & documentation. You would save yourself much trouble in the future, if you have solid understanding of program logic...

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have written a relatively complicated indicator (1.step haiken ashi calculation, 2.step supertrend). The indicator works correct.
Part of indicator listing with changeTrend[] buffer:
print: buffer7 (chnageTrend[]) from indicator (see 10.11.,22.9,20.8., ...)
chart with indicator (where: white line - buffer7)
I use the content of buffer7 in EA (indicator call by iCustom...) as trade trigger. Unfortunately, the content of buffer7 is wrong in the EA(see chart and i.e. alert for 10.11.10)
part of EA with buffer7[1] (changeTrend[1] in indicator - see above)
alert: buffer7 from EA
For full source see Attachment indicator: "Heiken Ashi and TK1.mql4" (name in attachment is wrong), EA: "ADI_EA_14112010_1.mql4".
Where is a bug?
Thank you for help!!!
Yours sincerely