Page 1 of 3 123 LastLast
Results 1 to 10 of 23
 7 Attachment(s)    

Thread: My supertrend EA - help needed!

  1. #1

    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 Images My supertrend EA - help needed!-supertrend3-jpg 
    Attached Files Attached Files

  2. #2

    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

    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

    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

    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,003

    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

    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

    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

    Default

    Viv108,

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

Similar Threads

  1. Supertrend EA Request
    By best2004 in forum Ideas for expert advisors
    Replies: 10
    Last Post: 05-24-2017, 17:15
  2. KG SuperTrend EA
    By PPI in forum Ideas for expert advisors
    Replies: 14
    Last Post: 07-23-2014, 21:13
  3. SuperTrend
    By cyril.dumas in forum Indicators
    Replies: 2
    Last Post: 05-16-2011, 22:41
  4. SuperTrend MTF Bars EA...
    By claypot in forum Ideas for expert advisors
    Replies: 9
    Last Post: 10-11-2010, 04:24
  5. sa MTEI Supertrend
    By magidkaramy in forum Ideas for expert advisors
    Replies: 1
    Last Post: 12-06-2008, 18:33

Tags for this Thread

100, broker, candle, change, coding, currency pairs, eas, eurusd, expert, funyoo, indicator, magic, magic number, main, managed, parabolic sar, profit, profitable, sells, stop, time, trailing

Posting Permissions

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