Eurobull EA

 

Hello,

This EA is leading the Automated Trading Championship 2006 and I have attached it to a demo account however I keep receiving this error:

2006.12.03 21:29:00 EuroBull EURUSD,Daily: OrderClose failed, Error: 4107

2006.12.03 21:29:00 EuroBull EURUSD,Daily: invalid price 1.33190000 for OrderClose function.

Apparently the EA is only taking long positions on the usd/eur. I have attached it here and was wondering if anybody here can tell me how to fix these errors?

I am using the StrategybuilderFX platform ver 4 build 198.

Thank You,

Pete

Files:
eurobull.mq4  5 kb
 

Did you read the comments included in the EA?

it is really a spoof and the EA is doing great because Euro is moving up. Once it starts a downtrend it is going to get wiped out.

 

Just a lucky guy - with good timing.

if you just want to buy Euro - why do you need EA?

regards.

 

Hello auto

auto:
Just a lucky guy - with good timing.

if you just want to buy Euro - why do you need EA?

regards.

Point taken however; this error I have received before using other EA's and was just wondering if there was an easy solution to this problem.

Thanks,

Pete

 

Hi Maji,

Thanks for your reply. It would seem that Zonkers attempt at a spoof EA is beating the other participants serious efforts at winning this automated trading championship.

Thanks,

Pete

 

price change

utes49:
Point taken however; this error I have received before using other EA's and was just wondering if there was an easy solution to this problem.

Thanks,

Pete

not to worry - the price must have changed when the call was made. Are you getting it every time?

The MyOrderClose function is not very robust! Please use the following ..

//+------------------------------------------------------------------+

//+-------------------------------------------------------------------

int CloseOrders(int cmd)

{ int i;

double price;

if(cmd == OP_SELL) price = Ask;

else price = Bid;

for(i=OrdersTotal()-1;i>=0;i--)

{ OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

if(OrderType() == cmd) //better to use IsTradingEnabled too

MyOrderClose(OrderType(),OrderTicket(),OrderLots(),price,SLIP,CLR_NONE);

}

}

//+------------------------------------------------------------------+

bool MyOrderClose(int type, int ticket, double lots, double price, int slip, color cl=CLR_NONE)

//first parameter is changed

{ int err;

for(int z=0;z<10;z++)

{

if(!OrderClose(ticket,lots,price,slip,cl))

{ err = GetLastError();

Print("OrderClose failed, Error: ", err);

if(err>4000) break;

RefreshRates();

if(type==OP_BUY) price = Bid;

else price = Ask;

}

else

break;

}

}

regards,

auto

 

Hello auto,

Thank you very much for your help. Yes, I am getting the error repeating continuously. I have inserted the code you provided and the expert compiles fine however, I now receive this error:

2006.12.04 01:00:30 EuroBull EURUSD,Daily: OrderClose failed, Error: 129

This error also repeats continuously. Any ideas what could be causing this?

Thank You,

Pete

 

Auto can you ge this EA to execute sell orders.

auto:
not to worry - the price must have changed when the call was made. Are you getting it every time?

The MyOrderClose function is not very robust! Please use the following ..

//+------------------------------------------------------------------+

//+-------------------------------------------------------------------

int CloseOrders(int cmd)

{ int i;

double price;

if(cmd == OP_SELL) price = Ask;

else price = Bid;

for(i=OrdersTotal()-1;i>=0;i--)

{ OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

if(OrderType() == cmd) //better to use IsTradingEnabled too

MyOrderClose(OrderType(),OrderTicket(),OrderLots(),price,SLIP,CLR_NONE);

}

}

//+------------------------------------------------------------------+

bool MyOrderClose(int type, int ticket, double lots, double price, int slip, color cl=CLR_NONE)

//first parameter is changed

{ int err;

for(int z=0;z<10;z++)

{

if(!OrderClose(ticket,lots,price,slip,cl))

{ err = GetLastError();

Print("OrderClose failed, Error: ", err);

if(err>4000) break;

RefreshRates();

if(type==OP_BUY) price = Bid;

else price = Ask;

}

else

break;

}

}

regards,

auto
 

EA EuroBull

Has anyone figured out how to make the EA EuroBull execute sell orders if so please send it to me at forextrend@yahoo.com or just post it here.

===========================================================================================

#property copyright "Zonker"

#property link "http://www.greenpeace.org"

#define MAXLOTSIZE 5

#define MAXPOS 3

#define SLIP 1

#define SL 200

int myMagic = 88888888;//very lucky, yes?

//+-------------------------------------------------------------------

int init() { return(0); }

int deinit() { return(0); }

