Using ServerSocket and Socket within Indicators

Custom indicators, trading strategies, data export and recording and more...
rickbarlow
Posts: 43
Joined: Mon Feb 08, 2021 5:37 pm
Been thanked: 1 time

Using ServerSocket and Socket within Indicators

Post by rickbarlow » Wed Oct 06, 2021 8:53 pm

I am having difficulty in adding some logic to indicators I am using in Bookmap. Version = 7.2.0 build 17

I am monitoring two symbols using 2 bookmap tabs, call them A and B. I have 1 indicator #1 running on A, which is watching for a signal. I have 1 indicator #2 running on B which is used to plot an image at a given time and price. When I get a signal within Indicator #1, I want to send this info to Indicator #2 and it will then plot an image onto the chart of B. I decided to use a Java client/server socket to communicate between the two indicators. 

However, when I attempt to create the client socket, wherein the server is at the accept() server-side socket method, both of my Bookmap UIs hang, as well as the indicators are hung. (I put trace log statements around the calls to see where stuck.) I thought that maybe it was because of Threading logic, so I added these socket calls into separate threads, but that did not change the outcome.

Do you have an idea of what I may be missing, or need to change?
Do you have an example demo showing two indicators communicating, either using sockets, or some other method? (I did not want to write to a file and read from the file due to my concern of performance issues.
Thank you.

Svyatoslav
Site Admin
Posts: 278
Joined: Mon Jun 11, 2018 11:44 am
Has thanked: 2 times
Been thanked: 31 times

Re: Using ServerSocket and Socket within Indicators

Post by Svyatoslav » Thu Oct 07, 2021 9:13 am

Hi. I don't see why what you are doing should not work. I don't have an example at hand, but could you please post a short self-contained example of what you are trying to do? If you are working with sockets from different threads without blocking the main threads, I don't see how that would block bookmap UI. (I mean, I can see a few possible mistakes, but I would prefer to avoid guessing too much if possible)

Post Reply