Forex
Google
New signals service!

Go Back   Forex Trading > Discussion Areas > Metatrader 4


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 04-15-2007, 01:33 PM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
yes, well, no: that logic (with the word 'static' added) would be to stop the EA go past on other than the first tick on a bar; thus, then the EA is only allowed to make a trade at the first tick on a bar. Regardless of whether there is an open trade or not. E.g., in a daily time frame, only the first tick after midnight would be a trade option.

Right solution to a different problem.

And, as Kalenzo pointed out, it's probably / possibly appropriate to also tie up the logic by magic number to the subset of trades managed by the EA. Which is another reason for inspecting the trades table.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 09-30-2007, 06:13 PM
WNW's Avatar
WNW WNW is offline
Senior Member
 
Join Date: Feb 2006
Location: Motown, USA
Posts: 378
WNW is on a distinguished road
Coding question: 1 trade per bar?

I'm working on an EA.
When I receive an entry signal, is there a simple way to limit that entry to
only 1 per bar? Some kind of global command?
Oftentimes there are multiple trades around the same area when price continues to retrigger the entry.

Any help appreciated,
Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 09-30-2007, 07:18 PM
HerbertH's Avatar
Member
 
Join Date: May 2006
Posts: 88
HerbertH is on a distinguished road
Quote:
Originally Posted by WNW View Post
I'm working on an EA.
When I receive an entry signal, is there a simple way to limit that entry to
only 1 per bar? Some kind of global command?
Oftentimes there are multiple trades around the same area when price continues to retrigger the entry.

Any help appreciated,
Thanks.
Hi, take a look in this thread: Number of trades per bar
In which the same question (and answer...:-) was discussed.

Cheers,
Herbert
__________________
Better being out, wishing to be in than being in and wishing to be out.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 09-30-2007, 08:30 PM
WNW's Avatar
WNW WNW is offline
Senior Member
 
Join Date: Feb 2006
Location: Motown, USA
Posts: 378
WNW is on a distinguished road
Thanks for your reply.
In reference to your post #3, where is this code placed?

datetime Timestamp = 0;

if(Timestamp != iTime(NULL,0,0))
{
Timestamp = iTime(NULL,0,0);


..your code here..
}

Is it placed jsut before the trading logic?
You referenced this link in the other thread for an example, but it appears to be a dead link:
http://www.forex-tsd.com/132491-post25.html

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 09-30-2007, 09:03 PM
HerbertH's Avatar
Member
 
Join Date: May 2006
Posts: 88
HerbertH is on a distinguished road
Quote:
Originally Posted by WNW View Post
Thanks for your reply.
In reference to your post #3, where is this code placed?

datetime Timestamp = 0;

if(Timestamp != iTime(NULL,0,0))
{
Timestamp = iTime(NULL,0,0);


..your code here..
}

Is it placed jsut before the trading logic?
You referenced this link in the other thread for an example, but it appears to be a dead link:
http://www.forex-tsd.com/132491-post25.html

Thanks.

It's a bit difficult to tell you where to put this because I don't know the structure of your expert, but most likely you want this in your Start() body.
Put the "datetime TimeStamp = 0" into the global variables at the top of the EA.

The thread with the example coding has been removed, but if you want an example sent or you want me to look at your Expert, just send me a PM with your email address.

Cheers
__________________
Better being out, wishing to be in than being in and wishing to be out.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 09-30-2007, 09:19 PM
WNW's Avatar
WNW WNW is offline
Senior Member
 
Join Date: Feb 2006
Location: Motown, USA
Posts: 378
WNW is on a distinguished road
I'll give that a try, thanks again.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #17 (permalink)  
Old 10-01-2007, 05:51 AM
WNW's Avatar
WNW WNW is offline
Senior Member
 
Join Date: Feb 2006
Location: Motown, USA
Posts: 378
WNW is on a distinguished road
I added the code as follows:
--------------------------
[other variables here]

datetime Timestamp = 0;


//+------------------------------------------------------------------+
//| Expert Initialization |
//+------------------------------------------------------------------+
int init()
{
LastPrice = Bid;
return(0);
}

//+------------------------------------------------------------------+
//| Expert start |
//+------------------------------------------------------------------+

