Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ The following list of strategies are currently supported by this package:
- [Awesome Oscillator Strategy](#awesome-oscillator-strategy)
- [Williams R Strategy](#williams-r-strategy)
- [Chande Forecast Oscillator Strategy](#chande-forecast-oscillator-strategy)
- [Projection Oscillator Strategy](#projection-oscillator-strategy)

## Usage

Expand Down Expand Up @@ -511,6 +512,14 @@ The [ChandeForecastOscillatorStrategy](https://pkg.go.dev/github.com/cinar/indic
actions := indicator.ChandeForecastOscillatorStrategy(asset)
```

#### Projection Oscillator Strategy

The [ProjectionOscillatorStrategy](https://pkg.go.dev/github.com/cinar/indicator#ProjectionOscillatorStrategy) uses *po* and *spo* values that are generated by the [ProjectionOscillator](https://pkg.go.dev/github.com/cinar/indicator#ProjectionOscillator) indicator function to provide a BUY action when *po* is above *spo*, and SELL action when *po* is below *spo*.

```golang
actions := indicator.ProjectionOscillatorStrategy(period, smooth, asset)
```

## Disclaimer

The information provided on this project is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.
Expand Down
31 changes: 31 additions & 0 deletions strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,34 @@ func MakeMovingChandeForecastOscillatorStrategy(period int) StrategyFunction {
return MovingChandeForecastOscillatorStrategy(period, asset)
}
}

// Projection oscillator strategy function.
func ProjectionOscillatorStrategy(period, smooth int, asset Asset) []Action {
actions := make([]Action, len(asset.Date))

po, spo := ProjectionOscillator(
period,
smooth,
asset.High,
asset.Low,
asset.Closing)

for i := 0; i < len(actions); i++ {
if po[i] > spo[i] {
actions[i] = BUY
} else if po[i] < spo[i] {
actions[i] = SELL
} else {
actions[i] = HOLD
}
}

return actions
}

// Make projection oscillator strategy.
func MakeProjectionOscillatorStrategy(period, smooth int) StrategyFunction {
return func(asset Asset) []Action {
return ProjectionOscillatorStrategy(period, smooth, asset)
}
}