Caută în comunitate
Afișez rezultate pentru tagurile 'BcLib Files'
Găsit 7 rezultate
-
BcLib update - New powerful trading functions
TheEconomist a postat o intrare blog în TheEconomist's Forex Arbitrage Blog
This BcLib issue adds new trading functions: - ReliableModifyTakeProfit() and ReliableModifyStopLoss(), which attempt to place and repair the TP and SL levels , by moving them up or down (take profit, for buys and sells) , down or up (stop loss, for buys and sells) in order to avoid ERR_INVALID_STOPS, which is the only error handled by these functions. The fast functions ModifyTakeProfit() and ModifyStopLoss(), older, simply attempt to do this once without handling any error. - ReliableOrderPlace(), which is an upgrade of the ReliableOrderSend() . The difference is that SL and TP are integers , given by the user in pips. ReliableOrderPlace() calls ReliableOrderSend() to manage placing of the order without SL and TP, then it uses ReliableModifyTakeProfit() and ReliableModifyStopLoss to set TP and SL levels. This is why, if any errors appear in the log, they are reported by ReliableOrderSend(), not by ReliableOrderPlace(). -
I'm answering to Pion's request to release the code for BcWin and BcTools. These were both written in Dev-Pascal. I am attaching the pas and project files , as a test script for them too.
-
BcLib (and many others) update... discoveries, bugs and mistakes
TheEconomist a postat o intrare blog în TheEconomist's Forex Arbitrage Blog
Last week our fellow TradeLover from the forum (who is also a contestant in MetaQuotes Automated Trading Championship 2007 - let's give him an for that) made a shocking and very disturbing discovery: a tick is not quite a pip in forex (we even argued for that, but he was right - never take anything for granted) Running a simple script like this: int start() { Print("tick size= ",MarketInfo(Symbol(),MODE_TICKSIZE), " - tick value= ",MarketInfo(Symbol(),MODE_TICKVALUE)); return(0); } what he got after some hours was this: 22:40:03 ticksize GBPCHF,M1: tick size= 0.0001 - tick value= 8.53 22:40:13 ticksize GBPCHF,M1: tick size= 0.0001 - tick value= 8.53 22:40:20 ticksize GBPCHF,M1: tick size= 0.0001 - tick value= 8.53 22:40:24 ticksize GBPCHF,M1: tick size= 0.0001 - tick value= 8.53 22:40:27 ticksize GBPCHF,M1: tick size= 0.0001 - tick value= 8.53 22:40:30 ticksize GBPCHF,M1: tick size= 0.0001 - tick value= 8.53 22:40:31 ticksize GBPCHF,M1: tick size= 0.0002 - tick value= 17.07 22:40:32 ticksize GBPCHF,M1: tick size= 0.0001 - tick value= 8.53 22:40:46 ticksize GBPCHF,M1: tick size= 0.0001 - tick value= 8.53 Now what if that tick value is caught in a hedge calculus that calculates lotsizing or results for months ahead ? In order to settle this issue once and for all, I made the RealTickValue() function as follows: double RealTickValue(string contract) { double res; res= MarketInfo(contract,MODE_TICKVALUE) / (MarketInfo(contract,MODE_TICKSIZE)/MarketInfo(contract,MODE_POINT)); return(res); } The function now works as a proxy for MODE_TICKVALUE inquiries. Now both BcLib and BcArb call that first when dealing with MODE_TICKVALUE. Found surprise bugs in ReliableOrderSend and ReliableOrderClose. Don't know how they got there, as they seem to work well. Also corrected past scripts that use MODE_TICKVALUE. Discovered also mistakes in updated SwapFinder, that's why I corrected and updated again, along with SwapButterfly. Inserted also a mechanism for calculating futures using London InterBank rates. It doesn't seem to be too much of use, as indicators are still wrong, but you can correct their parameters, so I added DiscountedFuturesLIB and DiscountedBasisLIB indicators. Corrected bugs in Futures script. Now it's set up with a MarginUsage of 50% and a SwapFree regime set to True by default. P.S. I will keep you posted with my arbitrage trades working (Spot-to-Futures type A) -
Updates list: - Updated code for ReliableOrderSend(), ReliableOrderClose() as I wrote earlier in this blog; - Modified fast Order_**** functions to lookup history , after checking current trades ; added function Order_Pool to retrieve the place of an order: MODE_TRADES, MODE_HISTORY, or -1; - Replaced calls to ObjectsRedraw() with calls to WindowRedraw(). The RealTickValue() function remains in place as a proxy for getting tick values, although MetaQuotes corrected the MODE_TICKVALUE bug since build 211. P.S. We are still working on the FXIndia issue...
-
BcLib further corrections needed
TheEconomist a postat o intrare blog în TheEconomist's Forex Arbitrage Blog
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). -
Updates list: > Swap2Interest_Volume function now supports swap type 1 also; > "Swap Functions" block renamed to "Financial Math"; > "Financial Math" block expanded to include functions for calculation or discount of currency futures; > GetCurrency() now works when market is closed too; > Added optimization types OPTIMIZE_SWAP_ONLY_VIRTUAL , OPTIMIZE_PRICE_ONLY_VIRTUAL to BcArb as possible parameter values for GetBestCross(); > Added variable bool SupportOneAtomCrosslists = false that can work as a switch to influence CreateCrosslist() and CreateCrosslistsTable() to discard or not one-atom crosslists; ...and perhaps others which I don't remember. Check also the new and repaired SwapFinder_script that uses everywhere UnitsToLots().
-
Place BcLib and BcArb in experts\include folder Place BcTools.Dll and BcWin.exe in experts\libraries folder First compile BcLib then BcArb.