Sari la conținut
  • intrări
    29
  • comentarii
    230
  • citiri
    1.163.018

BcLib further corrections needed


TheEconomist

14.705 citiri

It seems when I inserted the MaxPasses parameter in ReliableOrderSend and ReliableOrderClose they became really broken. Last correction solves the issue, however there is still a bug:

 

Examining the corrected codes of the functions: copy from here and replace in BcLib.mq4!

 

int ReliableOrderSend(string symbol,int cmd,double volume,double price,int slippage,double stoploss,double takeprofit, string comment="",int magic=0,datetime expiration=0,color arrow_color=CLR_NONE,int MaxPasses=0) 
 {  
 int Gle=ERR_TRADE_CONTEXT_BUSY;	
 string ErrType="";
 string ErrText="";
 string ErrExplanation="";	
 int passes=0;  
 int res=-1;  
 while (Gle==ERR_TRADE_CONTEXT_BUSY||Gle==ERR_REQUOTE||Gle==ERR_INVALID_PRICE||Gle==ERR_PRICE_CHANGED||Gle==ERR_OFF_QUOTES)
   {  

   if (Gle==ERR_REQUOTE||Gle==ERR_INVALID_PRICE||Gle==ERR_PRICE_CHANGED||Gle==ERR_OFF_QUOTES||passes==0)
	 {
	 if (passes!=0)
		RefreshRates();
	 if (price==0.0)  //if (passes!=0||price==0)
		price=MarketInfo(symbol,PriceOpenMode(cmd));
	 }//if (Gle==ERR_REQUOTE)						
   res=OrderSend(symbol,cmd,volume,price,slippage,stoploss,takeprofit,comment,magic,expiration,arrow_color);   
   Gle=GetLastError();	   
   TranslateError(Gle,ErrType,ErrText,ErrExplanation);
   if (Gle!=ERR_NO_ERROR)
	  Print("ReliableOrderSend error : ",Gle," : ",ErrText);			  
   passes=passes+1;

   if (MaxPasses!=0)
	 {
	  if (passes>=MaxPasses)
		break;
	 }

   //ADD ONLY THIS LINE
   if (Gle==ERR_REQUOTE||Gle==ERR_INVALID_PRICE||Gle==ERR_PRICE_CHANGED||Gle==ERR_OFF_QUOTES) { price=0.0; }

   }//while (Gle==ERR_TRADE_CONTEXT_BUSY||Gle==ERR_REQUOTE)	   
 return(res);
 }

bool ReliableOrderClose(int ticket, double lots, double price, int slippage, color Color=CLR_NONE,int MaxPasses=0) 
 {
 int Gle=ERR_TRADE_CONTEXT_BUSY;
 string ErrType="";
 string ErrText="";
 string ErrExplanation="";	
 int passes=0;  
 bool res;
 int otype;
 double olots;
 string osymbol;
 res=OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
 osymbol=OrderSymbol();
 otype=OrderType();
 olots=OrderLots();  
 if (lots==0)
 lots=olots;  
 if (res==True)
{
while (Gle==ERR_TRADE_CONTEXT_BUSY||Gle==ERR_REQUOTE||Gle==ERR_INVALID_PRICE||Gle==ERR_PRICE_CHANGED||Gle==ERR_OFF_QUOTES)
   {	 
   if (Gle==ERR_REQUOTE||Gle==ERR_INVALID_PRICE||Gle==ERR_PRICE_CHANGED||Gle==ERR_OFF_QUOTES||passes==0)
	 {
	 if (passes!=0)
		RefreshRates();
	 if (price==0.0)  //if (passes!=0||price==0)
		price=MarketInfo(osymbol,PriceCloseMode(otype));
	 }//if (Gle==ERR_REQUOTE)							   
   res=OrderClose(ticket,lots,price,slippage,Color);   
   Gle=GetLastError();
   TranslateError(Gle,ErrType,ErrText,ErrExplanation);
   if (Gle!=ERR_NO_ERROR)
	  Print("ReliableOrderClose error : ",Gle," : ",ErrText);		   
   passes=passes+1;

   if (MaxPasses!=0)
	 {
	  if (passes>=MaxPasses)
		break;
	 }

  	   //ADD ONLY THIS LINE
   if (Gle==ERR_REQUOTE||Gle==ERR_INVALID_PRICE||Gle==ERR_PRICE_CHANGED||Gle==ERR_OFF_QUOTES) { price=0.0; }

   }//while (Gle==ERR_TRADE_CONTEXT_BUSY||Gle==ERR_REQUOTE)  
}
 return(res);
 }

 

As you can see, the 0 for entry price is correctly handled. As long as a bad error occurs (such as ERR_OFF_QUOTES occurs) and there is no price sent to OrderSend() the price is reread by MarketInfo. However, if a regular error comes (such as ERR_PRICE_CHANGED) then function enters a possible endless loop, as the MarketInfo price inquiry will not be executed. This is why, before while cycle ends, price will be reset in both ReliableOrderSend() and ReliableOrderClose(), making possible its read in the next cycle execution. This is the only modification to be done. In the same time, given the fact we reset the price before the while ends, the first execution is ok in both cases with a 0 price and a non-zero given price. (Don't look at the old closing while comments, they are really old, when functions didn't handle all these errors!)

 

Later edit: price must be reset only in some error conditions, not in all!

 

P.S.

I need some input folks! Can't see all the bugs lurking the shadows! At least for BcLib core modules...

 

P.S. no 2

My trading account floats around 3% ROE (started from late Aug. 27). :biggrin:

10 Comentarii


Comentarii Recomandate

Vizitator Andi

Postat

Hi Bog.

 

Congrats to your accounts development. I did some tests with your futures arb strategy. Unfortunately I found out, there is no other broker out there beneath WHC and FXEgy*, that is offering such "goog" futures quotes. I don't know, where they are backing these quotes. With no other big, serious broker I found a good arb opportunity. I cannot see, how they can offer such futures quotes - if you calculate the duration and use a real spot price, you will never get the future rate they are offering (as stated before in other threads) - thats why a gap appears and you can make money. But is this serious for a long run?

 

Andi

Link spre comentariu
Hi Bog.

 

Congrats to your accounts development. I did some tests with your futures arb strategy. Unfortunately I found out, there is no other broker out there beneath WHC and FXEgy*, that is offering such "goog" futures quotes. I don't know, where they are backing these quotes. With no other big, serious broker I found a good arb opportunity. I cannot see, how they can offer such futures quotes - if you calculate the duration and use a real spot price, you will never get the future rate they are offering (as stated before in other threads) - thats why a gap appears and you can make money. But is this serious for a long run?

 

Andi

 

Well, I'm using FXI*/Beaver* with swap free regime and long arbitrage trades (type A). To me the long run is so serious I'm already dreaming at limos, parties and women :biggrin: On the other hand, if you want the B type arbitrage, it's not so important for the futures to be "fair" calculated, since the B type relies on fluctuations of the discounted futures - it's not important for this discounted futures to FLUCTUATE AROUND THE SPOT, but TO FLUCTUATE ENOUGH around an average in order to be usable.

 

Bogdan

Link spre comentariu
Vizitator Andi

Postat

Did you realize, that at fxi* you GET 0.04 Points Short and PAY -0.27 Points Long Swap for GBPUSD while at any other broker they charge for short and pay for long... obvious...

 

Andi

Link spre comentariu
Did you realize, that at fxi* you GET 0.04 Points Short and PAY -0.27 Points Long Swap for GBPUSD while at any other broker they charge for short and pay for long... obvious...

 

Andi

 

I didn't knew and I don't care. I don't wanna slalom thru the swaps. I want any possible spot-to-futures arb to be used equally. What should I do anyway with GBP/USD, at a 1% differential, when I have 4.25% between USD and JPY ?

 

Bogdan

Link spre comentariu
Vizitator Andi

Postat

Bog, what I mean is that its obvious for a broker to offer such swaps. Don't you have fear giving them your money?

Doing a nice future arb with a serious, big broker is a fine thing, but taking the risk of losing all your money because of the broker being bankrupt is not that fine.

 

By the way, fxegypt is not responding to any mail and their live support is offline for about 1 week. I cannot login to my live account (thank god, I still was not able to fund it). So much for serious broker...

 

Beste greetings, Andi.

Link spre comentariu
Bog, what I mean is that its obvious for a broker to offer such swaps. Don't you have fear giving them your money?

Doing a nice future arb with a serious, big broker is a fine thing, but taking the risk of losing all your money because of the broker being bankrupt is not that fine.

 

By the way, fxegypt is not responding to any mail and their live support is offline for about 1 week. I cannot login to my live account (thank god, I still was not able to fund it). So much for serious broker...

 

Beste greetings, Andi.

 

I feared sending my hard gained $500 in this shithole where I work, so I got help from Matt... :biggrin: he put money, arbed them, and got money wired back, so he trusted them and me too. Now his B-style arbitrage doesn't work any longer, cause they put him on manual. But mine works...sleeps and makes money. And by the way, before opening the account, when I asked about swap-free accounts, I also asked about trade length limit and they said there are no limits! (So I can keep the mail almost like an opposable contract clause :tongue: )

Link spre comentariu
Vizitator Andi

Postat

Looking good. Hope you do well for the future.

After all, that thing is working because they offer extremely different swaps than other brokers - I hope this lasts a long time for you.

 

Can you please specify the arb you are doing at fxindia right now (entrytime, entryprices,...).

 

Andi.

Link spre comentariu
Looking good. Hope you do well for the future.

After all, that thing is working because they offer extremely different swaps than other brokers - I hope this lasts a long time for you.

 

Can you please specify the arb you are doing at fxindia right now (entrytime, entryprices,...).

 

Andi.

 

Thanks, Andi

 

The arb now is:

 

MarginUsage set at 50% of the 500 leverage available (initial equity ~ $1.250)

 

Trades:

 

Short 1.50 6j @0.8725 aug 27, 22:44 commission $30

Short 1.60 usdjpy @ 115.67 aug 27, 22:45 spread 2 pips

 

 

Regards,

Bogdan

Link spre comentariu
Vizitator Andi

Postat

Thank you. I'm looking for a bigger broker, who is offering swap free + currencys CFD's. I will keep you informed about that.

 

Are you planning to include Gold and Silver CFD's within your Trading EA? Would be a nice completion.

 

Andi.

Link spre comentariu
Thank you. I'm looking for a bigger broker, who is offering swap free + currencys CFD's. I will keep you informed about that.

 

Are you planning to include Gold and Silver CFD's within your Trading EA? Would be a nice completion.

 

Andi.

 

No. I'd include an Oil arb. I also could do a Gold and Silver arb, if it would work with Gold and Silver Minis.

However, these could still be damaged at execution, when the long arb is pretty safe.

 

Bogdan

Link spre comentariu
Vizitator
Adaugă un comentariu...

×   Alipit ca text avansat.   Alipește ca text simplu

  Doar 75 emoji sunt permise.

×   Linkul tău a fost încorporat automat.   Afișează ca link în schimb

×   Conținutul tău precedent a fost resetat.   Curăță editor

×   Nu poți lipi imagini direct. Încarcă sau inserează imagini din URL.

×
×
  • Creează nouă...

Informații Importante

Am plasat cookie-uri pe dispozitivul tău pentru a îmbunătății navigarea pe acest site. Poți modifica setările cookie, altfel considerăm că ești de acord să continui.