| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Utility Procedures / Code Snippets https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=166 |
Page 2 of 7 |
| Author: | youcrazykids [ Tue Dec 27, 2011 7:08 pm ] |
| Post subject: | Re: Utility Procedures / Code Snippets |
Hi all Following the kind comments and suggestions by George (gaheitman), I've refined the on-chart indicator code, to make it a little more efficient. It draws everything once on startup, and only recalculates/redraws everything when the chart is altered by incoming data, such as a new bar or changes to the range. This turned out to be a good exercise, which improved my understanding of Empty4's lesser-used functions. Maybe it - or part of it - will prove useful. Code: Select all Thanks! youcrazykids [/size] |
|
| Author: | magft [ Sat Dec 31, 2011 8:30 am ] |
| Post subject: | Re: Utility Procedures / Code Snippets |
Here is a link to some code by 7-bit that is useful for debugging code, it removes the reliance on Print statements and use windows api and MS DebugView app to allow real-time logging of values not delayed like using Print and they are top to bottom. Hope it helps. Mike |
|
| Author: | gaheitman [ Sat Dec 31, 2011 2:50 pm ] |
| Post subject: | Re: Utility Procedures / Code Snippets |
This is great stuff, everyone who wants to write any code for Empty4 should read through all of 7-bit's code. For using DebugView, I wrote a procedure that checks to see if DebugView is running. It currently notifies the user that debug output will not be available, but you could easily change it to do nothing or to switch to old fashioned print statements. Code: Select all Code: Select all |
|
| Author: | dietcoke [ Mon Jan 02, 2012 9:43 pm ] |
| Post subject: | Re: Utility Procedures / Code Snippets |
I found this independently a few days ago and already I can't live without it, so I came here to post it and discovered I've been beaten to it |
|
| Author: | mbkennel [ Sun Jan 22, 2012 1:20 am ] |
| Post subject: | Re: Utility Procedures / Code Snippets |
I'll use this post of mine to point to some useful utility libraries procedures as the thread is pinned to the top. 1) Attempt to force download of historical data (up to 2048 bars per pair/timeframe) in a batch script. http://www.stevehopwoodforex.com/phpBB3 ... f=15&t=254 2) libGMT.h: Broker-independent time-routine: get local time & day of week in NYC,London,Tokyo in HHMM format, independent of server time, and with daylight saving adjustment. http://www.stevehopwoodforex.com/phpBB3 ... f=15&t=225 |
|
| Author: | gaheitman [ Tue Jan 31, 2012 11:04 am ] |
| Post subject: | Compound Logic Statements/Code Optimization |
I have been curious for some time about what optimization Empty4 does at runtime with regards to compound logic statements. For example, in this code: Code: Select all Code: Select all
Code: Select all Often this is no big deal, but in an indicator loop I was doing the following test up to 150 times for each bar on the chart: Code: Select all As an aside, functions that we call to test something shouldn't actually change anything. Those are called side-effects and they are bad. :> George |
|
| Author: | Dozer [ Tue Jan 31, 2012 3:51 pm ] |
| Post subject: | Re: Compound Logic Statements/Code Optimization |
Excellent optimization tip. Thanks for posting this info George. |
|
| Author: | gaheitman [ Tue Jan 31, 2012 5:03 pm ] |
| Post subject: | Expert Program Flow |
In my ongoing series of two messages What I have learned so far (some things are what I expected, some are not):
If you feel like playing, the EA is attached. George |
|
| Author: | gaheitman [ Thu Feb 02, 2012 7:23 pm ] |
| Post subject: | Infinite Loop |
Yesterday I had a silly logic error that caused my program to go into an infinite loop. There isn't much you can do when that happens but shut down Empty4. I wasn't able to get any of my debugging print() results either. So I added a time limit to my loop so that if it didn't finish after a certain time, it would still stop. Original code: Code: Select all Code: Select all Also, it's safe to leave this code in, should you forget. (I did George |
|
| Author: | gaheitman [ Fri Feb 03, 2012 11:18 am ] |
| Post subject: | Breaking out of good infinite loops |
In the dsugums thread there is a conversation about how to access the F7 functionality in the EA. The EA never leaves the start() procedure after the first tick arrives so that it can monitor prices for currencies that are not on the current chart. It's unfortunate that you can't work off ticks for any currency you want, but there you have it. If you are really interested in gaining control of the EA through live use of the F7 key, you can make the following changes. Option 1 This change will drop out of the infinite loop every 5 seconds. This goes against the purpose of the loop, since start() won't start again until the next tick arrives, so it may not be the best solution for this particular EA. in Start(), change Code: Select all Code: Select all This change requires calling a windows API function to see if you have pressed the F7 key. After saving your changes, the EA waits until the next tick arrives, but then stays in the infinite loop again. Above "int Start()" insert Code: Select all Next, change the loop code to be: Code: Select all George |
|
| All times are UTC | Page 2 of 7 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|