Is there any function in DolphinDB that is similar to the Crossover in Backtrader?
For example, the initial state is "A < B". When "A > B", the A line crosses over the B line, which is expected to be output as an anomaly.
B", the A line" /> B", the A line" /> B", the A line"/>
Is there any function in DolphinDB that is similar to the Crossover in Backtrader?
For example, the initial state is "A < B". When "A > B", the A line crosses over the B line, which is expected to be output as an anomaly.
Copyright © 2021 Jogjafile Inc.
For the current points A, B, three indicators can be used together to determine whether the A line crosses over B line:
previous value A < previous value B
current value A > current value B
the slope of the line segment where point A is located > the slope of the line segment where B is located
Here are the script:
(1) Verify whether the crossover points exist when sym=`A.
According to the results, it can be seen that the crossover points are at time
2018.10.08T01:01:01.014,2018.10.08T01:01:01.020, and2018.10.08T01:01:01.030, respectively.The result meet the expectation.
(2) Verify whether the crossover points exist when sym=`B.
The result meet the expectation.