Express my idea - use formula as indicator

Being a Forex trader, I would like to test a lot of ideas on indicators quickly. I want to test really quickly because most ideas don't work. I did code indicator in my ftap system using C++ or in MT4 using MQL. I need at least half to an hour on one single indicator, and after I found the idea was useless, my time was wasted.

Being a developer, I'm lazy, or in better words, I want to be productive. Repeating coding indicators and wasting my time won't interest me.

Then here comes the idea: a versatile indicator parses the input expression, or formula, and output values based on the formula. Then what I need to do is to feed the indicator with new formula. Writing a new formula is much much faster than coding an indicator.

How the indicator looks

The image at right side shows the looking of four formulas.

The first one on the top is 10 period CCI averaged by 20 period EMA.

The second is the square root of the product of 9 and 14 period RSI then plus 100.

The third is 20 period EMA of the value of square root of the product of 9 and 14 period RSI.

The last one is the simple average of the close price, which is exactly same as a 20 period SMA.

The features

1, Powerful “@” operator. The “@” operator makes the indicator on its right accepts values from the indicator on its left as input. So “iCci(10) @ iMa(20)” can be read as: calculate the moving average using the values of CCI.

2, Compound expression. The bracket “()” can be used many times.

3, Function call such as “sqrt(iRsi)” and array indexing such as “pClose[1]”.

4, Many built in functions such as “abs”, “sum” and “sqrt”, and adding new functions is a piece of cake. An interesting function is “if(condition, true value, false value)”, it adds simple branching ability.

5, It even supports variable assignment such as “x = iRsi(12)”.

6, Optimized. The constant expression is calculated at compiling phase before executing. “sqrt(1 + 3) * iRsi” will become “2 * iRsi” when executing.

7, I use a modified version of Shunting-yard algorithm to parse the expression.

Is it useful?

I spent dozens of hours on coding the expression parse in C++ in my ftap system. The result is certainly worth my effort. So yes, it's very useful.

In the image at right side , the top indicator is the standard 14 period RSI and the bottom one is the formula indicator which is a variant of RSI. The formula looks much better than standard RSI. I wouldn't have tried the idea without the formula indicator because it will cost a lot of time to code it in an standalone indicator.


Enter your comment. Wiki syntax is allowed: