EA Demo Vs Real

 

Hi expert,

I'm was running EA for Automatic trading and it running find in Demo acc. but facing problem to start running under real acc. any idea...why ?

 

No MQL4 code ... no error code ... no idea.

Well, maybe a little bit of an idea. I expect that you're getting error codes from OrderSend(). What are they?

 
brewmanz:

No MQL4 code ... no error code ... no idea.

Well, maybe a little bit of an idea. I expect that you're getting error codes from OrderSend(). What are they?

Hi expert,

Here you are.What do you thing ? now it just prompt out OrderSend like semi auto run.

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

int start()
{

double p=Point;
int OrdersPerSymbol=0;
int cnt=0;
if(AccountFreeMargin()==(300*Lots)) {Print("No"); return(0);}
if(Bars<100) {Print("NO BARS "); return(0);}
OrdersPerSymbol=0;
for(cnt=OrdersTotal();cnt>=0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if((OrdersPerSymbol<1) && OrderSymbol()==Symbol() )
{
OrdersPerSymbol++;
}if(Signal() == 1)
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Ask-(stoploss*p),Ask+(takeprofit*p),"Beli Beras "+CurTime(),0,0,White);return(0);
Sleep(10000);
}
if(Signal() == 2)
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,0,Bid+(stoploss*p),Bid-(takeprofit*p),"Jual padi "+CurTime(),0,0,Red);return(0);
Sleep(10000);
}
}
return(0);

}

Thanks//aiefan7

 

A)

B) You are not checking results of OrderSend

There are other problems, but get these out the way first

I strongly recommend that you examine other EAs before trying to write your own

 

instead of :

double p=Point;

try

double p=0.0001;

 
  1. You must adjust TP, SL, and slippage
    //++++ These are adjusted for 5 digit brokers.
    double  pips2points,    // slippage  3 pips    3=points    30=points
            pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
    int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
    int     init(){
        if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                    pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
        } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
        // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
    
    On ECN brokers you must orderSend and then set TP, SL.

  2. for(cnt=OrdersTotal();cnt>=0;cnt--)
    {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    if((OrdersPerSymbol<1) && OrderSymbol()==Symbol() )
    Always test return codes
        for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
            OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
        &&  OrderMagicNumber()  == magic.number             // my magic number
        &&  OrderSymbol()       == Symbol() ){              // and my pair.
    

  3. {
    OrderSend(Symbol(),OP_SELL,Lots,Bid,0,Bid+(stoploss*p),Bid-(takeprofit*p),"Jual padi "+CurTime(),0,0,Red);return(0);
    Sleep(10000);
    Always test return codes. Use a magic number so you can use multiple charts, multiple EAs, or manual trading.
    {
       int ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 0, 
                              Bid+(stoploss*p), Bid-(takeprofit*p), "Jual padi "+CurTime(), 
                              magic.number, 0, Red);
       if (ticket < 0) Alert( "OrderSend(type=", OP_SELL, " (Sell), lots=", Lots,
                ", price=", PriceToStr(Bid),...) failed: ", GetLastError() );
       return(0);
       //NOTREACHED Sleep(10000);