Introducing The Trailing Order Logic
To read more about Trailing Orders in general and see examples of rule executions, please refer to this article.
Some definitions:
Price at rule launch: This is the price at which the rule bought or sold a coin before any trailing order condition
Current Live Price: This is the latest available price at which a coin is trading
Trailing Order Price: The price at which your rule would trigger
The Current Live Price is continuously evaluated against the 'Price at rule launch' until the trailing condition has been met and the rule triggers. The rule triggers when 'Trailing Order Price' = 'Current Live Price'.
Rule Logic Example 1
At the launch of the rule, the Trailing Order Price is equal to the 'Price at rule launch' minus 1% as per the condition set above ('if that coin has price decrease by 1% trailing'). As soon as the Current Live Price starts to change over time as the rule continues to run, the Trailing Order Price can be calculated as follows: 'Current Live Price minus 1%'.
Example:
Rule buys 15 USD of ETH with BUSD at 4.15pm at 1 ETH = 1,000 USD
At 4.15pm, 'Price at rule launch' is 1,000 USD, the Trailing Order Price is 1,000 USD - 1% = 990 USD
Assuming the Current Live Price of ETH at 10.20pm is now 1,110 USD, the order would trigger at the Trailing Order Price of 1,110 USD - 1% = 1,098.9 USD
Rule Logic Example 2
In the example above, there are multiple conditions that need to be met before the order executes. To activate trailing:
the arbiter validates both conditions in the i.e.
โIF that coin has price increase by 3 % from price at which you bought AND IF that coin has price decrease by 1 % trailing
if both conditions are true, the output will be true and the SELL action will be triggered.
If one condition is true and the other condition is false, the output will be false and the SELL action will not be triggered. Instead, another validation will be carried out by the arbiter continuously until both conditions are true.
Rule Logic Example 3a - Trailing in first Condition (decrease by)
Price at rule launch: 1 ETH at $1,197
Trailing Order Price: 1 ETH at $1,197
Possible cases:
1) Price decreases until it has decreased by 10% from $1,197 (trailing order price) --> the rule triggers
2) Price increases from $1,197, then at some point decreases by 10%
Example: assuming the price increases to $1,400 - this now becomes the new trailing order price. The rule triggers if the price decreases by 10% from $1,400.
Assuming the price now drops 10% from $1,400, reaching $1,260, the rule will sell.
The difference between using the 'Current Live Price' option in the dropdown [referred to here as 'price at rule launch'] and the 'trailing' price is that the rule would have continued to evaluate the price increase against the 'price at rule launch' of $1,197 if 'trailing' was not used. The rule would have triggered at a lower price of $1,077. The trader would have done worse compared to selling at $1,260.
Coinrule's engine will always take the highest reached trailing order price from which to calculate the trailing decrease.
Rule Logic Example 3b - Trailing in first Condition (increase by)
Price at rule launch: 1 ETH at $1,203
Trailing Order Price: 1 ETH at $1,203
Possible cases:
1) Price increases until it has increased by 10% from $1,203 (trailing order price) --> the rule triggers
2) Price decreases from $1,197, then at some point increases by 10%
Let's assume the price of 1 ETH now decreases to $1,150. The Trailing Order Price gets updated to $1,150. The system now evaluates the condition against the new Trailing Order Price of $1,150.
For the rule to trigger, the price would now need to increase by 10% from the new Trailing Order Price of $1,150 and reach a price of $1,300 before the order triggers.
Without using the trailing functionality here, the rule would have triggered at a higher price of $1,323.
In connection with a 'trailing price increase' and a 'Buy' you can catch trend reversals with a better entry price compared to the regular 'current live price' value.