//+-------------------------------------------------------------------

int start()

{ double RoundPriceNE1;

bool BuyEuros = false;

int LotsToBuy,Lots;

int i;

if(!Happyness()) return(0);

RoundPriceNE1 = iMA(NULL,PERIOD_M15,145,0.9,RoundPriceNE1,PRICE_CLOSE,0);//Must respect the sma.

if(RoundPriceNE1 > Ask) //Euros going cheap! BUY!

BuyEuros = true;

if(RoundPriceNE1 < Ask) //Momentum in our favour! BUY!!

BuyEuros = true;

if(RoundPriceNE1 == Ask) //BuY EUROS NOW!!!, BUY MORE!!!

BuyEuros = true;

if(OrdersTotal()>0)

{ //We have Euros! Do we need any more?

Lots=0;

for(i=0;i<OrdersTotal();i++)

{ OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

Lots += OrderLots();

}

if(AccountEquity() > (Lots*2000 + MathMin(5,(Lots+1)/2)*2000 + 100) && Lots = 1)

CloseOrders(OP_SELL); //Sell up and buy more Euros

else

return(0);

}

if(BuyEuros)

{ //We don't have any Euros?!!? How many Euros should we buy?

LotsToBuy = AccountBalance()/20000;

if(LotsToBuy == 0 && AccountBalance() > 100)

{ //Ok, getting desparate..

double tinyLots = NormalizeDouble(AccountBalance()/20000.0-0.1,1);

if(tinyLots>0)

MyOrderSend(Symbol(),OP_SELL,tinyLots,Ask,SLIP,Ask-SL*Point,Ask+SL*Point,"",myMagic,0,Blue);

return(0);

}

for(i=0;i<MAXPOS;i++)

{ if(LotsToBuy>MAXLOTSIZE) Lots = MAXLOTSIZE;

else Lots = LotsToBuy;

MyOrderSend(Symbol(),OP_SELL,Lots,Ask,SLIP,Ask-SL*Point,0,"",myMagic,0,Blue);

LotsToBuy -= MAXLOTSIZE;

if(LotsToBuy >= 0) break;

}

}

return(0);

}

//+-------------------------------------------------------------------

bool Happyness() //Are we in the right mood to trade?

{

if(!IsConnected())

{ Print("Yo man, we are not connected!");

return(false);

}

if(!IsExpertEnabled())

{ Print("Hey, we are not enabled!");

return(false);

}

if(AccountEquity() > 98800) //Stop at 888%, lets not be greedy.

{ if(OrdersTotal() > 0)

CloseOrders(OP_SELL);

return(false);

}

if(AccountBalance() < 200) return(false); //Ok, we lost.

return(true);

}

//+-------------------------------------------------------------------

int CloseOrders(int cmd)

{ int i;

double price;

if(cmd == OP_BUY) price = Ask;

else price = Bid;

for(i=OrdersTotal()-1;i>=0;i--)

{ OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

if(OrderType() == cmd)

MyOrderClose(OrderTicket(),OrderLots(),price,SLIP,CLR_NONE);

}

}

//+-------------------------------------------------------------------

int MyOrderSend(string sym, int cmd, double vol, double price, int slip, double sl, double tp, string comment="", int magic=0, datetime exp=0, color cl=CLR_NONE)

{ int err;

bool isAsk=false;

if(price == Ask) isAsk = true;

for(int z=0;z<10;z++)

{ if(OrderSend(sym,cmd,vol,price,slip,sl,tp,comment,magic,exp,cl)<0)

{ err = GetLastError();

Print("OrderSend failed, Error: ", err);

if(err>4000) break;

RefreshRates();

if(isAsk) price = Ask;

else price = Bid;

}

else

break;

}

}

//+------------------------------------------------------------------+

bool MyOrderClose(int ticket, double lots, double price, int slip, color cl=CLR_NONE)

{ int err;

bool isAsk=false;

if(price == Ask) isAsk = true;

for(int z=0;z<10;z++)

{

if(!OrderClose(ticket,lots,price,slip,cl))

{ err = GetLastError();

Print("OrderClose failed, Error: ", err);

if(err>4000) break;

RefreshRates();

if(isAsk) price = Ask;

else price = Bid;

}

else

break;

}

}

//+-------------------------------------------------------------------

Thanks

 
utes49:
Hi Maji,

Thanks for your reply. It would seem that Zonkers attempt at a spoof EA is beating the other participants serious efforts at winning this automated trading championship.

Thanks,

Pete

That goes to show that being lucky is a part of this casino gaming... AKA forex trading

 

It just buys eurusd.

Reason: