Results 1 to 6 of 6
 0 Attachment(s)    

Thread: MTF EA Programming

  1. #1
    Junior Member
    Join Date
    Jan 2009
    Posts
    18

    Default MTF EA Programming

    I am attempting to program an EA that looks at the state of the trend in multiple time frames. All timeframes trend, the higher frames have more filtering. This I feel can increase the odds of a winning EA.

    In a singe time frame I use the function NewBar() which executes my code at the start of a new bar. This makes entry/exit more stable as the real time data does not effect the trade.

    What I am trying to do is look at the trends of multiple time frames (MTF). If the last closed bar and the one previous to it indicate a trend, then I trade in the lower timeframes only in the direction of the Higher timeframe trend.

    Does anybody have some code to post that if an EA is on the 5M timeframe chart, it can also look at and indicate the closing of bars on the 15M and 30M charts?

    For example if the following 2 MTF functions in an EA are attached to a 5M chart the following must happen:

    double NLMASigM5 = iCustom(NULL, 0,"MTF_NonLagMA_v7.1 SW", TimeFrame3, Price3, Length3, 0.0, 1.0 ,0, Current + 1);

    this looks at the state of the previous 5min bar, that is 1 to 5 minutes ago.

    This function also appears to look at the MTF indicator state at the close of the previous 5M bar. This value is however not fixed as the value can change until the 15M bar is complete (repaint over 3 5M bars)

    double NLMASigM15 = iCustom(NULL, 0,"MTF_NonLagMA_v7.1 SW", TimeFrame4, Price4, Length4, 0.0, 1.0 ,0, Current + 1);

    What I want is for this function to look at the value of the last closed 15 min bar.

    Any ideas?

    Here is the NewBar function if anybody wants.

    //=======================New Bar Function

    bool NewBar()
    {
    static datetime lastbar = 0;
    datetime curbar = Time[0];
    if(lastbar!=curbar)
    {
    lastbar=curbar;
    return (true);
    }
    else
    {
    return(false);
    }
    }

    thanks

    GAC

  2. #2

    Default

    double NLMASigM15 = iCustom(NULL, 15,"MTF_NonLagMA_v7.1 SW", TimeFrame4, Price4, Length4, 0.0, 1.0 ,0, 1);

  3. #3
    Junior Member
    Join Date
    Jan 2009
    Posts
    18

    Default

    Thanks for the quick reply.

    Will try it out.

    GAC

  4. #4

    Default

    No problem. What I would actually do in your position would be to make the timeframe and shift into external integers on Global Scope.

    Then you can optimise the EA against different timeframes/shifts and you might even find that M15 isn't the best trend timeframe after all. This would make sense as you seem to have variable parameters for the other indicator settings.

    edit: Looking again at your line of code - you seem to be using iCustom to reference the MTF version of the indicator. Don't - just use the normal non-MTF version.

    Sorry, I didn't notice that when I quickly posted yesterday.
    Last edited by jezzer1961; 03-16-2009 at 08:11.

  5. #5
    Junior Member
    Join Date
    Jan 2009
    Posts
    18

    Default Replaced MTF

    Thanks once again Jez. Have done what you suggested and it is working. Am starting testing. I am trying to get the odds more in my favour by looking at the trend in different timeframes and then trading in the 5m. Will see how it goes.

    thanks

    GAC

  6. #6

    Default your results

    I'd like to know how you go with your results. So please let me know.

Similar Threads

  1. Programming help please
    By Leverage1 in forum MQL programming
    Replies: 0
    Last Post: 03-20-2012, 04:02
  2. Programming help please
    By Leverage1 in forum MQL programming
    Replies: 2
    Last Post: 02-01-2012, 18:54
  3. Problems with programming EAs
    By bbbtrader in forum Ideas for expert advisors
    Replies: 0
    Last Post: 11-23-2010, 20:52
  4. Help needed for programming EA
    By vassil88 in forum MQL programming
    Replies: 0
    Last Post: 10-11-2010, 16:45

Tags for this Thread

5m timeframe, change, closing, color, date, ea programming, indicator, programming, real, repaint, time, trading, trend

Posting Permissions

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