Forex



Go Back   Forex Trading > Downloads > Expert Advisors - Metatrader 4
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 12-15-2008, 08:01 PM
Junior Member
 
Join Date: Dec 2008
Posts: 12
rwb181 is on a distinguished road
EA based on last bars open and close

Hello All,

I have been searching around for an EA with no luck and have been unable to create one that does exactly what I want it to do.

What I am looking for is an EA that will place a buy or sell order based on the opening and closing of the last two bars in the current chart.

Specifically, if the close of bar[1] is greater than the open of bar[1] and the close of bar[2] was less than the open of bar[2] (a price reversal), a buy order is placed on the open of bar[0]. A sell would be the opposite.

The EA doesn't need to be fancy or anything like that. Actually, what I could probably work with is just the formula that is needed to satisfy these conditions.

Any help that is offered will be greatly appreciated. In the mean time, I will continue to try to create the proper formula.

Thank you for your attention,
Ron
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 12-15-2008, 08:10 PM
Beno's Avatar
Senior Member
 
Join Date: Aug 2006
Location: London
Posts: 516
Beno is on a distinguished road
Do you mean a 2 bar reversal. What time frame are you thinking of using

Last edited by Beno; 12-15-2008 at 08:13 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 12-15-2008, 08:25 PM
Member
 
Join Date: Jun 2006
Posts: 42
uagadugu is on a distinguished road
Do you use some timefilter for the EA to work or this EA will work 24hrs? What's the timeframe?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 12-15-2008, 08:43 PM
ffaspector's Avatar
Junior Member
 
Join Date: Dec 2008
Posts: 15
ffaspector is on a distinguished road
Like this??

if(Volume[0]<1) {
if(Close[1]>Open[1] && Close[2]<Open[2]) OrderSend(...,OP_BUY,...);
if(Close[1]<Open[1] && Close[2]>Open[2]) OrderSend(...,OP_SELL,...);
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 12-16-2008, 02:04 AM
Junior Member
 
Join Date: Dec 2008
Posts: 12
rwb181 is on a distinguished road
Smile

Thanks for the replies everyone. I wanted a statement that would work for any time frame.

I came up with this and it seems to work.

// get the open and close for last two bars
OpenLastBar = iOpen(NULL,0,1);
OpenPreviousBar = iOpen(NULL,0,2);
CloseLastBar = iClose(NULL,0,1);
ClosePreviousBar = iClose(NULL,0,2);

// check if conditions are met
if(OpenLastBar<CloseLastBar && OpenPreviousBar>=ClosePreviousBar) siCurrentDirection = 1; //up
if(OpenLastBar>CloseLastBar && OpenPreviousBar<=ClosePreviousBar) siCurrentDirection = 2; //down

This is just the beginning of what I want to accomplish but, it is a start.

Thanks for the help, all
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 12-16-2008, 03:31 AM
Junior Member
 
Join Date: Dec 2008
Posts: 12
rwb181 is on a distinguished road
Shorter yet

I have learned that this will work as well;

if(iOpen(NULL,0,1)<iOpen(NULL,0,2) && iOpen(NULL,0,2)>=iClose(NULL,0,2)) siCurrentDirection = 1; //up
if(iOpen(NULL,0,1)>iOpen(NULL,0,2) && iOpen(NULL,0,2)<=iClose(NULL,0,2)) siCurrentDirection = 2; //down

A little shorter than the first I made.

I believe I can use the "TimeFrame" standard constant inside these to get
data from other time frames. But, this will work for now.

Have a great day Everyone!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #7 (permalink)  
Old 12-16-2008, 03:40 AM
Junior Member
 
Join Date: Dec 2008
Posts: 12
rwb181 is on a distinguished road
My Mistake, this is correct;

if(iOpen(NULL,0,1)<iClose(NULL,0,2) && iOpen(NULL,0,2)>=iClose(NULL,0,2)) siCurrentDirection = 1; //up
if(iOpen(NULL,0,1)>iClose(NULL,0,2) && iOpen(NULL,0,2)<=iClose(NULL,0,2)) siCurrentDirection = 2; //down

Sorry for any confusion.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #8 (permalink)  
Old 12-16-2008, 03:48 AM
Junior Member
 
Join Date: Dec 2008
Posts: 12
rwb181 is on a distinguished road
One more try

Forget everything past, this is what I meant;

if(iOpen(NULL,0,1)<iClose(NULL,0,1) && iOpen(NULL,0,2)>=iClose(NULL,0,2)) siCurrentDirection = 1; //up
if(iOpen(NULL,0,1)>iClose(NULL,0,1) && iOpen(NULL,0,2)<=iClose(NULL,0,2)) siCurrentDirection = 2; //down

That's what I get for being in a hurry.

It is a good thing my head is attached.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
ea open close


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Close Open Trades EAs based on Equity Tradinator Expert Advisors - Metatrader 4 32 11-10-2009 04:26 PM
Close after 5 bars carllos Metatrader 4 3 05-15-2007 10:14 PM
Open/close trade on same bar's close? WNW Expert Advisors - Metatrader 4 2 03-29-2007 06:37 AM
Close all based on Magic kokas Metatrader 4 mql 4 - Development course 6 09-19-2006 09:20 PM
Close all open positions jonjonau Expert Advisors - Metatrader 4 6 07-12-2006 06:01 AM


All times are GMT. The time now is 01:53 PM.



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