Multi 10:4 Trader EA
- slipshod
- Trader
- Posts: 404
- Joined: Tue Dec 27, 2011 9:14 am
- Location: Australia
Re: Multi 10:4 Trader EA
Great work Andy, thanks!
-
MrLong
Re: Multi 10:4 Trader EA
slipshod wrote:Great work Andy, thanks!
Thanks for your help also, makes life easier when we have a few of us rowing the boat.
Andy
-
MrLong
Re: Multi 10:4 Trader EA
Hi Brian,snailbeard wrote:The DisplayGrid() screen update uses more CPU than the trading logic. I am running two copies Empty4+EA and on a 4-core machine and I get bursts of 100% CPU usage on 2 CPUs.Wkcfx wrote:Great work guys! question; I've been testing on demo with GP, IC, Alpari and Oanda. I hope this is peculiar to my hardware but with v1.07 and about 10+ trades active I get pegged CPU and lockup no matter which broker I try? Also when I close the platform and no other apps are running the CPU stays 100% until I reboot the machine? I couldn't figure where to put Slipshod's suggestion of "Sleep()" I assume I have missed something. Any thoughts?
I'm running Win7 64 pro on a wired cat 6 lan, Intel Core2Duo 2.2GHz, 2GB, 4GB DDR2
I'll look forward to v1.08 and, if it is only my hardware, a new workstation.
thanks again!!
The simplest way of reducing the CPU load would be to reduce the rate at which the screen is updated,
depending on how you use it, this could be once per 5 seconds or once per minute, etc.
Also, MQL is heavy on string operations inside loops, I have some (untested) code to use index look-up instead of string comparisons:RegardsCode: Select all
int allPipFactors[]; //+------------------------------------------------------------------+ //| expert Get Factor function //+------------------------------------------------------------------+ double PFactorByName(string symbol) { for (int i = ArraySize(pipFactor) - 1; i >= 0; i--) if (StringFind(symbol, pipFactor[i], 0) != -1) return(pipFactors[i]); return(10000); } //+------------------------------------------------------------------+ //| Set up fast look-up for pip factor //+------------------------------------------------------------------+ void initPipFactors(string& arPairs[], int& arPipFactors[]) { int pairCount = ArraySize(arPairs); ArrayResize(arPipFactors, pairCount); for (int i = 0; i < pairCount; i++) { arPipFactors[i] = PFactorByName( arPairs[i] ); } } //+------------------------------------------------------------------+ //| Fast look-up for pip factor //+------------------------------------------------------------------+ int PFactor(int pairIndex ) { return (arPipFactors[pairIndex]) } //+------------------------------------------------------------------+ //| Faster pip conversions //+------------------------------------------------------------------+ int doubleToPip(int symIndex, double d) { return ( d * allPipFactors[symIndex] ) } double pipToDouble(int symIndex, double pips) { return ( pips / allPipFactors[symIndex]) }
Brian
Thanks for your code, I haven't tried it, but will do tomorrow.
Many Thanks
Andy
- simplex
- Trader
- Posts: 127
- Joined: Thu Feb 07, 2013 5:21 pm
- Location: An insignificant small town close to an insignificant former capital at the Rhine River.
CPU usage optimization and easier grid maintenance
Hi MrLong,
Great work! Your 1.07 EA is running for two days on one of my test accounts now - and it's really busy.
When I transferred the EA from my development machine (full HD display, quad core) to my elderly test machine (1366 pixels, weak AMD single core) the grid did not show correctly and the cpu usage was rather high. That's why I had a closer look on your code and started to work soon.
Now I have a 1.07 modification that covers the following items:
Modifying column management for the grid made it essentially easier (for me, at last) to set up the display correctly on both my machines.
Reason for the high cpu usage was that in func DisplayGrid() many calculations were done inside a double loop over the X and Y coordinates. Thus when you have e.g. 15 pairs and your display loop is running over its 10 columns all the calculations are done 150 times - without changing its input parameters. I reduced this to only one calculation and also removed some more redundancies of minor impact.
Runtime optimization lead to a significant drop of cpu usage - see screenshots bofore and after. The outcome was, that both machines' fans that were buzzing like hell when the original version ran are quiet now. I love my machines being quite while I'm working
.
Now I noticed you just released v 1.08. What I can offer to you and the community is to integrate my modifications in v 1.08 and send the file to you. The mods mainly consist of several new functions and an external variable to switch back and forth between your version and mine - just for testing purpose. Can be deleted after final integration.
I can easily do this over the weekend, maybe earlier.
If you're interested just drop me a line on where to deliver my code to.
Cheers to all, Jürgen
Great work! Your 1.07 EA is running for two days on one of my test accounts now - and it's really busy.
When I transferred the EA from my development machine (full HD display, quad core) to my elderly test machine (1366 pixels, weak AMD single core) the grid did not show correctly and the cpu usage was rather high. That's why I had a closer look on your code and started to work soon.
Now I have a 1.07 modification that covers the following items:
- split your function DisplayGrid() in two functions CreateGrid() and UpdateGrid() to optimize object management and reduce cpu usage
- replaced redundant function calls in CreateGrid() and UpdateGrid() to further optimize cpu usage
- declared extern int GridMethod to switch between original code and simplex code (temporarily)
- simplified positioning of columns in grid by arrays
- simplified drawing of grid background: drawRectancle()
- functions LabelCreate() and LabelSetText() to simplify object management
- On my display grid columns of open trades and corr. pairs were intermingled. Fixed this.
- changed some color settings, just a matter of personal preferences without public value
- changed some grid coordinates to fit on my screens
Modifying column management for the grid made it essentially easier (for me, at last) to set up the display correctly on both my machines.
Reason for the high cpu usage was that in func DisplayGrid() many calculations were done inside a double loop over the X and Y coordinates. Thus when you have e.g. 15 pairs and your display loop is running over its 10 columns all the calculations are done 150 times - without changing its input parameters. I reduced this to only one calculation and also removed some more redundancies of minor impact.
Runtime optimization lead to a significant drop of cpu usage - see screenshots bofore and after. The outcome was, that both machines' fans that were buzzing like hell when the original version ran are quiet now. I love my machines being quite while I'm working
Now I noticed you just released v 1.08. What I can offer to you and the community is to integrate my modifications in v 1.08 and send the file to you. The mods mainly consist of several new functions and an external variable to switch back and forth between your version and mine - just for testing purpose. Can be deleted after final integration.
I can easily do this over the weekend, maybe earlier.
If you're interested just drop me a line on where to deliver my code to.
Cheers to all, Jürgen
You do not have the required permissions to view the files attached to this post.
If you can't explain it simply, you don't understand it well enough. (Albert Einstein)
It appears that the Weighted Moving Average was invented by a trader who did not have a firm grasp of filter theory in hopes of reducing lag. (John F. Ehlers)
It appears that the Weighted Moving Average was invented by a trader who did not have a firm grasp of filter theory in hopes of reducing lag. (John F. Ehlers)
-
MrLong
Re: CPU usage optimization and easier grid maintenance
Hi Jürgen,simplex wrote:Hi MrLong,
Great work! Your 1.07 EA is running for two days on one of my test accounts now - and it's really busy.
When I transferred the EA from my development machine (full HD display, quad core) to my elderly test machine (1366 pixels, weak AMD single core) the grid did not show correctly and the cpu usage was rather high. That's why I had a closer look on your code and started to work soon.
Now I have a 1.07 modification that covers the following items:
NO changes were applied to trading decisions, etc. - just cpu optimization and gui stuff.
- split your function DisplayGrid() in two functions CreateGrid() and UpdateGrid() to optimize object management and reduce cpu usage
- replaced redundant function calls in CreateGrid() and UpdateGrid() to further optimize cpu usage
- declared extern int GridMethod to switch between original code and simplex code (temporarily)
- simplified positioning of columns in grid by arrays
- simplified drawing of grid background: drawRectancle()
- functions LabelCreate() and LabelSetText() to simplify object management
- On my display grid columns of open trades and corr. pairs were intermingled. Fixed this.
- changed some color settings, just a matter of personal preferences without public value
- changed some grid coordinates to fit on my screens
Modifying column management for the grid made it essentially easier (for me, at last) to set up the display correctly on both my machines.
Reason for the high cpu usage was that in func DisplayGrid() many calculations were done inside a double loop over the X and Y coordinates. Thus when you have e.g. 15 pairs and your display loop is running over its 10 columns all the calculations are done 150 times - without changing its input parameters. I reduced this to only one calculation and also removed some more redundancies of minor impact.
Runtime optimization lead to a significant drop of cpu usage - see screenshots bofore and after. The outcome was, that both machines' fans that were buzzing like hell when the original version ran are quiet now. I love my machines being quite while I'm working.
Now I noticed you just released v 1.08. What I can offer to you and the community is to integrate my modifications in v 1.08 and send the file to you. The mods mainly consist of several new functions and an external variable to switch back and forth between your version and mine - just for testing purpose. Can be deleted after final integration.
I can easily do this over the weekend, maybe earlier.
If you're interested just drop me a line on where to deliver my code to.
Cheers to all, Jürgen
That would be excellent, you can either post the code or just PM me.
Many Thanks
Andy
- slipshod
- Trader
- Posts: 404
- Joined: Tue Dec 27, 2011 9:14 am
- Location: Australia
Re: Multi 10:4 Trader EA
Jürgen, sounds like a great enhancement - I think it goes without saying that everyone would be more than interested in what you've done here 
- Sojourner
- Trader
- Posts: 105
- Joined: Fri Apr 27, 2012 7:36 pm
Re: Multi 10:4 Trader EA
FYI: For some reason 1.08 locked up on me so i shut down the teminal and deleted all the log files and restarted. Works fine now.
-
MrLong
Re: Multi 10:4 Trader EA
Did you restart MT after installing, NT TMATrue SlopeHisto MTF and 10.4 RSI2_on_NT_TMA?Sojourner wrote:FYI: For some reason 1.08 locked up on me so i shut down the teminal and deleted all the log files and restarted. Works fine now.
Andy
- Sojourner
- Trader
- Posts: 105
- Joined: Fri Apr 27, 2012 7:36 pm
Re: Multi 10:4 Trader EA
MrLong wrote:Did you restart MT after installing, NT TMATrue SlopeHisto MTF and 10.4 RSI2_on_NT_TMA?Sojourner wrote:FYI: For some reason 1.08 locked up on me so i shut down the teminal and deleted all the log files and restarted. Works fine now.
Andy
Had to. You can't get the Expert in the navigator unless you restart.
- McNish
- Trader
- Posts: 227
- Joined: Tue Nov 06, 2012 3:56 pm
Re: Multi 10:4 Trader EA
I'm so glad when ever I get a chance to give tips to F.T's. But here at SHF, in the midst of Brains Trust,Sojourner wrote:Had to. You can't get the Expert in the navigator unless you restart.
Go to the relevant Empty4, F4, compile, terminal. Check navigator !
Waiting for the next version of optimized code already.