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

Thread: BasketPercent

  1. #1
    Member
    Join Date
    May 2009
    Posts
    85

    Default BasketPercent

    Hey funyoo.

    In order to avoid always asking for basic functions, could you enlight me how to add basketpercent function to a code?
    (I am not a programmer, so it will be on a copy-past base).

    thank you.

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

    Default

    Quote Originally Posted by civfan View Post
    Hey funyoo.

    In order to avoid always asking for basic functions, could you enlight me how to add basketpercent function to a code?
    (I am not a programmer, so it will be on a copy-past base).

    thank you.
    Hi civfan,

    Extern parameters :

    Code:
    extern bool basketpercent=false;       // enable the basket percent
    extern double profit=10;               // close all orders if a profit of 10 percents has been reached
    extern double loss=30;                 // close all orders if a loss of 30 percents has been reached
    Start body :

    Code:
    if(basketpercent){
          if(closebasket==false)closebasket=closebasketpercent(profit,loss);
          if(closebasket){closebuy();closesell();delete(OP_BUYSTOP);delete(OP_SELLSTOP);delete(OP_BUYLIMIT);delete(OP_SELLLIMIT);}
          if(closebasket && count(OP_BUY)+count(OP_SELL)+count(OP_BUYLIMIT)+count(OP_SELLLIMIT)+count(OP_BUYSTOP)+count(OP_SELLSTOP)==0)closebasket=false;
       }
    Functions :

    Code:
    //|---------basket
    
    bool closebasketpercent(double profit,double loss){
       double ipf,ilo;
       ipf=profit*(0.01*AccountBalance());
       ilo=loss*(0.01*AccountBalance());
       cb=AccountEquity()-AccountBalance();
       if(cb>=ipf || cb<=(ilo*(-1)))return(1);
       return(0);
    }
    
    //|---------delete
    
    void delete(int type){
       if(OrdersTotal()>0){
          for(i=OrdersTotal();i>=0;i--){
            OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
            if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==type){
              OrderDelete(OrderTicket());
            }   
          }
       }
    }

  3. #3
    Member
    Join Date
    May 2009
    Posts
    85

    Default

    Thank you funyoo, you are the man!

  4. #4
    Member
    Join Date
    May 2009
    Posts
    85

    Default

    well I guess I am not copy-past it right...

    "2;75;C:\Program Files\Broco backtesting\experts\The Channel Scalper 1.11ZZ.mq4;169:60;'profit' - variable not defined
    2;75;C:\Program Files\Broco backtesting\experts\The Channel Scalper 1.11ZZ.mq4;169:67;'loss' - variable not defined
    2;75;C:\Program Files\Broco backtesting\experts\The Channel Scalper 1.11ZZ.mq4;682:7;'basketmode' - variable not defined
    2;75;C:\Program Files\Broco backtesting\experts\The Channel Scalper 1.11ZZ.mq4;687:7;'basketmode' - variable not defined
    2;75;C:\Program Files\Broco backtesting\experts\The Channel Scalper 1.11ZZ.mq4;692:7;'basketmode' - variable not defined"

  5. #5
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,178

    Default

    Quote Originally Posted by civfan View Post
    well I guess I am not copy-past it right...

    "2;75;C:\Program Files\Broco backtesting\experts\The Channel Scalper 1.11ZZ.mq4;169:60;'profit' - variable not defined
    2;75;C:\Program Files\Broco backtesting\experts\The Channel Scalper 1.11ZZ.mq4;169:67;'loss' - variable not defined
    2;75;C:\Program Files\Broco backtesting\experts\The Channel Scalper 1.11ZZ.mq4;682:7;'basketmode' - variable not defined
    2;75;C:\Program Files\Broco backtesting\experts\The Channel Scalper 1.11ZZ.mq4;687:7;'basketmode' - variable not defined
    2;75;C:\Program Files\Broco backtesting\experts\The Channel Scalper 1.11ZZ.mq4;692:7;'basketmode' - variable not defined"
    Hi civfan,

    Be sure to add the extern parameters,

    There is no basketmode option.

+ Reply to Thread

Posting Permissions

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