help! why this simple break-out EA does not work?
Results 1 to 5 of 5

Thread: help! why this simple break-out EA does not work?

  1. #1
    This is a EA. Just a 20 days split system.

    When price split 20 days new high, buy. Exit when price reach's 10 day's reduced

    when price break 20 day new low, market. Exit when price reach's 10 day's high.

    Later initial open ticket, 2 more ticket could be added.


    But once I backtest from 2006 to now on EUR/USD, no trading occurred.

    Who can help find out what's the issue?


    //-- enter parameters
    extern double Lots = 0.1;
    extern int n_enter_days=20;
    extern int m_exit_days=10;
    //p------------------------------------------------------------------
    //| pro initialization serve |
    //p------------------------------------------------------------------
    int init()

    //--

    //--
    return(0);

    //p------------------------------------------------------------------
    //| pro deinitialization function |
    //p------------------------------------------------------------------
    int deinit()

    //--

    //--
    return(0);


    // ------------------------------------------------------------------
    //| expert start work |
    // ------------------------------------------------------------------
    datetime last_time=0;
    int start()

    int cnt, ticket, total;
    if(Barslt;100)

    Print(bars less than 100);
    return(0);

    total=OrdersTotal();
    if(Close[1]gt;Top[iHighest(Symbol(),Period(),MODE_HIGH,n_enter_days, 1)]
    last_time ! =Timing[0]
    totallt;3)

    ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,My EA,12345,0,Red);
    if(ticketgt;0)

    if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES ))
    Print(BUY order started : ,OrderOpenPrice());

    else

    Print(Error opening BUY order : ,GetLastError());
    return(0);


    last_time =Timing[0];


    if(Close[1]lt;Low[iLowest(Symbol(),Stage(),MODE_LOW,n_enter_days,1)]
    last_time ! =Timing[0]
    totallt;3)

    ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,M y EA,12345,0,Green);
    if(ticketgt;0)

    if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES ))
    Print(BUY order started : ,OrderOpenPrice());

    else

    Print(Error opening BUY order : ,GetLastError());
    return(0);


    last_time =Timing[0];


    for(cnt=0;cntlt;total;cnt )

    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    if(OrderType()lt;=OP_SELL OrderSymbol()==Symbol())

    if(OrderType()==OP_BUY) // long position is started

    if(Close[1]lt;Low[iLowest(OrderSymbol(),Stage(),MODE_LOW,m_exit_days ,1)])
    OrderClose(OrderTicket(),OrderLots(),Bid,3,White);



    if(OrderType()==OP_SELL)

    if(OrderType()==OP_BUY) // long position is started

    if(Close[1]gt;Top[iHighest(OrderSymbol(),Stage(),MODE_HIGH,m_exit_da ys,1)])
    OrderClose(OrderTicket(),OrderLots(),Ask,3,White);







    //--

    //--
    return(0);

    // ------------------------------------------------------------------

  2. #2
    Hello virtousity.... Consider changing the start bar from 1 to some larger number, maybe 2.... In all places...h


    Inserted Code in case(Close#91;1#93;lt;Low#91;iLowest(OrderSymbol() ,Period(),MODE_LOW,m_exit_days,2)Number93;-RRB- //-- //-- if(Close#91;1#93;gt;Top#91;iHighest(OrderSymbol(), Period(),MODE_HIGH,m_exit_days,2)Number93;-RRB- //-- //-- Low#91;iLowest(Symbol(),Period(),MODE_LOW, n_enter_days,2)Number93; //-- //-- Top#91;iHighest( Symbol(),Period(),MODE_HIGH,n_enter_days,2)Number9 3;

  3. #3
    Heyseed:
    why should change this manner?
    I shifted it. But no trade happened during 3 years.

    Is there some logical mistake?

    I'm using alphri demo accont to check this

  4. #4
    Hayseed:
    It's very good of you . You're of fantastic assistance . I will go on improve my system
    Thanks very much.

  5. #5
    hey virt.... The first code is stating as soon as the close[1] is greater than the highest high of the last 20 pubs, buy.... That can not happen.... Something has to be changed.... Once such change is to move close[1] out of the arrays span of time....

    Hence the two....

    other ways exist.... Such as using Ask rather than close[1]... and more....

    There are a number of places where your words aren't being truely reflected from the code.... That's very common.... It's all part of the process....

    My preference would have been to rewrite from scratch.... But here is what worked for me...h
    https://www.forexforum.co.za/attachm...1186159852.mq4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.