-
Notifications
You must be signed in to change notification settings - Fork 17
Helper API
The Helper API provides many different helper methods to use. Char to string, Information on time, etc.
GetLastError
IsConnected
IsDllsAllowed
IsExpertEnabled
IsLibrariesAllowed
IsOptimization
IsStopped
IsTesting
IsTradeContextBusy
IsVisualMode
UnintializeReason
Alert
Comment
GetTickCount
MarketInfo
MessageBox
PlaySound
Print
SendFTP
SendMail
SendNotification
Sleep
CharToStr
DoubleToStr
NormalizeDouble
StrToDouble
StrToInteger
StrToTime
TimeToStr
Day
DayOfWeek
DayOfYear
Hour
Minute
Seconds
TimeCurrent
TimeDay
TimeDayOfWeek
TimeDayOfYear
TimeHour
TimeLocal
TimeMinute
TimeMonth
TimeSeconds
TimeYear
Year
CompareString
MathAbs
MathArccos
MathArcsin
MathArctan
MathCeil
MathCos
MathExp
MathFloor
MathLog
MathMax
MathMin
MathMod
MathPow
MathRand
MathRound
MathSin
MathSqrt
MathSrand
MathTan
StringConcatenate
StringFind
StringGetChar
StringLen
StringSetChar
StringSubstr
StringTrimLeft
Stringtrimright
TerminalCompany
TerminalName
TerminalPath
HideTestIndicators
Period
RefreshRates
Symbol
WindowBarsPerChart
WindowExpertName
WindowsFind
WindowFirstVisibleBar
WindowHandle
WindowIsVisible
WindowPriceMax
WindowPriceMin
WindowRedraw
WindowScreenshot
WindowsTotal
Get integer code of the last error and set last error value to 0.
protected int GetLastError()
- Integer code of the last error
Return whether or not Data Provide is connected
protected bool IsConnected()
- It returns true if connection to the server was successfully established, otherwise, it returns false.
Determinate ability to use external DLL`s. We don't support external DLL's
protected bool IsDllsAllowed()
- Returns true if the DLL function call is allowed, otherwise returns false
Determinate is there Expert advisors on chart
protected bool IsExpertEnabled()
- Returns true if Expert Advisors are enabled for running, otherwise returns false.
Determinate ability to use external libraries. We don't support external libraries
protected bool IsLibrariesAllowed()
- Returns true if library function call is allowed, otherwise returns false
Determine is there optimization mode using. Not supported, false in any cases
protected bool IsOptimization()
- false
Determine if EA is stopped
protected bool IsStopped()
- Returns true if EA is stopped, otherwise returns false
Used in Strategy testing, TRUE if EA running in Strategy test. Not supported, false in any cases
protected bool IsTesting()
- false
Can user trade now. Not supported, false in any cases
protected bool IsTradeContextBusy()
- false
Used in Strategies testing, and show Strategies Test on chart. Not supported, false in any cases
protected bool IsVisualMode()
- false
Return integer code of uninitializing reason
protected int UninitializeReason()
- integer code of uninitializing reason
Show alert windows with new and old alerts
protected void Alert(params object[] values)
- values - Values that will be concatenated and showed as alert message
Show label on chart in top-left corner
protected void Comment(params object[] vals)
- vals - Values that will be concatenated and showed as comment
Get the number of milliseconds elapsed since the system started
protected int GetTickCount()
- Number of milliseconds elapsed since the system started
Get information about instrument
protected double MarketInfo(string symbol, int type)
- symbol - Symbol name
- type - Type of instrument parameter that you want to get (MODE_LOW, MODE_HIGH, MODE_LOTSIZE ...)
- Double value of parameter
Show system message box
protected int MessageBox(string text = "", string caption = "", int flags = EMPTY)
- text - Text, containing message to output.
- caption - Optional text to be displayed in the box header.
- flags - Optional flags defining appearance and behavior of a message box. Flags can be a combination of a special group of flags.
- If the function is successfully performed, the returned value is one of values of MessageBox() return codes.
Play sound from specified file
protected void PlaySound(string filename)
- filename - Full file path
Show message in app journal
protected void Print(params object[] vals)
- vals - Values that will be concatenated and showed as print message
Send file by FTP. Not supported, return false in any cases.
protected bool SendFTP(string filename, string ftpPath = null)
- false
Send email Not supported
protected void SendMail(string subject, string someText)
Not supported, return false in any cases.
protected bool SendNotification(string message)
- false
Stop current thread for specified time in milliseconds.
protected void Sleep(int ms)
- ms - time in milliseconds
Convert Char to String
protected string CharToStr(int charCode)
- charCode - ASCII char code
- Text string
Convert double to string
protected string DoubleToStr(double value, int digits)
- value - Floating point value
- digits - Precision format, number of digits after decimal point (0-8).
- Text string
Round double value to a specified numbers of fractional digits
protected double NormalizeDouble(double value, int digits)
- value - Value with a floating point.
- digits - Accuracy format, number of digits after point (0-8).
- Value of double type with preset accuracy.
Converts string representation of number to double type (double-precision format with floating point).
protected double StrToDouble(string value)
- value - String containing the number character representation format.
- Value of double type. NaN in case of error.
Converts string containing the value character representation into a value of the int (integer) type.
protected int StrToInteger(string value)
- value - String containing the integer character representation format.
- Value of int type. MinValue in case of error.
Converts string in the format "yyyy.mm.dd hh:mi" to datetime type (the amount of seconds that have passed since 1 Jan., 1970).
protected datetime StrToTime(string value)
- value - String having "yyyy.mm.dd hh:mi " format.
- Value of datetime type as a number of seconds, passed since 01.01.1970. Datetime MinValue in case of error.
Converts value containing time in seconds that has passed since January 1, 1970, into a string of "yyyy.mm.dd hh:mi" format.
protected string TimeToStr(Object value,
int mode = (int)(DateTimeFormat.TIME_DATE | DateTimeFormat.TIME_MINUTES))
- value - Positive amount of seconds that have passed since 00:00, January 1, 1970.
-
mode - Optional data output mode can be one or combination of:
- TIME_DATE gets result as "yyyy.mm.dd"
- TIME_MINUTES gets result as "hh:mi"
- TIME_SECONDS gets result as "hh:mi:ss"
- String
Return day number of month according to server time
protected int Day()
- day number of month according to server time
Return day number of week according to server time
protected int DayOfWeek()
- Day number of week according to server time.
Return day number of year according to server time
protected int DayOfYear()
- Day number of year according to server time.
Return current hour according to server time
protected int Hour()
- Current hour according to server time.
Return current minute according to server time
protected int Minute()
- Current minute according to server time.
Return current month number according to server time
protected int Month()
- Current month according to server time.
Return current second according to server time
protected int Seconds()
- Current second according to server time.
Return current server time
protected datetime TimeCurrent()
- Current server time.
Return day of the month from specified date
protected int TimeDay(datetime date)
- date - specified date
- Day of month from specified date
Return day of the week from specified date
protected int TimeDayOfWeek(datetime date)
- date - specified date
- Day of the week from specified date
Return day of the year from specified date
protected int TimeDayOfYear(datetime date)
- date - specified date
- Day of the year from specified date
Return hour from specified date
protected int TimeHour(datetime time)
- time - specified date
- Hour from specified date
Return local time
protected DateTime TimeLocal()
- Local time
Return minute from specified date
protected int TimeMinute(datetime time)
- time - specified date
- Minute from specified date
Return month from specified date
protected int TimeMonth(datetime time)
- time - specified date
- Month from specified date
Return second from specified date
protected int TimeSeconds(datetime time)
- time - specified date
- Second from specified date
Return year from specified date
protected int TimeYear(datetime time)
- time - specified date
- Year from specified date
Return year from from server time
protected int Year()
- Year from server time
Compare strings and return equality
protected bool CompareString(string s1, string s2, bool ignoreCase = false)
- s1 - first string
- s2 - second string
- ignoreCase - ignore case of strings when true.(default = false)
- True if the strings are the same, false otherwise
The function returns the absolute value (modulus) of the specified numeric value.
protected double MathAbs(double value)
- value - Numeric value
- Value of double type more than or equal to zero.
The function returns the arccosine of x within the range 0 to π in radians.
protected double MathArccos(double x)
- x - The val value between -1 and 1, the arc cosine of which is to be calculated.
- Arc cosine of a number in radians. If val is less than -1 or more than 1, the function returns NaN (indeterminate value).
The function returns the arc sine of x within the range of -π/2 to π/2 radians.
protected double MathArcsin(double x)
- x - The val value between -1 and 1, the arc sine of which is to be calculated.
- Arc sine of the val number in radians within the range of -π/2 to π/2 radians. If val is less than -1 or more than 1, the function returns NaN (indeterminate value).
The function returns the arc tangent of x. If x is equal to 0, the function returns 0.
protected double MathArctan(double x)
- x - A number representing a tangent.
- returns a value within the range of -π/2 to π/2 radians.
Returns the smallest integral value that is greater than or equal to the specified double-precision floating-point number.
protected double MathCeil(double x)
- x - Numeric value
- Numeric value representing the smallest integer that exceeds or equals to x.
The function returns the cosine of an angle.
protected double MathCos(double value)
- value - Angle in radians
- Value of double type within the range of -1 to 1.
The function returns the value of e raised to the power of d.
protected double MathExp(double d)
- d - A number specifying the power.
- A number of double type. In case of overflow the function returns INF (infinity), in case of underflow MathExp returns 0.
The function returns integer numeric value closest from below.
protected double MathFloor(double x)
- x - Numeric value
- A numeric value representing the largest integer that is less than or equal to val.
The function returns a natural logarithm.
protected double MathLog(double x)
- x - Value logarithm of which is to be found.
- The natural logarithm of val in case of success. If val is negative, the function returns NaN (undetermined value). If val is equal to 0, the function returns INF (infinity).
The function returns the maximal value of two values.
protected double MathMax(double value1, double value2)
- value1 - First numeric value.
- value2 - Second numeric value.
- The largest of the two values.
The function returns the minimal value of two values.
protected double MathMin(double value1, double value2)
- value1 - First numeric value.
- value2 - Second numeric value.
- The smallest of the two values.
The function returns the real remainder of division of two numbers.
protected double MathMod(double value, double value2)
- value - Dividend value.
- value2 - Divisor value.
- he MathMod function calculates the real remainder f from expression val/y so that val = i * y + f , where i is an integer, f has the same sign as val, and the absolute value of f is less than the absolute value of y.
The function raises a base to a specified power.
protected double MathPow(double value, double exponent)
- value - Base.
- exponent - Exponent value.
- Value of base raised to the specified power.
Returns a pseudorandom integer within the range of 0 to 32767.
protected int MathRand()
- Integer value within the range of 0 to 32767.
The function returns a value rounded off to the nearest integer of the specified numeric value.
protected double MathRound(double value)
- value - Numeric value before rounding.
- Value rounded till to the nearest integer.
Returns the sine of a specified angle.
protected double MathSin(double value)
- value - Angle in radians.
- Sine of an angle measured in radians. Returns value within the range of -1 to 1.
Returns the square root of a number.
protected double MathSqrt(double x)
- x - Positive numeric value.
- Square root of value. If value is negative, MathSqrt returns NaN (indeterminate value).
Sets the starting point for generating a series of pseudorandom integers.
protected void MathSrand(int seed)
- seed - Starting number for the sequence of random numbers.
The function returns a tangent of a number.
protected double MathTan(double x)
- x - Angle in radians.
- Tangent of rad. If rad is greater than or equal to 263, or less than or equal to -263, a loss of significance in the result occurs, in which case the function returns an indefinite number.
The function returns the string formed by concatenation of parameters transformed into string type.
protected string StringConcatenate(params Object[] values)
- values - an object array, using the comma separator between each element
- Returns the string, formed by concatenation of parameters transformed into string type.
Search for a substring in a string.
protected int StringFind(string text, string matchedText, int start = 0)
- text - String, in which search is made.
- matchedText - Searched substring.
- start - Position in the string from which search is started.
- Returns position number in a string, from which the searched substring starts, or -1, if the substring is not found.
Returns value of a symbol, located in the specified position of a string.
protected int StringGetChar(string text, int pos)
- text - String.
- pos - Position of a symbol in the string
- Chart ASCII code in specified position from string. In case of error return -1
Returns the number of symbols in a string.
protected int StringLen(string text)
- text - String to calculate length.
- Length of string
Insert in specified position in string new chart
protected string StringSetChar(string text, int pos, int value)
- text - String.
- pos - Position for inserting
- value - Char ASCII code
- New string.
Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length.
protected string StringSubstr(string text, int start, int length = 0)
- text - String to extract a substring from.
- start - Initial position of a substring.
- length - Length of an extracted substring. If the parameter value is equal or less than 0 or parameter isn't set, the substring will be extracted from the indicated position till the string end.
- Copy of a extracted substring, if possible. Otherwise returns an empty string.
The function cuts line feed characters, spaces and tabs in the left part of the string till the first meaningful symbol. The string is modified at place.
protected string StringTrimLeft(string text)
- text - String that will be cut from the left.
- A copy of the cut string if possible, otherwise an empty string.
The function cuts line feed characters, spaces and tabs in the right part of the string after the last meaningful symbol. The string is modified at place.
protected string StringTrimRight(string text)
- text - String that will be cut from the right.
- A copy of the cut string if possible, otherwise an empty string.
Returns the name of company owning the client terminal.
protected string TerminalCompany()
- The name of company owning the client terminal.
Returns client terminal name.
protected string TerminalName()
- Client terminal name.
Returns the directory, from which the client terminal was launched.
protected string TerminalPath()
- The directory, from which the client terminal was launched.
The function sets a flag hiding indicators called by the Expert Advisor.
protected void HideTestIndicators(bool hide)
- hide - Hiding flag.
Returns timeframe of the current chart.
protected int Period()
- Period (timeframe) of the current chart (in minutes).
Refreshing of data in pre-defined variables and series arrays.
protected bool RefreshRates()
- True if the data updated, otherwise false.
Returns the name of a symbol of the current chart.
protected string Symbol()
- Name of symbol of the current chart.
Returns the amount of bars visible on the chart.
protected int WindowBarsPerChart()
- The amount of bars visible on the chart. This value may change as the chart is zoomed or scrolled.
Returns the name of the executed Expert Advisor, script, custom indicator, or library.
protected string WindowExpertName()
- The name of the executed Expert Advisor, script, custom indicator, or library
Get chart panel number by object name on it
protected int WindowsFind(string name)
- name - object name.
- Chart panel number
Returns index of the first visible bar in the current chart window.
protected int WindowFirstVisibleBar()
- Index of the first visible bar number in the current chart window.
Returns the system handle of the chart window. Not Supported
protected int WindowHandle(string symbol, int timeframe)
Determinate is the panel on chart with specified number currently visible. True in any cases.
protected bool WindowIsVisible(int index)
- True.
Get max price on specified chart panel
protected double WindowPriceMax(int index = 0)
- index - Panel index.
- Max price on specified chart panel
Get min price on specified chart panel
protected double WindowPriceMin(int index = 0)
- index - Panel index.
- Min price on specified chart panel
Force redraw chart
protected void WindowRedraw()
Create and save chart screenshot in specified file
protected bool WindowScreenShot(string filename, int size_x, int size_y, int start_bar = -1, int chart_scale = 0,
int chart_mode = -1)
- filename - Screen shot file name.
- size_x - Screen shot width in pixels.
- size_y - Screen shot height in pixels.
- start_bar - ndex of the first visible bar in the screen shot. If 0 value is set, the current first visible bar will be shot. If no value or negative value has been set, the end-of-chart screen shot will be produced, indent being taken into consideration.
- chart_scale - Horizontal chart scale for screen shot. Can be in the range from 0 to 5. If no value or negative value has been set, the current chart scale will be used.
-
chart_mode - Chart displaying mode. It can take the following values:
- CHART_BAR (0 is a sequence of bars)
- CHART_CANDLE (1 is a sequence of candlesticks)
- CHART_LINE (2 is a close prices line)
- If no value or negative value has been set, the chart will be shown in its current mode.
- Returns true if succeed, otherwise false.
Get total panels count
protected int WindowsTotal()
- Total panels count