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,003

    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

Similar Threads

  1. Replies: 1
    Last Post: 09-03-2011, 21:22
  2. Replies: 2
    Last Post: 04-15-2010, 16:44
  3. Close few trades after profit
    By przem81621 in forum MQL programming
    Replies: 1
    Last Post: 05-29-2009, 09:12
  4. Replies: 2
    Last Post: 05-25-2009, 17:59

Tags for this Thread

100, profit, study, usd

Posting Permissions

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