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 30 of 39
Author:  pips400 [ Mon Jun 24, 2013 6:01 am ]
Post subject:  Re: How to Trade 10.x Like a Boss

garyfritz wrote:
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();
I've made the following update, and now seems to be working fine, thanks guys

Code: Select all

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

datetime LastUpdate;

int start()
{
   if (TimeCurrent() - LastUpdate < 60) return(0);
   LastUpdate = TimeCurrent();
   
   int limit;
   int counted_bars = IndicatorCounted();
Author:  Baluda [ Mon Jun 24, 2013 7:38 am ]
Post subject:  Re: How to Trade 10.x Like a Boss

FWIW, this is what I do:

Code: Select all

static datetime oldH1BarTime;
if ( oldH1BarTime != iTime( NULL, PERIOD_H1, 0 ) )
{
   // Do something
}
oldH1BarTime =  iTime( NULL, PERIOD_H1, 0 ); 
Benefits:
  • All code is together in the same place
  • Test variable is declared static, it does not get lost
  • Period to test for is quickly spotted (and changed)
Happy coding!

Paul
Author:  SWG123 [ Mon Jun 24, 2013 9:55 am ]
Post subject:  Re: How to Trade 10.x Like a Boss

Baluda wrote:FWIW, this is what I do:

Code: Select all

static datetime oldH1BarTime;
if ( oldH1BarTime != iTime( NULL, PERIOD_H1, 0 ) )
{
   // Do something
}
oldH1BarTime =  iTime( NULL, PERIOD_H1, 0 ); 
Benefits:
  • All code is together in the same place
  • Test variable is declared static, it does not get lost
  • Period to test for is quickly spotted (and changed)
Happy coding!

Paul
OK, I'll stick my head up - feel free to throw coconuts! :D

Paul, for those of us who think a function is a wedding reception...where must we place this code?
Author:  Baluda [ Mon Jun 24, 2013 10:08 am ]
Post subject:  Re: How to Trade 10.x Like a Boss

SWG123 wrote:Paul, for those of us who think a function is a wedding reception...where must we place this code?
Anywhere, that is the beauty!

Just put it somewhere in your start() (or any other) function, set the period you want to use, type your once-in-a-period code and off you go.

Example, read some variable once per 5 minutes:

Code: Select all

static datetime oldM5BarTime;
if ( oldM5BarTime != iTime( NULL, PERIOD_M5, 0 ) )
{
   SomeVariable = CallSomeOffHandFunction(With, Some, Variables);
}
oldM5BarTime =  iTime( NULL, PERIOD_M5, 0 ); 
Paul
Author:  fxozgirl [ Mon Jun 24, 2013 11:20 am ]
Post subject:  Re: How to Trade 10.x Like a Boss

garyfritz wrote:
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();
Thanks for your help guys :D
Author:  phaholj [ Mon Jun 24, 2013 11:27 am ]
Post subject:  Re: How to Trade 10.x Like a Boss

Baluda wrote:
SWG123 wrote:Paul, for those of us who think a function is a wedding reception...where must we place this code?
Anywhere, that is the beauty!

Just put it somewhere in your start() (or any other) function, set the period you want to use, type your once-in-a-period code and off you go.

Example, read some variable once per 5 minutes:

Code: Select all

static datetime oldM5BarTime;
if ( oldM5BarTime != iTime( NULL, PERIOD_M5, 0 ) )
{
   SomeVariable = CallSomeOffHandFunction(With, Some, Variables);
}
oldM5BarTime =  iTime( NULL, PERIOD_M5, 0 ); 
Paul
What about 30 seconds?
Or it should read SomeVariables after 30 seconds.
Author:  garyfritz [ Mon Jun 24, 2013 1:38 pm ]
Post subject:  Re: How to Trade 10.x Like a Boss

I believe Paul's code runs the "do something" code once per bar, though it's not tied to the chart bar length. So if you want to run something once every 1 minute, 5 minutes, 15 minutes, etc -- Empty4-supported bar lengths -- then it works great. If you want more flexibility than that (10 seconds, 10 minutes, etc) then I think you have to use my approach.
Author:  Lancaster [ Mon Jun 24, 2013 4:10 pm ]
Post subject:  Re: How to Trade 10.x Like a Boss

There were several setups today but I've struggled, admittedly because I haven't done a great job following the ground rules.

I'm still short AUDCHF a few pips down, and this was my experience with EURAUD so far:
Author:  thelearner [ Mon Jun 24, 2013 5:12 pm ]
Post subject:  Re: How to Trade 10.x Like a Boss

ALL H1 CSS screaming for early cut loss on all AUD trades. Well...at least we got warned.
Author:  Sojourner [ Mon Jun 24, 2013 8:27 pm ]
Post subject:  Re: How to Trade 10.x Like a Boss

The RSI indi seems to be working OK but the CSS seems to be printing the lines and color bars differently.


spotdespot wrote: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
All times are UTC Page 30 of 39