+ Reply to Thread
Results 1 to 2 of 2
 0 Attachment(s)    

Thread: Close all open trades after every x profit

  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    9

    Red face Close all open trades after every x profit

    hello finyoo

    is it possible to code close all open trades after every x profit:

    example:
    begin balance= 1000

    extern double = 200; (USD)

    if (AccountProfit()>=1200 close all open trades (for close all positions i have a call function)

    if (AccountProfit()>=1400.- close all open trades
    "
    "
    if (AccountProfit()>=1600.- close all open trades
    "
    "
    and so on ....

    thanks for help

    begu

  2. #2
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,455

    Default

    Quote Originally Posted by begu View Post
    hello finyoo

    is it possible to code close all open trades after every x profit:

    example:
    begin balance= 1000

    extern double = 200; (USD)

    if (AccountProfit()>=1200 close all open trades (for close all positions i have a call function)

    if (AccountProfit()>=1400.- close all open trades
    "
    "
    if (AccountProfit()>=1600.- close all open trades
    "
    "
    and so on ....

    thanks for help

    begu
    Hi begu,

    Yes that's possible. You have to study GlobalVariableSet/GlobalVariableGet.

    With something like this :

    Code:
    extern double MinProfit=200;
    Code:
    int init()
    {
       GlobalVariableSet("Balance",AccountBalance());
       return(0);
    }
    Code:
    if(AccountBalance()>GlobalVariableGet("Balance"))GlobalVariableSet("Balance",AccountBalance());
    
    if(AccountEquity()>=(GlobalVariableGet("Balance")+MinProfit))Close all open trades

+ Reply to Thread

Similar Threads

  1. Close all buy and close all sell orders
    By q8m2002 in forum Scripts and other tools
    Replies: 8
    Last Post: 12-17-2010, 05:33
  2. Add Close previous order when open new position
    By darkkiller in forum MQL programming
    Replies: 1
    Last Post: 03-21-2009, 04:55
  3. Replies: 12
    Last Post: 03-19-2009, 18:28
  4. How to close open orders?
    By juhanimi in forum MQL programming
    Replies: 0
    Last Post: 03-05-2009, 07:49
  5. Friday close price-monday open
    By przem81621 in forum Ideas for expert advisors
    Replies: 4
    Last Post: 02-22-2009, 11:08

Posting Permissions

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