As you can see a lot have happened since the last pictures of the application. So here is some things.
Main part
The applications is build up around a main frame that contains the bar chart and some overlays. As you can see there is also some text fields and buttons. The upper part is to search stocks/indexes and also handle the overlays in the bar char. These fields and buttons are:- Search field to enter a search criteria to filter the instruments to search for.
- Search button, to apply the search
- A combo box, to show the filtered search result, and also choose the stock to view. This combo box listen to changes and updates the bar chart with the selected stock
- Next there is a box to limit the range of the data. I have not introduced recalculation for splits and emissions so to have a possibility to handle to not show before these events, I added a box to filter away prices before this date part.
- Next there is the intervals for the moving averages in the chart, default they are set to 5,20,50 but can be changed but have as most 3 different, but also as few as one. Default they are Simple Moving Average (SMA),
- to change to Exponential Moving Average (EMA) there is a checkbox
- to update changed settings for Moving averages there is a button "Update averages"
- finally on the top there is a check box to switch on/off viewing of "Bollinger Bands"
In the bottom part there is buttons for additional chart types. these are the ones I picked as most interesting for me and they show some different aspect of the prices.
- Stocastics (show how a stocks price is doing in relation to past movements)
- RSI (shows how strong a stock is moving in the current direction)
- Aroon (shows if a stock is trending or oscillating)
- MACD (and also MACD-histogram) (a momentum oscillator)
As I mentioned the main part is a Bar chart diagram. It contains some overlays like volume, moving average and optional Bollinger bands. These help to get a basic overview of a stocks movement and trend. It is made up of a specialized panel for the bar chart to handle the drawing of the chart.
The main application implements a method named top that is used in wrapped Swing features used in Scala. I have an object representing my starting point of the application, the first lines looks like:
As you can see I provide a title and also here is the search field where to put a search string. The most important thing to note here is the inheritance of SimpleSwingApplication which makes this object a Swing application
The next part looks like this
Here you can see some on the fly declaration and reactions to events on the components. The following code shows how to add these to the contents of other panels. you can also see the creation at the click of the button, creation of a generic diagram for "stochastics" mixed in with a DrawListener to make it drawable. Also how the series of stochastics is added to a generic diagram can be seen here.
This last part of the code adds the actual panels containing the fields, bar chart and buttons to the Swing application.
Additional panels
To add some extra check to the main part there is some diagrams that first was their own specialized panel, but after some refactoring they now all except MACD uses a generalized panel called GenericDiagram and here is a part of that code:And here is addition of some of the buttons into menu panel (top panel) followed by some example of the bottom panel with addition of button and reactions to its event. You see here that here is where the panel frame is set up inside the reaction to show the GenericDiagram with "stochastic" data.
Not so much to mention really except that as you see I extend with a trait with basic chart properties. this is intended to have common properties for this and other diagrams. The var's is to be able to add series and date series to the diagram. So this panel is only responsible to draw the things that are sent to it.
Ability to draw
No bar chart is complete if it is not possible to draw some help lines. This is managed by adding a trait for this, that can be mixed in wherever I want it. The code for that trais is:An example of this functionality is to draw help lines in a MACD diagram. (or any really)
This can be mixed in like in this case:
And then it is possible to draw on that panel.