Forex



Go Back   Forex Trading > Discussion Areas > 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 05-12-2009, 01:30 AM
hnk hnk is offline
Junior Member
 
Join Date: Sep 2007
Posts: 3
hnk is on a distinguished road
HELP: Two Strategies using one EA

Hello All,

I am working on a logic where I want to run two different strategies using one EA. What I want to do is

1. Run strategy 1 and do the first trade.
2. Once first trade is completed, EA should run the next trade using strategy 2.
3. Third trade then again will be for Strategy 1 after trade two is closed.


I have basic understanding of programming and will try if someone can guide me for steps required to control EA for switching between strategies. Appreciate if anyone can provide some guidelines.

Regards

hnk

Last edited by hnk; 05-12-2009 at 09:56 PM. Reason: Let the people know that I am looking for help rather them confuse them with the topic
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 05-12-2009, 04:04 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 820
wolfe is on a distinguished road
Quote:
Originally Posted by hnk View Post
Hello All,

I am working on a logic where I want to run two different strategies using one EA. What I want to do is

1. Run strategy 1 and do the first trade.
2. Once first trade is completed, EA should run the next trade using strategy 2.
3. Third trade then again will be for Strategy 1 after trade two is closed.


I have basic understanding of programming and will try if someone can guide me for steps required to control EA for switching between strategies. Appreciate if anyone can provide some guidelines.

Regards

hnk
You could use a Boolean flag such as:

PHP Code:
bool Use_Strategy_One true;
  
  if (
Use_Strategy_One == true)
   {
    if (
Strategy One Entry Code Here)
     {
      
OrderSend();
     }
    if (
Strategy One Exit Code Here)
     {
      
OrderClose();
      
Use_Strategy_One false;
     }
   }
   
  if (
Use_Strategy_One == false)
   {
    if (
Strategy Two Entry Code Here)
     {
      
OrderSend();
     }
    if (
Strategy Two Exit Code Here)
     {
      
OrderClose();
      
Use_Strategy_One true;
     }
   } 
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 05-12-2009, 02:59 PM
hnk hnk is offline
Junior Member
 
Join Date: Sep 2007
Posts: 3
hnk is on a distinguished road
Quote:
Originally Posted by wolfe View Post
You could use a Boolean flag such as:

PHP Code:
bool Use_Strategy_One true;
  
  if (
Use_Strategy_One == true)
   {
    if (
Strategy One Entry Code Here)
     {
      
OrderSend();
     }
    if (
Strategy One Exit Code Here)
     {
      
OrderClose();
      
Use_Strategy_One false;
     }
   }
   
  if (
Use_Strategy_One == false)
   {
    if (
Strategy Two Entry Code Here)
     {
      
OrderSend();
     }
    if (
Strategy Two Exit Code Here)
     {
      
OrderClose();
      
Use_Strategy_One true;
     }
   } 
Thanks Wolfe, it definitely will help. I will give it a try.

Regards,

hnk
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


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
Exit strategies pengie Suggestions for Trading Systems 21 06-13-2009 10:52 PM
Why do the Simple strategies often get ignored? KaMpeR General Discussion 25 02-08-2009 12:51 PM
Help with writing your own strategies hitman22 Metatrader 4 2 03-15-2006 11:22 AM
Do EAs exist for these strategies? confusedxx Expert Advisors - Metatrader 4 1 02-09-2006 03:51 PM


All times are GMT. The time now is 06:22 AM.



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