App::financeta allows you to write English like logical statements or rules
that then get automatically compiled to valid PDL code that will execute on the
data that you have loaded.
The rules can be one or more statements that are separated by a semi-colon. Separating by a semi-colon allows the user to write very long and complex rules on multiple lines for clarity.
The rule has a simple syntax:
<ORDER> <when|if> <CONDITION> [<CONDITION> ... <CONDITION>]
CONDITION parts need to be separated by the keywords
ORDER part of the rule has the following syntax:
<buy|sell> [QUANTITY] at <PRICE>
The order types are
sell which are keywords. The
optional and is an integer. If the quantity is not provided,
100 is assumed. The
price is required and is either a real number
or a variable. The price and quantity need to be separated by the
Conditions can be a single condition or multiple conditions separated by logical
operators given by keywords
or. The NOT logical operator can be used with the
keyword or the
Nested conditions are supported using parentheses
). A nested condition consists of multiple single conditions and other
The single condition has the following possible syntaxes:
COMPLEMENT: not <VARIABLE | NUMBER> COMPARISON: <VARIABLE> <becomes|crosses> <positive|negative|zero|VARIABLE|NUMBER> \ [from <above|below>]
Variables are pre-generated by the
App::financeta application based on the
indicators that the user has added. When the user opens the editor to write the
rules, the variables that are allowed are provided in the comments with their
descriptions. Each variable begins with a
$ sign and is followed by an
There is a special declaration that can be used by the user and it is given below:
<allow|no> <long|short> trades
This declaration tells the code generator whether to allow or disallow long/short trades. The user can use this to tune their strategy output.
Comments are allowed, and any line beginning with the
# sign begins a comment.
Here is a sample example generated for an MACD indicator:
### START OF AUTOGENERATED CODE - DO NOT EDIT ### The list of variables that you can use is below: ### $open ### $high ### $low ### $close ### $macd_12_26_9 ### $macdsig_12_26_9 ### $macdhist_12_26_9 ### END OF AUTOGENERATED CODE no short trades; buy at $open when $macdhist_12_26_9 becomes positive and $macd_12_26_9 crosses $macdsig_12_26_9 from below; sell at $high when $macdhist_12_26_9 becomes negative and $macd_12_26_9 crosses $macdsig_12_26_9 from above;'
This shows that when the
$macdhist_12_26_9 variable value becomes positive
along with the crossing condition, a
buy signal will be generated. Similarly, a
sell signal will be generated
when it becomes negative and ther crossing condition is valid.
As you can see, short trades are not allowed in the strategy.