[SOLVED] See picture below : How to refresh ICustom in EA automaticly, my Custom Indy need to refreshed when first attached

 

[IT's SOLVED]


The lower Sub windows returning error value because I didn't refresh it when attached.


Hi everyone...


I have this CI that need to be refreshed when first attached to the chart (refreshed by open it up and then close/attach it again - so it will return the correct value.


The problem is I'm gonna use it in EA and I'm worry and curious that when attached to the chart, the EA won't get the correct value from the CI, the EA get the CI value but the wrong one.


A friend of mind suggests me to reset the value of IndicatorCounted() through other variable every minute or so like this way :



datetime Current_Time;

int Counted_Bars, pos;


start

{

Counted_Bars = IndicatorCounted(); // Counted_Bars is equal with IndicatorCounted() func...


if (Current_Time != iTime(Symbol(), PERIOD_M5, 0); // ...however every 5 minutes....

{

Counted_Bars = 0; // ...the counted bars is zero/null/"refreshed"


Current_Time = iTime(Symbol(), PERIOD_M5, 0);

}


pos = Bars - Counted_Bars - 1;


while{pos >= 0)

{

// some indicator calculation


pos--;

}


I'm not sure this will work correctly in EA.

Beside I tried and don't like it. My CI is calculating all TF and displaying it on smaller TF. So recalculating everything will jeopardize every value.


So do you have any other idea ?.

 

That is the problem with some indicators...especially when using different time frames like you are.

You could try

WindowRedraw();

but I think this only works with objects, not indicators

 

Thanks for your respond JPS, and I just find the solution.

You see I only need data from bar 0, bar 1, and bar 2. So I make my CI send those data to GLOBAL VARIABLE, so then the EA can took/read the data from that GLOBAL VARIABLE.


This is not practical solution, since I have to attach my CI after attaching my EA - but it's the visual and acceptable solution since the I can see if the CI return correct value or not.


I shouldn't bother this forum cause sometime I finally found the answer my self.

 
onewithzachy:

I shouldn't bother this forum cause sometime I finally found the answer my self.

... and you share your found solution, so what is wrong to ask ? ;-)

 
meikel:

... and you share your found solution, so what is wrong to ask ? ;-)

Nothing wrong to ask...but you see this forum already jammed with the same question over and over (see it here : ***PLEASE SEARCH BEFORE POSTING*** ). I did search and re-search for my solution above but couldn't find it (or was I bore and impatient ?) so I started this topic. Well... what do you know, in less than a hour after I posted this topic I found the solution.

I think I was impatient with my problem and lazy enough to try to try to solve from different angle.

I just don't wanna jammed this good forum with repeated topic whom someone has asked before.
Reason: