Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13
 0 Attachment(s)    

Thread: How to count all open trades for specific pair with magicnumber?

  1. #11

    Default

    Quote Originally Posted by jidonk View Post
    Hi Jezzer,

    Hopefully you don't mind teaching me another one:

    for the EA to open another position ONLY when the previous position(s) are in a floating loss condition? I'm referring to dollar value of the loss, not based on pip step. (and still based on the specific pairs and magic)

    For example,
    if trade 1 is in -$10, then open trade 2
    if trade 1 & 2 are in -$30, then open trade 3, .....


    Thanks & Regards
    It is easier to do that for your second example where the total of the open positions is negative than it is for the first example where just any single position is negative.

    You can do the second example easily from within the existing function that has already been descibed.

    Before anything else, you must define a variable

    Code:
    double total_open_profit=0;
    In a new line between the OrderSelect() function and the if condition you then need to insert

    Code:
    double individual_open_profit=OrderProfit()+OrderSwap()+OrderCommission();
    Then, within the braces where the orders are counted and after orders_total;, you need to insert

    Code:
    total_open_profit=total_open_profit+individual_open_profit;
    What happens is that the function adds the profit from the current order to the previous total profit for every order that it counts. You can then use the value returned for total_open_profit to do your other things.
    Last edited by jezzer1961; 03-19-2009 at 09:46.

  2. #12
    Junior Member
    Join Date
    Jan 2009
    Posts
    18

    Default

    Quote Originally Posted by jidonk View Post
    Hi Perky_Z,

    Thanks for your help. But what I need is to COUNT all open trade not to Close all trades.

    I'm using:

    AllMyOrder = OrdersTotal();

    but it seems to count all open trades regardless the the pair/magic.


    Thanks
    hehehe couldnt make it too easy :-)

  3. #13

    Default

    Thanks a lot Jezzer

    Regards

Similar Threads

  1. Count trades on a certain bar
    By fxtester in forum MQL programming
    Replies: 0
    Last Post: 08-20-2014, 15:21
  2. Count historical trades on a certain bar
    By fxtester in forum MQL programming
    Replies: 0
    Last Post: 08-20-2014, 15:20
  3. Count all trades function
    By fxtester in forum MQL programming
    Replies: 0
    Last Post: 08-20-2014, 14:41
  4. I need an EA to open trades at a specific time
    By Johntrader in forum Scripts and other tools
    Replies: 0
    Last Post: 07-27-2012, 14:51
  5. Setting SL of all Trades on specific pairs
    By ixbone in forum MQL programming
    Replies: 9
    Last Post: 03-15-2009, 09:58

Tags for this Thread

change, eurusd, funyoo, how to, magic, magic number, profit

Posting Permissions

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