Category
General-Purpose Functions
Description
Returns both a value and a string
Syntax
Reason(value, string)
Parameters
value - numeric return value
string - string return value
Notes
This special-purpose function serves to allow a single ExitLimit or ExitStop formula to return different prices under different conditions and cause the resulting trade record to include a description of the condition that triggered the exit in its T.Reason field.
This capability was previously supported only in ExitRule by using Select. That worked implicitly because ExitRule is a true/false condition. If the formula returned any string value, that was interpreted as "true".
In contrast, ExitLimit and ExitStop need to return a specific price, so a function that can return both a value and a string was required to enable reason strings.
Example
ExitStop: if(Extern($SPY, C > MA(C, 100)),
Reason(FillPrice * 0.6, "bull market stop"),
Reason(FillPrice * 0.9, "bear market stop"))
|