Results 1 to 7 of 7
 0 Attachment(s)    

Thread: EA works only on Demoaccount

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    4

    Default EA works only on Demoaccount

    This EA is trading only on demo. Who know why?
    Thanks for help.




    extern double GapRange = 10;
    extern double SL_Factor = 2;
    extern double TP_Factor = 3;
    extern double MM_Risk = 2;
    extern int ExpertID=844478;

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

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

    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| expert start function |
    //+------------------------------------------------------------------+
    int start()
    {
    //---- ONE TRADE PER BAR

    static bool ToTrade;

    if(NewBar() == true)
    {
    if(COT(1, 101187) == 0 && COT(2, 201187) == 0) ToTrade = true;
    }

    //---- GAP

    bool GAP;

    double CurrOpen = iOpen(NULL, 0, 0);
    double PrevClose = iClose(NULL, 0, 1);
    double Range = MathAbs(PrevClose - CurrOpen);

    if(Range >= GapRange * Point * 10) GAP = true;

    //---- TP / SL

    double ATR = iATR(NULL, 0, 13, 1);
    double Spread = MarketInfo(Symbol(), MODE_SPREAD) * Point;

    double TakeProfit = ATR * TP_Factor;
    double StopLoss = (ATR * SL_Factor) + Spread;

    //---- TRADE

    int Ticket;

    if(ToTrade == true && GAP == true)
    {
    if(CurrOpen < PrevClose)
    {
    Ticket = OrderSend(Symbol(), OP_BUY, LotSize(MM_Risk, StopLoss), Ask, 3, Ask - StopLoss, Ask + TakeProfit, "Gap_Trader.B", 101187, 0, Blue);

    if(Ticket < 0)
    {
    Print("Error in OrderSend : ", GetLastError());
    }
    else
    {
    ToTrade = false;
    }
    }

    if(CurrOpen > PrevClose)
    {
    Ticket = OrderSend(Symbol(), OP_SELL, LotSize(MM_Risk, StopLoss), Bid, 3, Bid + StopLoss, Bid - TakeProfit, "Gap_Trader.S", 201187, 0, Red);

    if(Ticket < 0)
    {
    Print("Error in OrderSend : ", GetLastError());
    }
    else
    {
    ToTrade = false;
    }
    }
    }

    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //+ Check Open Trades |
    //+------------------------------------------------------------------+
    int COT(int BS, int MN)
    {
    int Buys = 0, Sells = 0;

    for(int cnt_COT = 0; cnt_COT < OrdersTotal(); cnt_COT++)
    {
    OrderSelect(cnt_COT, SELECT_BY_POS, MODE_TRADES);

    if(OrderSymbol() == Symbol() && OrderMagicNumber() == MN && OrderType() == OP_BUY) Buys++;
    if(OrderSymbol() == Symbol() && OrderMagicNumber() == MN && OrderType() == OP_SELL) Sells++;
    }

    if(BS == 1) return(Buys);
    if(BS == 2) return(Sells);
    }
    //+------------------------------------------------------------------+
    //| LotSize |
    //+------------------------------------------------------------------+
    double LotSize(double Risk, double SL)
    {
    double MaxLot = MarketInfo(Symbol(), MODE_MAXLOT);
    double MinLot = MarketInfo(Symbol(), MODE_MINLOT);

    double StopLoss = SL / Point / 10;
    double Size = Risk / 100 * AccountBalance() / 10 / StopLoss;

    if(Size < MinLot) Size = MinLot;
    if(Size > MaxLot) Size = MaxLot;

    return(NormalizeDouble(Size, 2));
    }
    //+------------------------------------------------------------------+
    //| New Bar |
    //+------------------------------------------------------------------+
    bool NewBar()
    {
    static datetime PrevBar;

    if(PrevBar < Time[0])
    {
    PrevBar = Time[0];
    return(true);
    }
    else
    {
    return(false);
    }
    }

  2. #2
    Junior Member
    Join Date
    Jan 2011
    Location
    Vienna
    Posts
    6

    Default

    Are you sure you activated the execution of EAs on your real account ?
    Normaly I kno no restrictions on EAs.
    Software and Consulting for MetaTrader4 - MQLware - www.mqlware.com

  3. #3
    Junior Member
    Join Date
    Jan 2011
    Posts
    4

    Default

    I think I know now what the problem is. It dont work, because S/L and T/P set at the same time.
    Can someone modify it, that the EA open first a order, then set the S/L and T/P ?
    Thanks for help.

  4. #4
    Junior Member
    Join Date
    Jan 2011
    Location
    Vienna
    Posts
    6

    Default

    Its no problem to change the settings for TP and SL, although this should not be the reason, except you set them wrong.
    Use the OrderModify command to do this.
    Software and Consulting for MetaTrader4 - MQLware - www.mqlware.com

  5. #5
    Junior Member
    Join Date
    Jan 2011
    Posts
    4

    Default

    You know what/how I must modify it? My MQL is bad.

  6. #6
    Junior Member
    Join Date
    Jan 2011
    Location
    Vienna
    Posts
    6

    Default

    I keept your EA runing the last days on a Symbol in my Demo account and received error 130 which means the distance of the stop level is to close.

    But it also means that your EA will also trade when adding it to a chart.

    Which symbol do you trade with ?
    Software and Consulting for MetaTrader4 - MQLware - www.mqlware.com

  7. #7
    Junior Member
    Join Date
    Jan 2011
    Posts
    4

    Default

    Thank you,
    my broker told me now, it is not allowed T/P and S/L with the ending like .02 only with ending .0 or .5
    Because the price change is 0.5 points. If S/L is .03 its not working.
    Can you help me please what I must do?
    I trade the germanDAX and the backtest is great.

Similar Threads

  1. How forex works
    By painofhell in forum Trading discussion
    Replies: 0
    Last Post: 08-18-2014, 21:29
  2. EA works in backest but not live?
    By Doodman in forum Expert advisors live statements
    Replies: 1
    Last Post: 04-10-2012, 19:24
  3. EA that works with 4:1 RR
    By plork in forum Ideas for expert advisors
    Replies: 0
    Last Post: 08-20-2011, 12:44
  4. Need EA that works with 4:1 RR
    By plork in forum Trading discussion
    Replies: 0
    Last Post: 08-20-2011, 12:09
  5. There is an EA that really works?
    By Dima in forum Expert advisors backtesting
    Replies: 0
    Last Post: 01-25-2011, 11:17

Tags for this Thread

100, 2011, atr, backtest, broker, change, date, demo, ea works, eas, mql, real, sells, spread, stop, stoploss, thank you, time, trader, trading

Posting Permissions

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