int start()
{
if(Timestamp != iTime(NULL,0,0))
Timestamp = iTime(NULL,0,0);

------------------------------------
and it's not working; still generating multiple trades.
Have I entered it correctly?

The trade logic comes much farther down in the code; unfortunately the code is copyrighted and I cannot disclose it.

Last edited by WNW; 10-01-2007 at 10:58 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #18 (permalink)  
Old 10-01-2007, 08:04 AM
HerbertH's Avatar
Member
 
Join Date: May 2006
Posts: 88
HerbertH is on a distinguished road
Quote:
Originally Posted by WNW View Post
I added the code as follows:
--------------------------
[other variables here]

datetime Timestamp = 0;


//+------------------------------------------------------------------+
//| Expert Initialization |
//+------------------------------------------------------------------+
int init()
{
LastPrice = Bid;
Anchor = (Ask+Bid)/2;
return(0);
}

//+------------------------------------------------------------------+
//| Expert start |
//+------------------------------------------------------------------+

int start()
{
if(Timestamp != iTime(NULL,0,0))
Timestamp = iTime(NULL,0,0);

------------------------------------
and it's not working; still generating multiple trades.
Have I entered it correctly?

The trade logic comes much farther down in the code; unfortunately the code is copyrighted and I cannot disclose it.

Keep in mind that the example code I provided will restrict only the enclosed portion of your code which then is being handled once every new bar.

If you enclose ALL of the Start() code inside it will not only trigger new trades every new bar, but it will also execute your code looking for breakeven, trailingstop etc. only once a new bar starts.

The simple recepy for using this method is: Enclose only the part of your coding logic that needs to be handled once every new bar.

I understand your copyright situation, but you have to realise mine as well:
I cannot help you any further than this without any insight in (part of) the coding.
Maybe the code snippets in this merged thread will give you new ideas.

Cheers
__________________
Better being out, wishing to be in than being in and wishing to be out.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #19 (permalink)  
Old 10-01-2007, 03:41 PM
WNW's Avatar
WNW WNW is offline
Senior Member
 
Join Date: Feb 2006
Location: Motown, USA
Posts: 378
WNW is on a distinguished road
Quote:
Originally Posted by HerbertH View Post
If you enclose ALL of the Start() code inside it will not only trigger new trades every new bar, but it will also execute your code looking for breakeven, trailingstop etc. only once a new bar starts.

The simple recepy for using this method is: Enclose only the part of your coding logic that needs to be handled once every new bar.
Thanks again for your reply.

I'm not a coder and am not familiar with MQL syntax.

When you say "enclose" what does that mean in terms of which characters to use? Can you provide an example?

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #20 (permalink)  
Old 10-01-2007, 09:28 PM
HerbertH's Avatar
Member
 
Join Date: May 2006
Posts: 88
HerbertH is on a distinguished road
Quote:
Originally Posted by WNW View Post
Thanks again for your reply.

I'm not a coder and am not familiar with MQL syntax.

When you say "enclose" what does that mean in terms of which characters to use? Can you provide an example?

Thanks.
With enclose I mean putting your code in between the { } brackets of the code snippet I showed you.

For example:
Code:
int start()
{
     if(Timestamp != iTime(NULL,0,0))
     {
          Timestamp = iTime(NULL,0,0);

          CheckForNewTradeSetup(); // This will be where you put your code which is only allowed to run once every new bar
     }

     CheckOpenTrades();    // This will be where your code is placed, which will run every tick
}
The example shown above will check to open new trades once every new bar,
but will check existing open trades (e.g. to handle breakeven etc) every tick.

Hope this helps

PS. If you are not a coder and this expert is not functioning properly, why don't you just have the original coder have a look at this?
__________________
Better being out, wishing to be in than being in and wishing to be out.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Gannswing to open trade gee Expert Advisors - Metatrader 4 1 02-15-2007 09:00 PM
Restarting EA with current open trade dwmcqueen Metatrader 4 5 01-26-2007 04:29 AM
script open trade BrunoFX Tools and utilities 6 05-21-2006 11:08 PM


All times are GMT. The time now is 12:04 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.