+ Reply to Thread
Results 1 to 7 of 7
 1 Attachment(s)    

Thread: Day Filter & Close All Order

  1. #1
    Member
    Join Date
    Jan 2009
    Posts
    48

    Default Day Filter & Close All Order

    Hello guys

    Can somebody help/show me how to add "Day Filter" & "Close All Order" function. For e.g if someone doesn't want to trade on Friday(select friday for both function), then the function should not open any new trade on fridays and also should automatically close all open orders/pending orders of the previous days.

    Thanks in advance

    Regards

  2. #2
    Member
    Join Date
    Oct 2010
    Location
    Australia
    Posts
    214

    Default

    Which Ea?

    Does it already have the time filter options in the code?

    You want to close all orders at a particular time? and not reopen any orders until monday for example?

  3. #3
    Member
    Join Date
    Jan 2009
    Posts
    48

    Default

    Quote Originally Posted by arbus View Post
    Which Ea?

    Does it already have the time filter options in the code?

    You want to close all orders at a particular time? and not reopen any orders until monday for example?
    well its a personal martingale ea. I already add time filter...just need the code of close order function.
    Yes it should close all orders at a particular day and time and should not open any new orders until a selected day and time.
    Hopefully you understand and help.
    Thanks

  4. #4
    Member
    Join Date
    Jan 2009
    Location
    Austria
    Posts
    310

    Default

    try like this:

    extern bool CloseOutSide=false/true

    if(checktime()){
    if(CloseOutSide){CloseAll();}
    return(0);
    }


    void CloseAll(){
    for(int h=OrdersTotal();h>=0;h--){
    OrderSelect(h,SELECT_BY_POS,MODE_TRADES);
    if(OrderTicket()>0){
    for(int i=1;i<=NumberOfTries;i++){
    RefreshRates();
    bool TicketClosed=OrderClose(OrderTicket(),OrderLots(), NormalizeDouble(OrderClosePrice(),Digits),Slippage *mt,Yellow);

    IX
    IXBONE
    Forex VPS, IX Trader Forex Software
    Business Internet Services
    Registered Internet Service Provider (Ripe: AS 16195)

  5. #5
    Member
    Join Date
    Jan 2009
    Posts
    48

    Default

    Quote Originally Posted by ixbone View Post
    try like this:

    extern bool CloseOutSide=false/true

    if(checktime()){
    if(CloseOutSide){CloseAll();}
    return(0);
    }


    void CloseAll(){
    for(int h=OrdersTotal();h>=0;h--){
    OrderSelect(h,SELECT_BY_POS,MODE_TRADES);
    if(OrderTicket()>0){
    for(int i=1;i<=NumberOfTries;i++){
    RefreshRates();
    bool TicketClosed=OrderClose(OrderTicket(),OrderLots(), NormalizeDouble(OrderClosePrice(),Digits),Slippage *mt,Yellow);

    IX

    thanks for reply...can u tel how this gonna function.
    Can u show how to add only day filter code.
    Thanks

  6. #6
    Member
    Join Date
    Jan 2009
    Location
    Austria
    Posts
    310

    Default

    the whole function

    IX

    //+----------------------------------------------------------------------------+
    //| Time filter functions |
    //+----------------------------------------------------------------------------+
    bool checktime(){

    string svrdate=Year()+"."+Month()+"."+Day();

    if(MondayFilter){
    nmondayhour=MondayHour;
    if(nmondayhour<10)imondayhour="0"+nmondayhour;
    if(nmondayhour>9)imondayhour=nmondayhour;
    if(MondayMinute<10)imondayminute="0"+MondayMinute;
    if(MondayMinute>9)imondayminute=MondayMinute;
    tmonday=StrToTime(svrdate+" "+imondayhour+":"+imondayminute);
    }
    if(WeekFilter){
    nstarthour=StartHour;
    if(nstarthour<10)istarthour="0"+nstarthour;
    if(nstarthour>9)istarthour=nstarthour;
    if(StartMinute<10)istartminute="0"+StartMinute;
    if(StartMinute>9)istartminute=StartMinute;
    tstart=StrToTime(svrdate+" "+istarthour+":"+istartminute);

    nendhour=EndHour;
    if(EndHour<10)iendhour="0"+nendhour;
    if(EndHour>9)iendhour=nendhour;
    if(EndMinute<10)iendminute="0"+EndMinute;
    if(EndMinute>9)iendminute=EndMinute;
    tend=StrToTime(svrdate+" "+iendhour+":"+iendminute);
    }
    if(FridayFilter){
    nfridayhour=FridayHour;
    if(nfridayhour<10)ifridayhour="0"+nfridayhour;
    if(nfridayhour>9)ifridayhour=nfridayhour;
    if(FridayMinute<10)ifridayminute="0"+FridayMinute;
    if(FridayMinute>9)ifridayminute=FridayMinute;
    tfriday=StrToTime(svrdate+" "+ifridayhour+":"+ifridayminute);
    }
    if(WeekFilter)if((nstarthour<=nendhour && TimeCurrent()<tstart || TimeCurrent()>tend) || (nstarthour>nendhour && TimeCurrent()<tstart && TimeCurrent()>tend))return(true);
    if(TradeSunday==false)if(DayOfWeek()==0)return(tru e);
    if(FridayFilter)if(DayOfWeek()==5 && TimeCurrent()>tfriday)return(true);
    if(MondayFilter)if(DayOfWeek()==1 && TimeCurrent()<tmonday)return(true);
    return(false);
    }
    IXBONE
    Forex VPS, IX Trader Forex Software
    Business Internet Services
    Registered Internet Service Provider (Ripe: AS 16195)

  7. #7
    Member
    Join Date
    Jan 2009
    Posts
    48

    Default Add Filters

    Well am not able to put the code correctly so can you help
    here is the marty EA
    need...
    1. Max order
    2. Time filter
    3. Day filter
    4. Stoploss/Equity Stop will be an added advantage ;-)

    Thanks
    Attached Files

+ Reply to Thread

Similar Threads

  1. Replies: 1
    Last Post: 05-18-2011, 17:17
  2. Close all profitable order
    By fairylord in forum Scripts and other tools
    Replies: 2
    Last Post: 09-22-2009, 17:09
  3. Close OLDEST Order...
    By BillR in forum MQL programming
    Replies: 0
    Last Post: 08-22-2009, 14:38
  4. Add Close previous order when open new position
    By darkkiller in forum MQL programming
    Replies: 1
    Last Post: 03-21-2009, 04:55

Posting Permissions

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