How to Trade 10.x Like a Boss

This is where Bob posts his own threads
Post Reply
User avatar
pips400
Trader
Posts: 279
Joined: Tue Jan 01, 2013 9:03 pm

Re: How to Trade 10.x Like a Boss

Post by pips400 »

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();
User avatar
Baluda
Trader
Posts: 330
Joined: Mon Feb 06, 2012 2:00 pm
Location: An insignificant village in the Netherlands

Re: How to Trade 10.x Like a Boss

Post by Baluda »

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
Check the MQL4 Market for my best EA's and Indicators.
SWG123
Trader
Posts: 565
Joined: Wed Nov 16, 2011 3:02 pm
Location: Cape Town

Re: How to Trade 10.x Like a Boss

Post by SWG123 »

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?
User avatar
Baluda
Trader
Posts: 330
Joined: Mon Feb 06, 2012 2:00 pm
Location: An insignificant village in the Netherlands

Re: How to Trade 10.x Like a Boss

Post by Baluda »

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
Check the MQL4 Market for my best EA's and Indicators.
User avatar
fxozgirl
Trader
Posts: 1176
Joined: Wed Nov 16, 2011 9:16 am
Location: Melbourne, Australia

Re: How to Trade 10.x Like a Boss

Post by fxozgirl »

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
phaholj
Trader
Posts: 25
Joined: Thu Aug 16, 2012 6:25 am

Re: How to Trade 10.x Like a Boss

Post by phaholj »

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.
garyfritz

Re: How to Trade 10.x Like a Boss

Post by garyfritz »

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.
Lancaster
Posts: 8
Joined: Tue Apr 02, 2013 6:17 pm

Re: How to Trade 10.x Like a Boss

Post by Lancaster »

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:
You do not have the required permissions to view the files attached to this post.
thelearner
Trader
Posts: 114
Joined: Tue Sep 11, 2012 9:35 am

Re: How to Trade 10.x Like a Boss

Post by thelearner »

ALL H1 CSS screaming for early cut loss on all AUD trades. Well...at least we got warned.
User avatar
Sojourner
Trader
Posts: 105
Joined: Fri Apr 27, 2012 7:36 pm

Re: How to Trade 10.x Like a Boss

Post by Sojourner »

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
You do not have the required permissions to view the files attached to this post.
Post Reply

Return to “Bob's individual forum”