//+------------------------------------------------------------------+//| Macro definitions. |//+------------------------------------------------------------------+//--- eliminate division by zero errors#define DivZero(a,b) (b==0.) ?0 :1.0*a/b
Macro definition - eliminate division by zero errors , output Warning.
//+------------------------------------------------------------------+//| Macro definitions. |//+------------------------------------------------------------------+//--- eliminate division by zero errors, output Warning.#define DivZero(a,b) (b==0.) ?Print("Warning: division by zero in "+__FUNCTION__) :1.0*a/b
Example:
//+------------------------------------------------------------------+//| Macro definitions. |//+------------------------------------------------------------------+//--- eliminate division by zero errors#define DivZero(a,b) (b==0.) ?0 :1.0*a/b
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+intOnInit()
{
int x,y;
Print(DivZero(x,y));
}
Thanks for sharing. As a remark, be cautious using such function as DivZero(), you don't get a runtime error causing an interruption of your program, BUT that can mask a logical error, much more difficult to find.
angevoyageur: Thanks for sharing. As a remark, be cautious using such function as DivZero(), you don't get a runtime error causing an interruption of your program, BUT that can mask a logical error, much more difficult to find.
Thanks for the note. 've Added code example: eliminate division by zero errors , output Warning.
Macro definition - Return (number of digits or number of symbols after a decimal point)
//+------------------------------------------------------------------+//| Macro definitions. |//+------------------------------------------------------------------+//--- Returns number of digits or number of symbols after a decimal point#define GetDigits(a) (StringFind(a,".")<0) ?0 :StringLen(StringSubstr(a,(StringFind(a,"."))+1,-1))
Example:
//+------------------------------------------------------------------+//| Macro definitions. |//+------------------------------------------------------------------+//--- Returns number of digits or number of symbols after a decimal point#define GetDigits(a) (StringFind(a,".")<0) ?0 :StringLen(StringSubstr(a,(StringFind(a,"."))+1,-1))
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+intOnInit()
{
double Numbers = 1235.22446235;
string Name = "_tmp.xxxxxx";
Print(GetDigits(Numbers));
Print(GetDigits(Name));
}
Example 2: Returns number of digits of the volume for a deal(lots)
#include <Trade\SymbolInfo.mqh>
CSymbolInfo m_sym;
//+------------------------------------------------------------------+//| Macro definitions. |//+------------------------------------------------------------------+//--- Returns number of digits or number of symbols after a decimal point#define GetDigits(a) (StringFind(a,".")<0) ?0 :StringLen(StringSubstr(a,(StringFind(a,"."))+1,-1))
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+intOnInit()
{
// Returns number of digits of the volume for a deal(lots)
m_sym.Name(Symbol());
Print(GetDigits(m_sym.LotsStep()));
}
Why aren't you checking if the object already exists, you do in your WriteText() function ?
Because you've already written, I just use it to change its value.
Like the time showing on the chart
Macro definition - eliminate division by zero errors
Macro definition - eliminate division by zero errors , output Warning.
Example:
Macro definition - eliminate division by zero errors
Example:
Macro definition - eliminate division by zero errors
Example:
Thanks for sharing. As a remark, be cautious using such function as DivZero(), you don't get a runtime error causing an interruption of your program, BUT that can mask a logical error, much more difficult to find.
Thanks for the note. 've Added code example: eliminate division by zero errors , output Warning.
Macro definition - Return (number of digits or number of symbols after a decimal point)
Example:
Example 2: Returns number of digits of the volume for a deal(lots)
Delete pending order
Delete pending order
hi;
below code can use for " send email & send massage to mobile & send sound and alarm " .i write below and use it in all my indicator.
example : https://www.mql5.com/en/code/1868