stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

How to Trade 10.x Like a Boss
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=2505
Page 29 of 39
Author:  andygrope [ Sun Jun 23, 2013 10:37 am ]
Post subject:  Re: How to Trade 10.x Like a Boss

garyfritz wrote:
spotdespot wrote:I actually think that the issue is with the indicators themselves - or more accurately Empty4 and how it deals with indis. I think (Baluda/Steve/coders please advise) that indicators do whatever it is they do every tick (and presumably cannot do their thing every bar close like an EA can).
That's right. Empty4 calls the start() function on every tick. Most indicators (including the 10.5 CSS indicators) do all their calculations and displays on every tick.

But it's easy to fix. Just add this at the beginning of start():

Code: Select all

datetime LastUpdate = 0;
if (TimeCurrent() - LastUpdate < 10) return(0);
LastUpdate = TimeCurrent();
(Not tested since the markets are closed, but it's pretty trivial.)

That will update every 10 seconds. Change the 10 to 60 if you want it to update every minute.
I have 16 GB and I never get close to using it all and each Empty4 terminal maxes out at around 8% cpu when it is bogged down.
More likely it's 12%. You have a quad-core CPU, with each core having two "threads." So your CPU power gets divided into 8 chunks. 1/8 of 100% is 12.5%. When one CPU is spinning as fast as it can, due to a loop or a hang in Empty4, it only consumes 12.5% of your total CPU.
Hi Gary.
Could you please explain in a bit more detail for a newbie how to get that code operating.
Where is "beginning of start"?
Cheers
Author:  kwanann [ Sun Jun 23, 2013 1:02 pm ]
Post subject:  Re: How to Trade 10.x Like a Boss

The start() function....
Author:  spotdespot [ Sun Jun 23, 2013 1:18 pm ]
Post subject:  Re: How to Trade 10.x Like a Boss

Here are some options for people. I have made the change in all the indis that 10.4/10.5 uses that use TMA - I think! If you want to to directly replace what you have then you will need to rename them and overwrite & restart Empty4. I suggest you check that they work first - as Gary mentioned they can't be tested, in terms of effect, with the market closed.

Cheers,
Dave.

EDIT: Updated to add the 10.5 CSS H4 indi
EDIT: - Updated to move the LastUpdate as per the posts below. 24/06/2013 08:35 GMT
Author:  garyfritz [ Sun Jun 23, 2013 2:34 pm ]
Post subject:  Re: How to Trade 10.x Like a Boss

Yes Shelley, you've got it in the right place -- as does Dave in the zip file above. Dave, you might want to include the 10.5 CSS H4 variant too...
Author:  spotdespot [ Sun Jun 23, 2013 2:45 pm ]
Post subject:  Re: How to Trade 10.x Like a Boss

garyfritz wrote:Yes Shelley, you've got it in the right place -- as does Dave in the zip file above. Dave, you might want to include the 10.5 CSS H4 variant too...
Good spot - done.

Cheers,
Dave.
Author:  Pipstubborn [ Sun Jun 23, 2013 4:48 pm ]
Post subject:  Re: How to Trade 10.x Like a Boss

Thanks a lot guys, will try it as son as the market opens. I hope I can see it with all the charts open
Author:  fxozgirl [ Sun Jun 23, 2013 7:55 pm ]
Post subject:  Re: How to Trade 10.x Like a Boss

garyfritz wrote:Yes Shelley, you've got it in the right place -- as does Dave in the zip file above. Dave, you might want to include the 10.5 CSS H4 variant too...

Cheers Gary :D & thanks Dave
Author:  mpetersrx7 [ Mon Jun 24, 2013 12:17 am ]
Post subject:  Re: How to Trade 10.x Like a Boss

Shelley.
I don't think this will work because you need to move
datetime LastUpdate = 0;

above the function so it gets defined globally. Otherwise, everytime start is called it gets reset to 0.

HTH,
Mark
fxozgirl wrote:
garyfritz wrote: But it's easy to fix. Just add this at the beginning of start():

Code: Select all

datetime LastUpdate = 0;
if (TimeCurrent() - LastUpdate < 10) return(0);
LastUpdate = TimeCurrent();
(Not tested since the markets are closed, but it's pretty trivial.)

That will update every 10 seconds. Change the 10 to 60 if you want it to update every minute.

Gary, can you please confirm I have placed your piece of code in the correct location?

thanks

Shelley

Code: Select all

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
  datetime LastUpdate = 0;
   if (TimeCurrent() - LastUpdate < 10) return(0);
   LastUpdate = TimeCurrent();
   int limit;
   int counted_bars = IndicatorCounted();

   if (counted_bars < 0)  return(-1);
   if (counted_bars > 0)  counted_bars -= 10;

   limit = Bars - counted_bars;

   if ( maxBars > 0 )
   {
      limit = MathMin (maxBars, limit);   
   }   

   int i;
   
   for ( i = 0; i < CURRENCYCOUNT; i++ )
   {
      SetIndexStyle( i, DRAW_LINE, STYLE_SOLID, 2, currencyColors[i] );
   }   

   RefreshRates();
   
   for ( i = limit; i >= 0; i-- )
   {
      int index;
      double diff = 0.0;
      
      ArrayInitialize(currencyValues, 0.0);
Author:  bgood [ Mon Jun 24, 2013 2:54 am ]
Post subject:  Re: How to Trade 10.x Like a Boss

Jemook, I've tried using Easy Order to place pending trades but each time I do I receive a message stating "Invalid Lot Size". Any suggestions?
Author:  garyfritz [ Mon Jun 24, 2013 2:56 am ]
Post subject:  Re: How to Trade 10.x Like a Boss

mpetersrx7 wrote:Shelley.
I don't think this will work because you need to move
datetime LastUpdate = 0;
above the function so it gets defined globally. Otherwise, everytime start is called it gets reset to 0.
GACK!! You are absolutely right, Mark. Either move that line outside the function, or declare it as "static datetime". Moving it outside the function is probably simpler/better.

Sorry about that folks!

I'm trying to test out the code to make sure I didn't screw up again, but for some reason my Empty4 is not behaving. I'll test it when I get things working...

EDIT: Seems to work fine. Just put the datetime declaration before the start() function:

Code: Select all

datetime LastUpdate;
int start()
{
   if (TimeCurrent() - LastUpdate < 10) return(0);
   LastUpdate = TimeCurrent();
All times are UTC Page 29 of 39