-
Notifications
You must be signed in to change notification settings - Fork 2
Studies
Study is the object that is responsible for a visual representation of some data. Here you decide what data do you want to display and how it should be visualized - as a candlestick, line, column, mountain, etc.
You can add them to a chart, modify their properties or create a completely custom study.
Adding a built-in study is fairly simple:
// assume you've created a `financeChart` somewhere
val chart: SciFinanceChart
// create your studies
val priceSeriesStudy = PriceSeriesStudy(PaneId.DEFAULT_PANE)
val rsiStudy = RSIStudy(PaneId.uniqueId("RSI"))
// add them to your chart
chart.studies.add(priceSeriesStudy)
chart.studies.add(rsiStudy)
NOTE: Creating our priceSeriesStudy with a
PaneId.DEFAULT_PANE
pane id means that we want to place our study on the main pane. If you want it to be a separate pane, create your study with some unique id, as we did with the rsiStudy. Please follow the Pane article for more details.
Each of our studies has its own editable properties, depending on the FinanceSeries type and indicators included in that study. These editable properties are annotated with the @EditableProperty
annotation in order to allow you to collect all available properties, for example, for a study settings view. In order to get all editable properties of your study, your code might look, something like this:
private fun getStudyEditableList(study: IStudy, viewType: Int) : List<IEditable> {
val editableItems = mutableListOf<IEditable>()
study::class.java.methods.forEach { it ->
val annotation = it.getAnnotation(EditableProperty::class.java)
if (annotation != null) {
val childItem = it.invoke(study) as? IEditable
if (childItem != null && childItem.viewType == viewType && study.isValidEditableForSettings(childItem)) {
editableItems.add(childItem)
}
}
}
return editableItems
}
NOTE: There is a viewType parameter which you can use to filter you editable properties by type, for example whether it is FinanceSeries or Indicators.
As an example, let's take our RSIStudy
and try to modify its properties. It has 2 TALibIndicatorProvider.RSIIndicator
and LineFinanceSeries
:
-
TALibIndicatorProvider.RSIIndicator
has its own 2 properties: period and input. By default, period == 14 and input == "close" which means that we want to calulate our RSI based on close prices. Let's change our period to 50 and input to "open" price. It will produce the following result:
period == 14, input == "close" | period == 50, input == "open" |
---|---|
-
LineFinanceSeries
which has its own editable properties: opacity and strokeStyle with color, antiAliasing, thickness and strokeDashArray.
NOTE: You can find more about
PenStyle
in the SciChart Android Documentation
All of these properties have some default values in order to have a nice chart out-of-the-box. Feel free to edit them to match your design requirements. After some changes, your RSIStudy
might look, like this:
color == Constants.DefaultBlue thickness == 4f strokeDashArray == null |
color == Constants.DefaultRed thickness == 4f strokeDashArray == floatArrayOf(20f, 20f) |
---|---|
Finance SDK contains 14 built-in studies, available out of the box. There is on special PriceSeriesStudy
that displays candlesticks and volume bars and studies that represents technical indicators from the world's most famous TA-Lib (Technical Analysis) Library. Here is the list of them all available studies with screenshots from our SciTrader Android and iOS app. Please download it and try.
PriceSeriesStudy | ADXStudy |
---|---|
ATRStudy | BBandsStudy |
---|---|
CCIStudy | EMAStudy |
---|---|
HT_TrendlineStudy | MacdStudy |
---|---|
OBVStudy | RSIStudy |
---|---|
SARStudy | SMAStudy |
---|---|
STDDevStudy | StochStudy |
---|---|
NOTE: Some of our studies are added to the main pane, others - to the separate pane by default. You can change this behavior by providing a pane id as a Study init parameter. Please follow the Pane article for more details.