molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming

AFTER YOU REGISTER SEND US AN EMAIL TO ACTIVATE YOUR ACCOUNT - Before posting:-1- Please read the user guide -2- Try the examples -3- Search in the forum
It is currently Sun May 12, 2024 11:28 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: position keeps opening and closing
PostPosted: Tue Nov 27, 2012 3:46 pm 
Offline

Joined: Tue Nov 20, 2012 6:21 pm
Posts: 13
Hello,
After my close long hits it keeps trying to reopen new buy and then close long takes it out again. This happens over and over opening new closing etc. etc. It shouldn't open new position with a buy once the ta block logic has been met so why is this happening?
Thank you.


Attachments:
aoacsarclbuy.mol [8.4 KiB]
Downloaded 437 times
MT4 EA2.png
MT4 EA2.png [ 344.7 KiB | Viewed 4389 times ]
Top
 Profile  
 
 Post subject: Re: position keeps opening and closing
PostPosted: Tue Nov 27, 2012 5:24 pm 
Offline

Joined: Sun Jun 19, 2011 9:38 pm
Posts: 270
You have a simple >= condition in both BUY TA blocks. Without further restriction, every time this simple condition is true your EA enters a buy trade. Maybe try adding new TA's that say shift 2 < (was previously below) to better define your crossover.

Also, using shift 0 in a TA while using CompletedBars in the START icon may not be doing what you think. Shift 0 will evaluate your condition every tick, overriding CompletedBars. Use shift 1 to evaluate based on the last closed price bar if that's what you're after.

_________________
I'm not a programmer, but I play one on TV.


Top
 Profile  
 
 Post subject: Re: position keeps opening and closing
PostPosted: Wed Nov 28, 2012 12:09 am 
Offline

Joined: Tue Nov 20, 2012 6:21 pm
Posts: 13
I'll try other options
thanks.


Top
 Profile  
 
 Post subject: Re: position keeps opening and closing
PostPosted: Wed Nov 28, 2012 8:51 am 
Offline

Joined: Tue Nov 20, 2012 6:21 pm
Posts: 13
I was assuming that completed bars does just that. It should execute once bar is actually completed and not during the actual formation of the bar. It sounds like that is what tick by tick should do. So what is the real difference between completed and tick on the home screen then?
Thank you.


Top
 Profile  
 
 Post subject: Re: position keeps opening and closing
PostPosted: Wed Nov 28, 2012 12:13 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
The ea will trade once a bar at the open (when the first tick of the new bar is received)
The issue is the logic, you have something like this:
if x then close
if y then open
which is evaluated once per bar in that sequence. Both conditions may overlap (both close and buy may be true at any given moment). You need to change the logic to avoid overlaps.


Top
 Profile  
 
 Post subject: Re: position keeps opening and closing
PostPosted: Wed Nov 28, 2012 10:17 pm 
Offline

Joined: Tue Nov 20, 2012 6:21 pm
Posts: 13
got it thanks much


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by Molanis © 2009