Results 1 to 2 of 2
 0 Attachment(s)    

Thread: Error for the EA that trade in the same hours everyday

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

    Default Error for the EA that trade in the same hours everyday

    Hi all,

    Please help to check the below code, is there any error if I want to make this EA to put in a pending order at the same time everyday? I have tried to run the strategy tester, but end up it don't trade a single trade for 3 years period!!! I believe something wrong inside.

    Concept for this EA is:
    1. put the pending order for Buy stop and Sell stop at GMT5:59, anyone of them trigger, the other one will be deleted, and put down the expiration for them if they still haven't reach the SL or TP at GMT06:59.
    2. The Entry point for the Buy stop is the Highest close value between the current and previous bar, mean bar for GMT4 and GMT5, the Entry point for the Sell stop is the Lowest clost value between the current and the previous bar also.
    3. If the different for the Highest and the Lowest is more than 70 pips, then dun put the pending order.

    Please help to check any error or the improvement for the programming inside.
    *This program is actually modified from a program call 21hours, however it can't be work after i adjusted the entry point and time entry.

    Thanks.

    //------------------------------------------------------
    extern double Lots = 0.1;
    extern int ChasStartH = 05;
    extern int ChasStartM = 59;
    extern int ChasStopH = 06;
    extern int ChasStopM = 59;
    extern int SL = 40; //Stop Loss
    extern int TP = 100; //Take profit
    extern double BuyEP; //Entry point for Buy order
    extern double SellEP; //Entry point for Sell order

    int prevtime;
    //+------------------------------------------------------------------+
    //| expert initialization function |
    //+------------------------------------------------------------------+
    int init()
    {
    //----

    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| expert deinitialization function |
    //+------------------------------------------------------------------+
    int deinit()
    {
    //----

    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| expert start function |
    //+------------------------------------------------------------------+
    int start()
    {
    //----





    int OrderCountOtl=0;
    int i=0;
    int total = OrdersTotal();
    for(i = 0; i <= total; i++)
    {

    OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
    if(OrderMagicNumber() == 12321)
    {
    if (OrderType()>1) OrderCountOtl++;
    }

    }

    if (OrderCountOtl==1)
    {
    for(i = 0; i <= total; i++)
    {
    OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
    if(OrderMagicNumber() == 12321)
    {
    if (OrderType()>1) OrderDelete(OrderTicket());
    }
    }
    }


    if(Time[0] == prevtime)
    return(0);
    prevtime = Time[0];
    if(!IsTradeAllowed())
    {
    prevtime = Time[1];
    return(0);
    }



    if (TimeHour(TimeCurrent())==ChasStartH && TimeMinute(TimeCurrent())==ChasStartM)
    {
    If (High[1]>High[0])
    {
    BuyEP = High[1];
    }
    If (High[1]<High[0])
    {
    BuyEP = High[0];
    }
    If (Low[1]<Low[0])
    {
    SellEP = Low[1];
    }
    If (Low[1]>Low[0])
    {
    SellEP = Low[0];
    }
    If (BuyEP-SellEP)>70*Point
    {
    return(0);
    }
    OrderSend(Symbol(),OP_BUYSTOP,Lots,BuyEP,2,Ask-SL*Point,Ask+TP*Point,"",12321,0,Green);
    OrderSend(Symbol(),OP_SELLSTOP,Lots,SellEP,2,Bid+S L*Point,Bid- TP*Point,"",12321,0,Red);
    }

    if (TimeHour(TimeCurrent())==ChasStopH && TimeMinute(TimeCurrent())==ChasStopM)
    {
    i=0;
    total = OrdersTotal();
    for(i = 0; i <= total; i++)
    {
    OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
    if(OrderMagicNumber() == 12321)
    {
    if (OrderType()==OP_BUY)OrderClose(OrderTicket(),Orde rLots(),Bid,2,Green);
    if (OrderType()==OP_SELL)OrderClose(OrderTicket(),Ord erLots(),Ask,2,Green);
    if (OrderType()>1)OrderDelete(OrderTicket());
    }
    }
    }

    //----
    return(0);
    }

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

    Default Some admentment do inside

    Have done some mistake inside, here is the updated changes for the ordersend.

    OrderSend(Symbol(),OP_BUYSTOP,Lots,BuyEP+4*Point,3 ,BuyEP+(4-SL)*Point,BuyEP+(4+TP)*Point,"",12321,0,Green);
    OrderSend(Symbol(),OP_SELLSTOP,Lots,SellEP-4*Point,3,SellEP-(4-SL)*Point,SellEP-(4+TP)*Point,"",12321,0,Red)

    Anyone can help?

Similar Threads

  1. Live analyzing charts everyday + Ichimoku Winners ebook
    By al_agouz2010 in forum Technical analysis
    Replies: 2
    Last Post: 01-14-2014, 21:40
  2. Dealing The Everyday Charts Will Enhance Your Trading Results
    By forexmetal2015 in forum Trading discussion
    Replies: 0
    Last Post: 10-01-2012, 13:06
  3. Wait x hours to open new order after a losing trade
    By zickzack222 in forum MQL programming
    Replies: 1
    Last Post: 01-04-2011, 13:30
  4. Where is error ?
    By przem81621 in forum MQL programming
    Replies: 2
    Last Post: 07-09-2009, 07:34
  5. Two Hours EA
    By funyoo in forum Expert advisors backtesting
    Replies: 0
    Last Post: 04-17-2009, 19:00

Tags for this Thread

100, expert, hours, pips, programming, sells, stop, strategy, time

Posting Permissions

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