+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 22
 7 Attachment(s)    

Thread: My supertrend EA - help needed!

  1. #1
    Member
    Join Date
    Jan 2009
    Posts
    126

    Default My supertrend EA - help needed!

    Hi guys. I have a problem with an EA based on the supertrend indicator. Buys and sells need to take place when the colour changes, to show a trend change. The only problem with this EA is that it trades, sometimes, when the price hits the supertrend line (see the attached image). It should only trade AFTER the the colour change. Is there a solution to this?

    It trades on the 1M EURUSD with the multiplier settings set to 10. If the above issue can be resolved, it can be quite a profitable EA.

    This EA was kindly created by Funyoo, now I am hoping someone else can have a look at its coding.
    Attached Images  
    Attached Files

  2. #2
    Member
    Join Date
    Jan 2009
    Posts
    151

    Default

    It looks to me like it should be entering on new bar open only.

    Here's a function that will return TRUE if a new bar has just formed:

    // This function returns TRUE at the very first tick a bar i.e. after the previous bar has just closed
    bool NewBar()
    {
    if(PreviousBarTime<Time[0])
    {
    PreviousBarTime = Time[0];
    return(true);
    }

    return(false); // in case if - else statement is not executed
    } you need to declare datetime PreviousBarTime at the beginning of your EA...
    then in your code you could just use
    if ( NewBar() )
    {
    ...... code you need to be executed after a bar has closed here ....
    }

  3. #3
    Member
    Join Date
    Jan 2009
    Posts
    126

    Default

    HI jezzer, thanks for your time! Can you do me a favour and add the code in the right place for me? I am useless at all this!

    Anyone else is welcome to help if they can!

  4. #4
    Member
    Join Date
    Jan 2009
    Posts
    151

    Default

    That's no problem, Viv. I'm happy to do it but it will have to go to the bottom of my "To Do" list and it might take a week or two before I even get round to looking at it.

    I posted a possible solution to your problem, because this was far quicker, and someone else might like to give it a go. I think as well that it might be best to insert an extern bool, to give the option of entering on bar close only or not. What might work on M1 for instance wouldn't necessarily work on other timeframes, so I think it would be better to have the option of both.

  5. #5
    Member
    Join Date
    Jan 2009
    Posts
    126

    Default

    Thanks jezzer. I have asked Funyoo to have a look, but please keep it on your 'to do' pile incase he is unable to help. I am suer its not a big job. I will let you know if someone else has managed to change the code so it can be taken off your list. Thanks for your help!

  6. #6
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,455

    Default

    Quote Originally Posted by jezzer1961 View Post
    That's no problem, Viv. I'm happy to do it but it will have to go to the bottom of my "To Do" list and it might take a week or two before I even get round to looking at it.

    I posted a possible solution to your problem, because this was far quicker, and someone else might like to give it a go. I think as well that it might be best to insert an extern bool, to give the option of entering on bar close only or not. What might work on M1 for instance wouldn't necessarily work on other timeframes, so I think it would be better to have the option of both.
    Hi jezzer1961 and welcome!

    Quote Originally Posted by Viv108 View Post
    Thanks jezzer. I have asked Funyoo to have a look, but please keep it on your 'to do' pile incase he is unable to help. I am suer its not a big job. I will let you know if someone else has managed to change the code so it can be taken off your list. Thanks for your help!
    Hi Viv108,

    At line 137, after "return(0);}", add :

    Code:
    bool NewBar()
    {
    if(PreviousBarTime<Time[0])
    {
    PreviousBarTime = Time[0];
    return(true);
    }
    
    return(false); // in case if - else statement is not executed
    }
    At line 84, before ")SELL="true";", add :

    Code:
    &&NewBar()
    At line 83, before ")BUY="true";", add :

    Code:
    &&NewBar()
    At line 55, add :

    Code:
    datetime PreviousBarTime;

  7. #7
    Member
    Join Date
    Jan 2009
    Posts
    126

    Default

    i've done this. Back tested it.. seems much better than before! Thanks so much guys. Will let you know how it goes!

  8. #8
    Member
    Join Date
    Nov 2008
    Posts
    98

    Default

    Quote Originally Posted by Viv108 View Post
    i've done this. Back tested it.. seems much better than before! Thanks so much guys. Will let you know how it goes!
    can you share this indicator again in this thread? The EA is calling for the indicator.

  9. #9
    Member
    Join Date
    Dec 2008
    Location
    Germany
    Posts
    76

    Default Supertrend EA

    Hi folks,
    the Supertrend indicator is posted at the parabolic SAR EA Thread, there you can download at page three.

    I recognized that at 1 min timeframe the colour often changes within the candle. So my best advise, maybe trade higher timeframe. Try 5 or 15 min.

    Regards

    Criss

  10. #10
    Member
    Join Date
    Oct 2008
    Posts
    273

    Default

    Viv108,

    Whtat SL, TP, and TS are you using for this EA?
    Attached Files

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast

Similar Threads

  1. EA needed for this indicator plz.
    By cashgrade in forum Indicators
    Replies: 2
    Last Post: 01-19-2010, 01:54
  2. sa MTEI Supertrend EA
    By funyoo in forum Expert advisors backtesting
    Replies: 9
    Last Post: 08-15-2009, 21:31
  3. Simple EA needed for indicator
    By forexpop in forum MQL programming
    Replies: 0
    Last Post: 07-16-2009, 03:00
  4. sa MTEI Supertrend
    By magidkaramy in forum Ideas for expert advisors
    Replies: 1
    Last Post: 12-06-2008, 17:33

Posting Permissions

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