Does anyone know how to code a function that would make the program wait for candle close and then continue? Thanks in advance.
Does anyone know how to code a function that would make the program wait for candle close and then continue?
- plzz convert this indicator to expert adviser
- Please Programme this GUPPY MMA Indicator
- time specific code
GreenPoint:
Does anyone know how to code a function that would make the program wait for candle close and then continue?
"wait" at what point ? it's very easy to return early on from start() just by checking the time of the candle . . . but it is actually impossible to detect the close of a candle . . you can detect the start of a candle though.
Does anyone know how to code a function that would make the program wait for candle close and then continue?
This function has been circulating around here for a while.
/** * Checks if the bar has closed * @param int timeframe * @param bool reset */ bool IsBarClosed(int timeframe,bool reset) { static datetime lastbartime; if(timeframe==-1) { if(reset) lastbartime=0; else lastbartime=iTime(NULL,timeframe,0); return(true); } if(iTime(NULL,timeframe,0)==lastbartime) // wait for new bar return(false); if(reset) lastbartime=iTime(NULL,timeframe,0); return(true); }
I assume timefame would be 1,5,15,30,60,240. But what is bool reset? Thanks.
flaab:
This function has been circulating around here for a while.
Which I don't like because you can only call it once per tick. It fails if you call it more than once per tick and people tend to do that with function calls. Simpler:This function has been circulating around here for a while.
int start(){ static datetime Time0; if (Time0 == Time[0]) return(0); : Time0 = Time[0]; // \ Do this whenever you want to return(0); // / wait for a new bar.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register