Clickable button on the chart using JavaFX or Java Swing

HalTrader

Well-known member
Joined
May 26, 2022
Posts
50
Likes
18
I wonder whether it is possible to create a clickable button using JavaFX or Java Swing, not on a GUI, but directly on the chart within a custom-written study?

I was able to build a clickable button on a GUI using JavaFX or Java Swing after watching a few YouTube videos. However, the question is how to integrate it within a study and use it directly on the chart, instead of generating a GUI. For example, when a user clicks on the button, it could trigger a customizable action, such as “place a limit buy order, with stop loss placed 1 or 2 ticks below the recent Swing Low and take profit placed 1 tick below the previous Swing High”, or something similar.

I know that we can use predefined keyboard shortcuts or mouse clicks (left/right single or double click, etc.) (Configure / Preferences / Orders / Submission), with a predefined exit strategy, but take profit or stop loss levels based on recent Swing High or Low can only be customized through custom coding.

This could be beneficial and very useful for scalping or day trading.

Any thoughts?

Thanks
 
Would be nice when Motivewave supports buttons/popups etc. natively on a chart. (I did not find it in the framework).

I created a 'panel' with labels, checkboxs, values and buttons in a Figure. The panel is shown as part of the black Motivewave chart canvas. The buttons can be used for eg. opening/closing trades. The components are drawn by the Figure.draw method (a button is simply drawn by a rectangle with text in it). The Study.onClick event needs to be passed to the Figure to handle the click and invoke an action and the Figure.contains method must return true when the mouse is in the panel.

I added a button in the panel by which an undecorated Swing JDialog is shown which hides when clicked outside. The dialog is used for more detailed configuration. I set the dialog to undecorated, alwaysOnTop and added a WindowsFocusListener which disposes(hides) the dialog when focus is lost. The swing dialog can be shown by calling setVisible (on the EventDispatchThread). I did not succeed in loading an other look and feel.

Succes,
Moti.
 
Thank you for the information. To clarify, the panel you created appears on a separate GUI, right? Not within a MotiveWave chart itself? If that’s the case, it’s similar to what I have done.

I will contact MotiveWave support and kindly request if it is possible to implement JavaFX- or Java Swing-based methods directly in their SDK in the future.
 
The panel is part of / in the chart at a fixed position, it draws over the bars. (it is not floating) It is a Figure that shows own created labels, values, buttons and checkboxs. I needed the buttons for open/close actions. With a Figure, you can draw anything on the chart.

You can show Swing dialogs. The problem is however that the swing dialog is not paired with the chart. When an other chart is shown or the chart layout changes the swing dialog needs to be repositioned and show probably other contents. So I ended up using a Figure which is part of the chart. Support for Swing/javaFx would be nice, an other mechanism hat supports invoking custom actions from a chart may work too (via the SDK).

Note that Motivewave offers a variety of ways to configure settings: study dialog, custom context menus and quick settings. So for most basic settings, Motivewave will do. See the SDK manual.
 
Thanks again for the information. I have already contacted MW support about the possibility of integrating JavaFX/Swing.
 
Top