-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement the Larry Connors the 2-period RSI strategy Fixes #69 * Implement the Larry Connors the 2-period RSI strategy. Fixes #69
- Loading branch information
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) 2022 Onur Cinar. All Rights Reserved. | ||
// https://github.com/cinar/indicatorts | ||
|
||
import { Asset } from '../asset'; | ||
import { Action } from '../action'; | ||
import { rsi2 } from '../../indicator/momentum/rsi2'; | ||
|
||
/** | ||
* RSI 2. When 2-period RSI moves below 10, it is considered deeply oversold, | ||
* and the other way around when moves above 90. | ||
* | ||
* @param asset asset object. | ||
* @returns strategy actions. | ||
*/ | ||
export function rsi2Strategy(asset: Asset): Action[] { | ||
const indicator = rsi2(asset.closings); | ||
|
||
const actions = new Array<Action>(indicator.length); | ||
for (let i = 0; i < actions.length; i++) { | ||
if (indicator[i] < 10) { | ||
actions[i] = Action.BUY; | ||
} else if (indicator[i] > 90) { | ||
actions[i] = Action.SELL; | ||
} else { | ||
actions[i] = Action.HOLD; | ||
} | ||
} | ||
|
||
return actions; | ||
} |