Forex



Go Back   Forex Trading > Programming > MetaTrader
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 07-14-2008, 11:22 AM
Member
 
Join Date: May 2008
Posts: 31
payback is on a distinguished road
How to open two indipendent orders?

Hi all again! I'm sorry to hassle you with questions that may stupid, but i need your help!
My problem is that i wanted to add an hedging subsystem in my EA (originally from coderguru),
so here is the point:

I have an order X if X goes under (e.g.) 25 pips i open order Y

so if was only one order "y" it is no problem because i can use a counter like this

PHP Code:
  //+------------------------------------------------------------------+
//| FUNCTION : NUMBER OF ORDER BASE ON SYMBOL AND MAGIC NUMBER       |
//| SOURCE   : n/a                                                   |
//| MODIFIED : FIREDAVE                                              |
//+------------------------------------------------------------------+
int subTotalTrade()
{
   
int
      cnt

      
total 0;

   for(
cnt=0;cnt<OrdersTotal();cnt++)
   {
      
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if(
OrderType()<=OP_SELL &&
         
OrderSymbol()==Symbol() &&
         
OrderMagicNumber()==MagicNumbertotal++;
   }
   return(
total);
}

//+------------------------------------------------------------------+
//| FUNCTION : OPEN ORDER BASE ON SYMBOL AND MAGIC NUMBER            |
//| SOURCE   : n/a                                                   |
//| MODIFIED : FIREDAVE                                              |
//+------------------------------------------------------------------+
string subCheckOpenTrade()
{
   
int
      cnt         
0;
   
string
      lasttrade   
"None";      

   for(
cnt=0;cnt<OrdersTotal();cnt++)
   {
      
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if(
OrderType()<=OP_SELL &&
         
OrderSymbol()==Symbol() &&
         
OrderMagicNumber()==MagicNumber)
      {
         if(
OrderType()==OP_BUY lasttrade "BUY";
         if(
OrderType()==OP_SELLlasttrade "SELL";
      }         
   }
   return(
lasttrade);


and then limit to 1 the open order

like this

PHP Code:

//+------------------------------------------------------------------+
//| NEW TRADE - ENTRY                                                |
//+------------------------------------------------------------------+
   
if(subTotalTrade()<&& (BuyCondition  || SellCondition  ) && AllowEntry
   { 
but in this way i can open only one hedging order so what about if
X closes Y still open
X1 goes -25 now i'd like to open Y1 order and i can't!

How can i solve this problem?
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 07-14-2008, 11:35 AM
Senior Member
 
Join Date: Apr 2006
Posts: 158
InTrance is on a distinguished road
Change the MagicNumber for each system in OrderSend and then for your counting
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 07-14-2008, 11:44 AM
Member
 
Join Date: May 2008
Posts: 31
payback is on a distinguished road
what is the logic behind? i want to open multiple "Y" orders like this
X and Y, x closes
X1 and Y
X1 and Y, Y1
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
  #4 (permalink)  
Old 07-14-2008, 12:03 PM
Senior Member
 
Join Date: Nov 2006
Posts: 308
luxinterior is on a distinguished road
I'd like to try to help you but your question isn't very clear.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
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 07-14-2008, 12:47 PM
Member
 
Join Date: May 2008
Posts: 31
payback is on a distinguished road
Ok i'll try to explain better....
I have an ea, it performs well, but it still have false signals but it's not a problem
For example my signal is buy is buy right ? (X)
if OrderProfit < -25 open hedge order
the hedge order is a sell order (Y) with it's paramaters.

If X closes Y must still open until take profit
and so on X1 Y
X1 Y Y1 etc
is it a little bit more clear?
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 07-15-2008, 01:33 AM
Member
 
Join Date: May 2008
Posts: 31
payback is on a distinguished road
still no ideas or suggestions? please help! your are the best on the net!!!
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 07-15-2008, 04:12 PM
Senior Member
 
Join Date: Apr 2006
Posts: 158
InTrance is on a distinguished road
You could have a binary variable and reset when the first order closes so when you have an X order and it goes -25 and reset=false you open Y. Then set reset=true until X is gone

Hope it makes sense

Last edited by InTrance; 07-15-2008 at 04:17 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
  #8 (permalink)  
Old 07-15-2008, 05:27 PM
Member
 
Join Date: May 2008
Posts: 31
payback is on a distinguished road
thx! at first look it seems it could work it out! i will try tomorrow because today i'm very busy!
but thx anyway!
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
Close all open orders EA nubika Expert Advisors - Metatrader 4 30 10-31-2009 01:40 PM
EA to close pending and open orders!! criss73 Expert Advisors - Metatrader 4 7 04-08-2009 06:48 AM
close all open orders script forextrend General Discussion 2 12-17-2006 07:16 AM
Script to close open orders... babarmughal Expert Advisors - Metatrader 4 1 12-13-2006 05:50 PM
Using Arrays to track info for All Open Orders deeforex Questions 6 09-12-2006 07:01 PM


All times are GMT. The time now is 07:28 PM.



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