Results 1 to 2 of 2
 0 Attachment(s)    

Thread: Filter Trades When MA Is Flat

  1. #1
    Junior Member
    Join Date
    May 2009
    Posts
    1

    Default Filter Trades When MA Is Flat

    Can anyone please help me on how to script a program in expert advisor so that trades will not occur when MA (at prior bar) is flat?
    Suppose there is a fast MA and slow MA. I would like to have no trades when the direction of slow MA was flat on the previous bar.

    Thank you and regards,
    Daddy630

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

    Default

    Quote Originally Posted by daddy630 View Post
    Can anyone please help me on how to script a program in expert advisor so that trades will not occur when MA (at prior bar) is flat?
    Suppose there is a fast MA and slow MA. I would like to have no trades when the direction of slow MA was flat on the previous bar.

    Thank you and regards,
    Daddy630
    Hi daddy630,

    Code:
    extern bool flatmafilter=false;
    extern int maperiod=100;
    extern int shift=1;
    Code:
    if(buy/sell entry conditions...
    && (flatmafilter==false || (flatmafilter && NormalizeDouble(iMA(NULL,0,maperiod,0,MODE_SMA,PRICE_CLOSE,shift),Digits)!=NormalizeDouble(iMA(NULL,0,maperiod,0,MODE_SMA,PRICE_CLOSE,shift+1),Digits)))
    )buy/sell=true;

Similar Threads

  1. Flat and Non Flat Bars EA
    By funyoo in forum Expert advisors backtesting
    Replies: 7
    Last Post: 07-07-2010, 15:28
  2. Flat and Non Flat Bars EA
    By funyoo in forum Expert advisors live statements
    Replies: 1
    Last Post: 06-22-2010, 10:11
  3. Replies: 3
    Last Post: 06-14-2010, 16:49
  4. XMA filter - new trend filter, check it out
    By Metatrader7 in forum Ideas for expert advisors
    Replies: 13
    Last Post: 05-09-2010, 09:06

Tags for this Thread

100, advisor, expert, expert advisor, how to, sma

Posting Permissions

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