Results 1 to 3 of 3
 0 Attachment(s)    

Thread: How to guarantee no more than one simultaneous trade with a multipair EA?

  1. #1
    Junior Member
    Join Date
    May 2009
    Posts
    11

    Default How to guarantee no more than one simultaneous trade with a multipair EA?

    Hello all,

    I'm writing an multipair EA, that should only have one single trade open two avoid excessive drawdown.

    What I did is looping through all open trades and counted orders with the same magicNr (All pairs on this EA use the same magicNr).
    and then placing an order if there is an entry signal.

    But this doesn't always work, because two or more instances of the EA might check for open orders at the same and as there are no open orders, they are placing new orders at the same time.

    To check if this might happen, I've made an EA that always sends a new order, if the count of open trades is zero. And the problem really happens when I close and reopen the terminal, or when I close all open orders. I always encounter multiple trades from different pairs ;-(

    What can I do to handle this properly?

    Thanks in advance

  2. #2

    Default

    Use GlobalVariables they are they answer to your problem.
    Last edited by BillR; 11-23-2009 at 14:00.

  3. #3
    Junior Member
    Join Date
    May 2009
    Posts
    11

    Default

    Thank you very much BillR, it works now!

    That's more or less that, what I've added to my code:
    Code:
    at init():
      GlobalVariableSet( "MyEAOrderInProgress", false );
    
    within trading logic:
      if ( GlobalVariableGet( "MyEAOrderInProgress" ) == false )
      {
         GlobalVariableSet( "MyEAOrderInProgress", true );
         OrderSend( Symbol(), OP_BUY, lots, price, slippage, stoploss, takeprofit, comment, magicNr, Blue );
         GlobalVariableSet( "MyEAOrderInProgress", false );
      }

Similar Threads

  1. Replies: 0
    Last Post: 09-21-2010, 00:37
  2. Simple Multipair
    By 626mx in forum Ideas for expert advisors
    Replies: 12
    Last Post: 08-05-2010, 22:54
  3. Replies: 0
    Last Post: 10-13-2008, 17:11
  4. Irish Bank Guarantee Scheme
    By funyoo in forum Economy
    Replies: 0
    Last Post: 10-02-2008, 20:56

Tags for this Thread

how to, magic, pairs, signal, slippage, stoploss, thank you, time, trading

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •