Results 1 to 10 of 10
 0 Attachment(s)    

Thread: Setting SL of all Trades on specific pairs

  1. #1
    Member
    Join Date
    Jan 2009
    Location
    Austria
    Posts
    325

    Default Setting SL of all Trades on specific pairs

    Hi all,

    have anyone SL code piece for an EA like this:

    extern int EURUSDStopLoss=200; //Fixed loss of all open orders, closes all orders in loss of a specific pair.
    We have 4 open orders, all in negative profit
    0.01 = -10pips
    0.02 = -20pips
    0.04 = -40pips
    0.08 = -80pips
    Summ negativ pips = 150pips

    Now if we reach with all orders of eur/usd -200pips, all orders should be closed at this specific pair with loss of 200pips. Magic should be included.
    Could be hidden too.

    Different SL styles very welcome

    thanks for help

    IX
    Last edited by ixbone; 03-13-2009 at 15:33.

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

    Default

    Hi ixbone,

    Code:
    double TotalProfit=0;
    for(int cnt=OrdersTotal()-1;cnt>=0;cnt--)
    {
       OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
       if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
          if(OrderType()==OP_BUY || OrderType()==OP_SELL)
          {
             TotalProfit=TotalProfit+OrderProfit()/OrderLots();
          }
    }
          
    if(TotalProfit<=EURUSDStopLoss*-1)CloseAll();
    You have also to take in consideration the swap and the commission.

  3. #3
    Member
    Join Date
    Jan 2009
    Location
    Austria
    Posts
    325

    Default

    Quote Originally Posted by funyoo View Post
    Hi ixbone,

    Code:
    double TotalProfit=0;
    for(int cnt=OrdersTotal()-1;cnt>=0;cnt--)
    {
       OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
       if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
          if(OrderType()==OP_BUY || OrderType()==OP_SELL)
          {
             TotalProfit=TotalProfit+OrderProfit()/OrderLots();
          }
    }
          
    if(TotalProfit<=EURUSDStopLoss*-1)CloseAll();
    You have also to take in consideration the swap and the commission.

    thanks funyoo,

    you know, yesterday 12/03/2009:14:00 chf drops unexpectly, so eur/chf rises 500 pips at once, usd/chf rises 450 pips, gbp/chf 650 pips and so on.
    today all */chf doesnt reverse, so some of my demos are still alive with a high floating, all demos active without margin calls.

    to protect my account, if this setting for eur/chf was -200, no high floating occours, saves margin, equity and nerves.

    i'll test and report back

    IX

  4. #4
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by ixbone View Post
    thanks funyoo,

    you know, yesterday 12/03/2009:14:00 chf drops unexpectly, so eur/chf rises 500 pips at once, usd/chf rises 450 pips, gbp/chf 650 pips and so on.
    today all */chf doesnt reverse, so some of my demos are still alive with a high floating, all demos active without margin calls.

    to protect my account, if this setting for eur/chf was -200, no high floating occours, saves margin, equity and nerves.

    i'll test and report back

    IX
    Yes, most of my demo accounts have exploded.

    It was a really particular day.

  5. #5
    Member
    Join Date
    Jan 2009
    Location
    Austria
    Posts
    325

    Default

    Quote Originally Posted by funyoo View Post
    Yes, most of my demo accounts have exploded.

    It was a really particular day.
    IX EA?

    i think. the allorders stoploss is the solution to avoid this szenario

    After testing your code it generates over 20 errors, i have to evalute this later.

    My 500bucks demo is still alive, usd/chf, hits me....
    Balance 970, Floating 330

    If i requote to your message, i cant attach a gif with 110kb

    IX

  6. #6
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by ixbone View Post
    IX EA?
    No, correlation EAs and some other martingale EAs.

    Quote Originally Posted by ixbone View Post
    After testing your code it generates over 20 errors, i have to evalute this later.

    My 500bucks demo is still alive, usd/chf, hits me....
    Balance 970, Floating 330

    If i requote to your message, i cant attach a gif with 110kb

    IX
    Strange, the maximum is 1Mb, maybe the dimension is too high (max 1600*1000), or there is an unknown character.

  7. #7
    Member
    Join Date
    Jan 2009
    Location
    Austria
    Posts
    325

    Default

    Quote Originally Posted by funyoo View Post
    No, correlation EAs and some other martingale EAs.



    Strange, the maximum is 1Mb, maybe the dimension is too high (max 1600*1000), or there is an unknown character.

    i think the dimension...my remote desktop connection works at 1920, vps too

  8. #8
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by ixbone View Post
    i think the dimension...my remote desktop connection works at 1920, vps too
    Ok I have modified it. Try again.

  9. #9
    Member
    Join Date
    Jan 2009
    Location
    Austria
    Posts
    325

    Default

    Quote Originally Posted by funyoo View Post
    Ok I have modified it. Try again.
    resolution 1920x1080, now it works

    demo500 account floating now 255bucks

  10. #10
    Member
    Join Date
    Jan 2009
    Location
    Austria
    Posts
    325

    Default

    Quote Originally Posted by funyoo View Post
    Hi ixbone,

    Code:
    double TotalProfit=0;
    for(int cnt=OrdersTotal()-1;cnt>=0;cnt--)
    {
       OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
       if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
          if(OrderType()==OP_BUY || OrderType()==OP_SELL)
          {
             TotalProfit=TotalProfit+OrderProfit()/OrderLots();
          }
    }
          
    if(TotalProfit<=EURUSDStopLoss*-1)CloseAll();
    You have also to take in consideration the swap and the commission.
    Hi funyoo,

    after checking, rechecking, double checking, your good code which selects "all", is this possible:

    - trading on 4 majors, but checking the loss of specific pair/ seperate buy, sell orders
    - extern string BuyEURUSD = "EURUSD"
    - extern string SellEURUSD = "EURUSD"
    - setting max loss of a specific pair on all buy orders (extern int BuyEURUSDMaxLoss= 500)
    - setting max loss of a specific pair on all sell orders (extern int SellEURUSDMaxLoss=350)
    - now selecting all e/u buy orders, count the loss, if higher or equal -500, close all buy e/u orders, if less then -500 then leave all e/u buy orders open
    - now selecting all e/u sell orders, count the loss, if higher or equal -350, close all sell e/u orders, if less then -350 then leave all e/u sell orders open
    - if max loss reached, buy or sell, trading on this pair should be disabled (if buy max loss reached and sell max loss not, disable trading, closing all buy, leaving the sell orders open = no new sell trades)

    same routine for all other majors too
    thx funyoo for help, i know this a is more specific exercise

    IX

Similar Threads

  1. How Cross Currency Pairs Affect Dollar Pairs
    By painofhell in forum Trading discussion
    Replies: 0
    Last Post: 04-24-2015, 12:00
  2. 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
  3. Monitoring trades on other currency pairs.
    By arbus in forum MQL programming
    Replies: 0
    Last Post: 09-04-2011, 15:13
  4. Help for setting this ea
    By cimi in forum MQL programming
    Replies: 2
    Last Post: 04-09-2009, 22:12
  5. Replies: 12
    Last Post: 03-19-2009, 19:28

Tags for this Thread

100, closing, commission, correlation, demo, eas, eur, eur/usd, high, magic, martingale, pairs, stoploss, test, trading, 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
  •