| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Execute a function call only once at the Daily Open https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=863 |
Page 1 of 1 |
| Author: | erickva [ Mon Oct 01, 2012 9:51 am ] |
| Post subject: | Execute a function call only once at the Daily Open |
Hi All, I am not very familiar with Empty4 and I am struggling to find a way to execute a function call once we have the start of a new Daily bar. I want to execute it only once. I can make it inside the start() and check if I have a new day, but would be a ridiculous loop for something that can probably be done in one line, by a more experienced Empty4 programmer. So, if someone can help with this one I will appreciate. Thanks, Erick |
|
| Author: | dietcoke [ Mon Oct 01, 2012 10:29 am ] |
| Post subject: | Re: Execute a function call only once at the Daily Open |
Eg. Code: Select all if (D1Bars != iTime(NULL, PERIOD_D1,0) ) { ... your code here } |
|
| Author: | erickva [ Mon Oct 01, 2012 10:48 am ] |
| Post subject: | Re: Execute a function call only once at the Daily Open |
Hi dietcoke, Thanks very much! Exactly what I was looking for! Guess I just have to update D1Bars anytime I go through my code, so it will run again next day, if it is inside the start(): D1Bars = iTime(NULL, PERIOD_D1,0); Thank you! Erick |
|
| Author: | gaheitman [ Mon Oct 01, 2012 10:51 am ] |
| Post subject: | Re: Execute a function call only once at the Daily Open |
Don't forget to set D1Bars = iTime(NULL, PERIOD_D1,0) within the loop. You'll probably also want to add a test to make sure you aren't starting your EA in the middle of the afternoon. What I've done in the past is check that TimeDay(iTime(NULL,PERIOD_M1,0)) != TimeDay(iTime(NULL,PERIOD_M1,1)). This makes sure that we've entered a new day, and will only trigger in the first minute of the day. George |
|
| Author: | erickva [ Mon Oct 01, 2012 11:04 am ] |
| Post subject: | Re: Execute a function call only once at the Daily Open |
Brilliant George, thanks a lot! |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|