A very handy function in terms of constructing forks. If so, this colour. And if it is not, then another colour. Function IIFc() takes three mandatory parameters:
condition - A logical expression. It can be true or false.
ifTrue - The colour that will be returned by IIFc() if condition is true.
ifFalse - The colour that will be returned by IIFc() if condition is false.
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 18.07.2008 |//| Описание : Возвращает одно из двух значений взависимости от условия. |//+----------------------------------------------------------------------------+color IIFc(bool condition,color ifTrue,color ifFalse){if( condition)return( ifTrue);elsereturn( ifFalse);}
Similar convenience for real numbers. If so, such a real number. If it is not, then another number. The IIFd() function takes three mandatory parameters:
condition - A logical expression. It can be true or false.
ifTrue - The real number that will be returned by IIFd() if condition is true.
ifFalse - A real number that will be returned by IIFd() if condition is false.
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 01.02.2008 |//| Описание : Возвращает одно из двух значений взависимости от условия. |//+----------------------------------------------------------------------------+double IIFd(bool condition,double ifTrue,double ifFalse){if( condition)return( ifTrue);elsereturn( ifFalse);}
ifTrue - An integer number that will be returned by IIFi() if the condition expression is true.
ifFalse - An integer that will be returned by IIFi () if condition is false.
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 01.02.2008 |//| Описание : Возвращает одно из двух значений взависимости от условия. |//+----------------------------------------------------------------------------+int IIFi(bool condition,int ifTrue,int ifFalse){if( condition)return( ifTrue);elsereturn( ifFalse);}
Similar convenience for strings. If so, such a string. If not, then another string. The IIFs() function takes three mandatory parameters:
condition - A logical expression. It can be true or false.
ifTrue - The string that will be returned by IIFs() if condition is true.
ifFalse - The string that will be returned by IIFs( ), if condition is false.
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 01.02.2008 |//| Описание : Возвращает одно из двух значений взависимости от условия. |//+----------------------------------------------------------------------------+string IIFs(bool condition,string ifTrue,string ifFalse){if( condition)return( ifTrue);elsereturn( ifFalse);}
The IIFs() function is, in most cases, used in the commenting block of the EA operation. For example, it is used when outputting values of external parameters of the EA.
To show how trading functions intended for use in the tester only can be applied, I wrote e_ForTester, a swing Expert Advisor. The entry signal is a pair of unidirectional candlesticks. If the candlesticks are directed upwards, the EA closes the buy and sells. If the candlesticks are directed downwards, the Expert Advisor closes the sale and buys. There is only one position in the market at all times. Exit is either by the opposite signal, or by a stop/stop/stick. Stop and Take are two external parameters that can be optimized. The following tester-only functions are used in the EA:
I was reading the book by V.Yakimkin. "Forex market - your way to success" and came across the following lines "...differential from (DJI x Nikkei)..." Can you tell me, Igor, if it is possible to implement it and output it as an indicator...
The IIFc() function.
A very handy function in terms of constructing forks. If so, this colour. And if it is not, then another colour. Function IIFc() takes three mandatory parameters:
The IIFd() function.
Similar convenience for real numbers. If so, such a real number. If it is not, then another number. The IIFd() function takes three mandatory parameters:
The IIFi() function.
Similar convenience for integers. If so, such an integer. If not, then another number. The IIFi() function takes three mandatory parameters:
IIFs() function.
Similar convenience for strings. If so, such a string. If not, then another string. The IIFs() function takes three mandatory parameters:
Example of using the IIFc() function.
If the given price level is higher than the current Bid, then set a horizontal line at the given price level in blue, otherwise in red.
Without use of IIFc() function the above code would look as follows:
P.S. Attached is a script to test the IIFc() function.
Example of using the IIFs() function.
The IIFs() function is, in most cases, used in the commenting block of the EA operation. For example, it is used when outputting values of external parameters of the EA.
P.S. Attached is a script to test the IIFs() function.
An example of the use of the IIFd() function.
It is convenient to use IIFd() function when initializing some variables. For example, price levels of stop and take before opening a position.
Without the IIFd() function, this code would look as follows:
Example of using trading functions in the tester.
To show how trading functions intended for use in the tester only can be applied, I wrote e_ForTester, a swing Expert Advisor. The entry signal is a pair of unidirectional candlesticks. If the candlesticks are directed upwards, the EA closes the buy and sells. If the candlesticks are directed downwards, the Expert Advisor closes the sale and buys. There is only one position in the market at all times. Exit is either by the opposite signal, or by a stop/stop/stick. Stop and Take are two external parameters that can be optimized.
The following tester-only functions are used in the EA:
Trades of the e_ForTester Expert Advisor on the EURUSD H1 chart:
P.S. Attached: