For convenience, the MQL4 functions are divided into groups, similar to MQL4 Reference. For each MQL4 function (except trading functions) the description and MQL5 implementation are presented, it allows you to reduce the conversion time significantly. I've checked on Excel, as expected, it normally returns the remainder zero, unlike mql4.įor an ugly workaround i use the modulus '%' operator with a function to convert price to int and back to double (% only accept int's). This article is a quick guide to MQL4 language functions, it will help you to migrate your programs from MQL4 to MQL5. If you run this test script, the result of the third price is suppose to not change (1.25500), at least in my opinion. the number is an integer product of the divisor) the MathMod() doesn't return zero, it returns the divisor instead.Įxample: #property show_inputs extern double divisor = 0.0005 ĭouble price = ĭouble remainder = MathMod( price, divisor) Īlert( "price = ", DoubleToStr( price, Digits), " result = ", DoubleToStr( price - MathMod( price, divisor), Digits)) Īlert( "*****************************************************") But I recently found out that if the division remainder is zero (i.e. Res=OrderSend(Symbol(),OP_BUY,(AccountEquity() * 0.I've used MathMod() function a lot on my code for rounding off prices. #property description "Double Moving Av." If(CalculateCurrentOrders(Symbol())=0) CheckForOpen() The MathMod function calculates the floating-point remainder f of x / y such that x i y + f, where i is an integer, f has the. - calculate open orders by current symbol double MathMod ( double value1, double value2) The function returns the floating-point remainder of division of two numbers. MQL4 programming help needed - simply combining indicators 0 replies. MathMod is a mathematical modeling software. ObjectCreate(name,OBJ_HLINE,0,0,P,0,0,0,0) What is the best way to get started learning MQL4 programming language 20 replies. Note Instead of MathPow () you can use pow(). Return Value Value of base raised to the specified power. double MathPow( double base, // base double exponent // exponent value ) Parameters base in Base. If(ObjectFind(name)!=-1) ObjectDelete(name) MathPow - Math Functions - MQL4 Reference MathPow The function raises a base to a specified power. Void DrawHline(string name,double P,color clr,int WIDTH) If(!OrderClose(TicketS,OrderLots(),NormalizeDouble(Ask,Digits),slippage,clrRed))Įrr=OrderSend(Symbol(),OP_BUY,Lot,NormalizeDouble(Ask,Digits),slippage,0,0,"òåñò",0) Įrr=OrderSend(Symbol(),OP_SELL,Lot,NormalizeDouble(Bid,Digits),slippage,0,0,"òåñò",0) ![]() SL=NormalizeDouble(Ask+TrailingStop*Point,Digits) Res=OrderSend(Symbol(),OP_BUY,(AccountEquity() * 0.0001 /LotFactor),Ask,3,0,0,"",MAGICMA,0,Blue) įor(int i=0 i=OOP + Takeprofit * Point) Ma=iMA(NULL,0,SMMA_Slow,MovingShift,MODE_SMMA,PRICE_CLOSE,0) MQL4 Reference Math Functions MathAbs MathAbs MathArccos MathArcsin MathArctan MathCeil MathCos MathExp MathFloor MathLog MathLog10 MathMax MathMin MathMod. Ma=iMA(NULL,0,MA_simple,MovingShift,MODE_SMA,PRICE_CLOSE,0) Example: Function to modify a newly entered MT4 order to add the stoploss and takeprofit fields with a given ticket called OrderModify. ![]() - go trading only for first tiks of new bar This code accounts for that (I had to truncate some of the possible methods that threw the error, and group them into broader catagories). A string has a character limit of about 350. Int CalculateCurrentOrders(string symbol) There is a problem with the code I posted previously.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |