Results 1 to 2 of 2
 0 Attachment(s)    

Thread: Close few trades after profit

  1. #1

    Default Close few trades after profit

    I'm looking for code :
    it,s open first trade 0.1 lot with current loss=-10
    second 0,2 lot =-5
    third 0,4 lot profit=+20
    -------------------------------------------------
    sum =+5

    how to close this open trades after all sum profit= X value ?

  2. #2

    Default

    double prof = 0;

    for(int i=0; i < OrdersTotal(); i++)
    {
    OrderSelect(i, SELECT_BY_POS);

    if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic.Number)
    prof += OrderProfit();
    }

    if(prof == YourProfitTarget)
    {
    //Close all trades
    for(i=0; i < OrdersTotal(); i++)
    {
    OrderSelect(i, SELECT_BY_POS);

    if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic.Number)
    {
    if(OrderType() == OP_BUY)
    //Close trade here...

    if(OrderType() == OP_SELL)
    //Close short trade here...
    }
    }

    }
    FXCode Inc.
    Expert Advisor Developer

Similar Threads

  1. Close all trades equity at level
    By joseclar in forum Ideas for expert advisors
    Replies: 0
    Last Post: 12-04-2015, 23:24
  2. Time Confirmation for Close Trades
    By FX-BoT-FX in forum MQL programming
    Replies: 0
    Last Post: 03-08-2012, 20:18
  3. Replies: 2
    Last Post: 05-25-2009, 17:59
  4. Close all open trades after every x profit
    By begu in forum MQL programming
    Replies: 1
    Last Post: 04-09-2009, 19:03

Tags for this Thread

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
  •