Forex



Go Back   Forex Trading > Discussion Areas > Setup Questions






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
 
Thread Tools Display Modes
  #1 (permalink)  
Old 01-16-2007, 11:58 AM
Member
 
Join Date: Dec 2005
Posts: 35
zhu28ming is on a distinguished road
Close Position(s) when Price hits MA

Hello, Sirs
Does any expert know how to close the current position when the price hits a moving average?

Thank you!
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 01-16-2007, 12:29 PM
Administrator
 
Join Date: Sep 2005
Posts: 20,017
Blog Entries: 235
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
Quote:
Originally Posted by zhu28ming
Hello, Sirs
Does any expert know how to close the current position when the price hits a moving average?

Thank you!
I am not an expert on this subject but I know the following.

In the settings of EA write:

Code:
extern int Current=1;
extern string PARAMETERS_INDICATOR_ONE  = "Moving Average for close";
extern int CloseEMA_Period = 21;
extern int MAcloseMode =  1; //0=sma, 1=ema, 2=smma, 3=lwma
then:

Code:
double Buy1_2 = iMA(NULL, 0, CloseEMA_Period, 0, MAcloseMode, PRICE_CLOSE, Current);
     
double Sell1_2 = iMA(NULL, 0, CloseEMA_Period, 0, MAcloseMode, PRICE_CLOSE, Current);
the condition for close buy and sell:

Code:
if (iClose(NULL,0,Current) <= Buy1_2) Order = SIGNAL_CLOSEBUY;
if (iClose(NULL,0,Current) >= Sell1_2) Order = SIGNAL_CLOSESELL;
and finally:

Code:
if (Order == SIGNAL_CLOSESELL) 
               {
               OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
                              return(0);
               }
and so on.
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 01-18-2007, 07:34 AM
Member
 
Join Date: Dec 2005
Posts: 35
zhu28ming is on a distinguished road
Is any expert to make it become an EA?

Thanks so much!!!!!!!!
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

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
How to partial close an open position..... bdandi General Discussion 22 09-20-2008 01:02 PM
Alarm or close current position when price hit a MA. zhu28ming Expert Advisors - Metatrader 4 1 09-27-2006 12:04 AM
close open position one shot manually dreamer Setup Questions 1 07-07-2006 02:08 PM
close the current position when the price hits a moving average zhu28ming Expert Advisors - Metatrader 4 0 06-28-2006 02:31 AM


All times are GMT. The time now is 01:56 AM.



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