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
  #1 (permalink)  
Old 04-01-2008, 02:54 AM
Member
 
Join Date: Nov 2006
Posts: 33
winias is on a distinguished road
EA building 101 question Need Help please!

Hi there -
I have a simple problem and figured this was the bast place to turn to for some helpful advice. I have a very simple ea I put together from the following website:

Expert Advisor Builder for MetaTrader 4

I'm not a programmer, and thought this was the best place to put my ideas to work (instead of posting my brain online here ). The ea works, no doubt about that, and has been giving me some good entries.

My problem comes when it opens a trade, and the buy or sell signal is continued on the next bar, it closes the current buy and starts a new one, creating multiple trades (usually losses) over and over again in a short time span. How do I allow it to only trade once, until the close buy signal is generated?

To my willing experts out there, thank you in advance!
S.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-01-2008, 03:04 AM
Senior Member
 
Join Date: Oct 2007
Posts: 221
Dave137 is on a distinguished road
Wink

TRADE ONLY ONCE ON BAR



Up at the top where you declare your variables put


static bool ITradedOnThisBar;


then where you send your order put


if(Your Critera && ITradedOnThisBar!=Bars)
{
ticket=OrderSend(Symbol(),OP_BUY,... );
ITradedOnThisBar = Bars;
}


Doing This will keep you from opening a trade on the same bar that you already opened a trade on, but more importantly you want to keep it from closing on the same bar so I would also add this code where you close your trade, for example:

if(Your Criteria && ITradedOnThisBar != Bars)
{
OrderClose(OrderTicket(),... ); // close position
}

This is probably the most simple way to do what you are trying to do.


This works if you can find the places to add these statements.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-01-2008, 03:13 AM
Senior Member
 
Join Date: Oct 2007
Posts: 221
Dave137 is on a distinguished road
Smile

Another possibility that is causing your problem is the close of buy and sell statement setting are set and activating very close to your opening buy and sell entry statement setting....Such as buy open at RSI > 60 and Closing the RSI positions < 50. If the RSI is ranging up and down because of price volatility you will be entering and exiting quite frequently. Check how the program statements work by studying the enter and exit points on the graph by expanding the bars and see how they correspond to your in and out logic of your program.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-01-2008, 04:26 AM
Member
 
Join Date: Nov 2006
Posts: 33
winias is on a distinguished road
Thank you!

Thank you Dave! It seems the close buy logic was holding the issue, but I'm certain your other respose will serve me well down the line. I didnt rationalize too well how the code wouldn't do as I wished it to right off the bat. I'm pretty impressed with this little website otherwise; its allowed me to put my mental garbage to good use . After I fixed this problem my results shot up to an 85% win rate; not bad for a first attempt. Keep you posted and I appreciate, very much, the reply.
S.
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 Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Building EA indicator MA profeta Suggestions for Trading Systems 1 03-07-2007 12:47 AM
Part-Time Wealth Building System-Weekly james2ko Expert Advisors - Metatrader 4 5 01-30-2007 11:07 PM
EA question yaniv_av Expert Advisors - Metatrader 4 1 11-14-2006 01:10 PM


All times are GMT. The time now is 08:29 AM.



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