Hi,
I wrote an indicator that just has to show some global variables.
So I deleted all the stuff of indicatorCounted() in start(), and therefore I want to give the indi.-buffers some initial values in init():
Well the buffers aren't 'filled' if I apply this indicator new to a chart??? Only after I open the edit-option-window of this indicator and press OK - then the values are set?
Even the Comment("Waiting for the next tick..") isn't shown - during the whole Sunday while the markets were closed!
But despite there was no tick (it was Sunday afternoon, about 4pm GMT!!) the Comment from start() was shown.
Somehow it is not what I expect. :(
I expect init() to be executed at the start of the indicator(), after: applying, change of options, compiling.
and start() to be executed after a tick..
But somehow it was mixed up??
gooly
Did you create the global variables?
Do you know that new comments overwrite the old comments?
Have you tried using Print() instead of Comment()?
Have you tried including the deinit() and putting Print() in there?
1) Well the global variables exist! As soon as I open the option-window and close with ok the buffers are filled and showen - but not before that.
2) I know old comments are overwritten, but there is no tick so why and how can the Comment of init() been overwritten by start().
My problem of understanding is:
A) why init() seems not to by started if the indicator is installed - only after I edit the options => shown by not drawn buffers
B) why start() is started yesterday, Sunday, while the markets are closed and the chart hasn't got any tick?
add to A) the while loop is not carried out - or may be the buffers are re initialized by whatever and the result of the loop was 'emptied' again, but where and why?
This behaviour would be hard to understand.
gooly
1) Well the global variables exist! As soon as I open the option-window and close with ok the buffers are filled and showen - but not before that.
2) I know old comments are overwritten, but there is no tick so why and how can the Comment of init() been overwritten by start().
My problem of understanding is:
A) why init() seems not to by started if the indicator is installed - only after I edit the options => shown by not drawn buffers
B) why start() is started yesterday, Sunday, while the markets are closed and the chart hasn't got any tick?
add to A) the while loop is not carried out - or may be the buffers are re initialized by whatever and the result of the loop was 'emptied' again, but where and why?
This behaviour would be hard to understand.
gooly
B) The start() is always ran Once when you attach an indicator to the chart (even if there are no ticks). This would overwrite your comment.
A) The init function must return quickly. Its not the place for doing huge loops. Maybe thats part of your problem. I'm sure the while loop would execute. Either its not shown in the buffer windows until ticks ... or your loop is too long.
B) start() ist started on installation without the presence of a tick only by indicators or an EAs too?
A) init() should be the perfect function for initializations in start I would need extra semaphores to be asked again and again and again..
But thanks ubzen!
gooly
B) Only happens with Indicators
A) Move your While loop into the start(). I just tested it and it doesn't like to assign buffers values (during the 1st Attach to chart).
Here this works allot better.
#property indicator_chart_window #property indicator_buffers 1 double xBuff1e[]; int init(){ SetIndexBuffer(0,xBuff1e); return(0); } int start(){ static bool Once; if(Once) return(0); if(!Once){InitializeMyBuffer();} Print("Start()................."); Once=true; return(0); } void InitializeMyBuffer(){ int i=5; while(i>0) {i--; double dValue=GlobalVariableGet("sGlbVarEqu1"); Print("dValue=",dValue); xBuff1e[i] = dValue; Print("i=",i,"__xBuff1e[i]=",xBuff1e[i]); } Print("Waiting for the next tick.."); }
- 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 wrote an indicator that just has to show some global variables.
So I deleted all the stuff of indicatorCounted() in start(), and therefore I want to give the indi.-buffers some initial values in init():
Well the buffers aren't 'filled' if I apply this indicator new to a chart??? Only after I open the edit-option-window of this indicator and press OK - then the values are set?
Even the Comment("Waiting for the next tick..") isn't shown - during the whole Sunday while the markets were closed!
But despite there was no tick (it was Sunday afternoon, about 4pm GMT!!) the Comment from start() was shown.
Somehow it is not what I expect. :(
I expect init() to be executed at the start of the indicator(), after: applying, change of options, compiling.
and start() to be executed after a tick..
But somehow it was mixed up??
gooly