Results 1 to 4 of 4
 0 Attachment(s)    

Thread: Opposite Close

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    7

    Default Opposite Close

    I'd like to know to get
    Close sell + Buy and
    Close buy+ Sell at the same bar
    have I set oppositeclose input :true ?

    Thank you very much for your help
    Best Regards
    Massimo

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

    Default

    Quote Originally Posted by maxmiral View Post
    I'd like to know to get
    Close sell + Buy and
    Close buy+ Sell at the same bar
    have I set oppositeclose input :true ?

    Thank you very much for your help
    Best Regards
    Massimo
    Hi maxmiral,

    In the extern parameters, add :

    Code:
    extern bool oppositeclose=true;
    After the entry conditions in the start body, add :

    Code:
    if((oppositeclose && sell))closebuy();
    if((oppositeclose && buy))closesell();
    After the start(){} body, add :

    Code:
    //|---------close
    
    void closebuy(){
       RefreshRates();
       if(OrdersTotal()>0){
          for(int i=OrdersTotal();i>=0;i--){
             OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
             if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_BUY){
                OrderClose(OrderTicket(),OrderLots(),Bid,slippage*mt);
             }
          }
       }
    }
    
    void closesell(){
       RefreshRates();
       if(OrdersTotal()>0){
          for(int i=OrdersTotal();i>=0;i--){
             OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
             if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_SELL){
                OrderClose(OrderTicket(),OrderLots(),Ask,slippage*mt);
             }
          }
       }
    }
    Finally replace sell and buy by your respective parameters (that determine the nature of the signal).

    Or you can simply add closebuy() before the sell ordersend function and closesell() before the buy ordersend function.

  3. #3
    Junior Member
    Join Date
    Dec 2009
    Posts
    7

    Default Opposite Close and other filter

    Hi Funyoo,
    I modified extern bool oppositeclose=true and
    I added in Simple ZigZag v.1.01 piece of code
    " //|---------close

    void closebuy(){
    RefreshRates();
    if(OrdersTotal()>0){
    for(int i=OrdersTotal();i>=0;i--){
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
    if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_BUY){
    OrderClose(OrderTicket(),OrderLots(),Bid,slippage* mt);
    }
    }
    }
    }

    void closesell(){
    RefreshRates();
    if(OrdersTotal()>0){
    for(int i=OrdersTotal();i>=0;i--){
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
    if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_SELL){
    OrderClose(OrderTicket(),OrderLots(),Ask,slippage* mt);
    }
    }
    }
    } "

    Could you build another version of this EA this by adding another filter true or false

    I think "Laguerre filter" could be helpfull in this case (without take profit/stop loss (hide= true) )

    Close Sell + Buy only after ZigZag Pointer GreeArrow position on chart stable for 3-4-5 bars (as input selectable) and if price is only above Laguerre filter and then on other side and on reverse

    Close Buy + Sell only after ZigZag Pointer Red Arrow position on chart stable for 3-4-5 bars (as input selectable) and if price is only down Laguerre filter .

    Thank you very much and Happy New Year.
    Massimo

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

    Default

    Hi maxmiral,

    Please post your request in the Elite section.

Similar Threads

  1. Close all buy and close all sell orders
    By q8m2002 in forum Scripts and other tools
    Replies: 11
    Last Post: 12-01-2012, 04:38
  2. High/Low M1>M5 EA needs opposite close - Please help me
    By Sachse in forum Ideas for expert advisors
    Replies: 18
    Last Post: 11-02-2010, 19:59
  3. 10 pips Once A Day Opposite Last NHour Trend
    By funyoo in forum Expert advisors backtesting
    Replies: 5
    Last Post: 07-29-2009, 17:28
  4. Ea For Opposite Damiani Filter
    By kendr423 in forum Ideas for expert advisors
    Replies: 1
    Last Post: 01-30-2009, 07:49
  5. 10 pips Once A Day Opposite Last NHour Trend
    By funyoo in forum Expert advisors live statements
    Replies: 0
    Last Post: 11-13-2008, 12:27

Tags for this Thread

elite, profit, request, signal, simple, slippage, stop

Posting Permissions

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